Skip to content
Snippets Groups Projects
Commit caca9dfa authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CheckoutWizards: Simplify code to look up specific pages


Change-Id: I0098e17585d73e05632027676e7712ef9c843da2
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
parent 75f06755
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/wizard/vcsconfigurationpage.h> #include <vcsbase/wizard/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
using namespace VcsBase; using namespace VcsBase;
...@@ -70,14 +72,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : ...@@ -70,14 +72,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{ {
const CloneWizardPage *cwp = 0; const CloneWizardPage *cwp = find<CloneWizardPage>();
foreach (int pageId, pageIds()) { QTC_ASSERT(cwp, return 0);
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
if (!cwp)
return 0;
const VcsBaseClientSettings &settings = BazaarPlugin::instance()->client()->settings(); const VcsBaseClientSettings &settings = BazaarPlugin::instance()->client()->settings();
*checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory()); *checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory());
......
...@@ -66,13 +66,9 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir) ...@@ -66,13 +66,9 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir)
{ {
// Collect parameters for the checkout command. // Collect parameters for the checkout command.
// CVS does not allow for checking out into a different directory. // CVS does not allow for checking out into a different directory.
const CheckoutWizardPage *cwp = 0; const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId))))
break;
}
QTC_ASSERT(cwp, return 0); QTC_ASSERT(cwp, return 0);
const CvsSettings settings = CvsPlugin::instance()->client()->settings(); const CvsSettings settings = CvsPlugin::instance()->client()->settings();
const Utils::FileName binary = settings.binaryPath(); const Utils::FileName binary = settings.binaryPath();
QStringList args; QStringList args;
......
...@@ -67,12 +67,7 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : ...@@ -67,12 +67,7 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{ {
// Collect parameters for the clone command. // Collect parameters for the clone command.
const CloneWizardPage *cwp = 0; const CloneWizardPage *cwp = find<CloneWizardPage>();
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
QTC_ASSERT(cwp, return 0); QTC_ASSERT(cwp, return 0);
return cwp->createCheckoutJob(checkoutDir); return cwp->createCheckoutJob(checkoutDir);
} }
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/wizard/vcsconfigurationpage.h> #include <vcsbase/wizard/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
using namespace VcsBase; using namespace VcsBase;
namespace Mercurial { namespace Mercurial {
...@@ -66,14 +68,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : ...@@ -66,14 +68,8 @@ CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{ {
const CloneWizardPage *cwp = 0; const CloneWizardPage *cwp = find<CloneWizardPage>();
foreach (int pageId, pageIds()) { QTC_ASSERT(cwp, return 0);
if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId))))
break;
}
if (!cwp)
return 0;
const VcsBaseClientSettings &settings = MercurialPlugin::client()->settings(); const VcsBaseClientSettings &settings = MercurialPlugin::client()->settings();
......
...@@ -67,11 +67,7 @@ CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) : ...@@ -67,11 +67,7 @@ CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) :
VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir) VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir)
{ {
// Collect parameters for the checkout command. // Collect parameters for the checkout command.
const CheckoutWizardPage *cwp = 0; const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
foreach (int pageId, pageIds()) {
if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId))))
break;
}
QTC_ASSERT(cwp, return 0); QTC_ASSERT(cwp, return 0);
SubversionClient *client = SubversionPlugin::instance()->client(); SubversionClient *client = SubversionPlugin::instance()->client();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment