CheckoutWizards: Simplify code to look up specific pages

Change-Id: I0098e17585d73e05632027676e7712ef9c843da2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Tobias Hunger
2015-05-11 13:02:36 +02:00
parent 75f067550f
commit caca9dfa6f
5 changed files with 12 additions and 33 deletions

View File

@@ -40,6 +40,8 @@
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/wizard/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
#include <QDebug>
using namespace VcsBase;
@@ -70,14 +72,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{
const CloneWizardPage *cwp = 0;
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
if (!cwp)
return 0;
const CloneWizardPage *cwp = find<CloneWizardPage>();
QTC_ASSERT(cwp, return 0);
const VcsBaseClientSettings &settings = BazaarPlugin::instance()->client()->settings();
*checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory());

View File

@@ -66,13 +66,9 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir)
{
// Collect parameters for the checkout command.
// CVS does not allow for checking out into a different directory.
const CheckoutWizardPage *cwp = 0;
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId))))
break;
}
const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
QTC_ASSERT(cwp, return 0);
const CvsSettings settings = CvsPlugin::instance()->client()->settings();
const Utils::FileName binary = settings.binaryPath();
QStringList args;

View File

@@ -67,12 +67,7 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{
// Collect parameters for the clone command.
const CloneWizardPage *cwp = 0;
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
const CloneWizardPage *cwp = find<CloneWizardPage>();
QTC_ASSERT(cwp, return 0);
return cwp->createCheckoutJob(checkoutDir);
}

View File

@@ -39,6 +39,8 @@
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/wizard/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
using namespace VcsBase;
namespace Mercurial {
@@ -66,14 +68,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{
const CloneWizardPage *cwp = 0;
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
if (!cwp)
return 0;
const CloneWizardPage *cwp = find<CloneWizardPage>();
QTC_ASSERT(cwp, return 0);
const VcsBaseClientSettings &settings = MercurialPlugin::client()->settings();

View File

@@ -67,11 +67,7 @@ CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) :
VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir)
{
// Collect parameters for the checkout command.
const CheckoutWizardPage *cwp = 0;
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId))))
break;
}
const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
QTC_ASSERT(cwp, return 0);
SubversionClient *client = SubversionPlugin::instance()->client();