diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 73686384092..7327c8ea2cd 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -183,7 +184,15 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters)); - addAutoReleasedObject(new CloneWizardFactory); + auto cloneWizardFactory = new BaseCheckoutWizardFactory; + cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR)); + cloneWizardFactory->setIcon(QIcon(QLatin1String(":/bazaar/images/bazaar.png"))); + cloneWizardFactory->setDescription(tr("Clones a Bazaar branch and tries to load the contained project.")); + cloneWizardFactory->setDisplayName(tr("Bazaar Clone (Or Branch)")); + cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { + return new CloneWizard(path, parent); + }); + addAutoReleasedObject(cloneWizardFactory); const QString prefix = QLatin1String("bzr"); m_commandLocator = new CommandLocator("Bazaar", prefix, prefix); diff --git a/src/plugins/bazaar/clonewizard.cpp b/src/plugins/bazaar/clonewizard.cpp index a01e1fc6678..c41cc177b91 100644 --- a/src/plugins/bazaar/clonewizard.cpp +++ b/src/plugins/bazaar/clonewizard.cpp @@ -43,18 +43,6 @@ using namespace Bazaar::Internal; -CloneWizardFactory::CloneWizardFactory() -{ - setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR)); - setIcon(QIcon(QLatin1String(":/bazaar/images/bazaar.png"))); - setDescription(tr("Clones a Bazaar branch and tries to load the contained project.")); - setDisplayName(tr("Bazaar Clone (Or Branch)")); -} - -VcsBase::BaseCheckoutWizard *CloneWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new CloneWizard(path, parent); -} // -------------------------------------------------------------------- // CloneWizard: diff --git a/src/plugins/bazaar/clonewizard.h b/src/plugins/bazaar/clonewizard.h index 3363aca2bb6..20a273acd41 100644 --- a/src/plugins/bazaar/clonewizard.h +++ b/src/plugins/bazaar/clonewizard.h @@ -33,21 +33,9 @@ #include #include -#include - namespace Bazaar { namespace Internal { -class CloneWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - CloneWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; - class CloneWizard : public VcsBase::BaseCheckoutWizard { Q_OBJECT diff --git a/src/plugins/cvs/checkoutwizard.cpp b/src/plugins/cvs/checkoutwizard.cpp index ce4b3ab4fcc..9cca9a71394 100644 --- a/src/plugins/cvs/checkoutwizard.cpp +++ b/src/plugins/cvs/checkoutwizard.cpp @@ -40,19 +40,6 @@ namespace Cvs { namespace Internal { -CheckoutWizardFactory::CheckoutWizardFactory() -{ - setId(QLatin1String(VcsBase::Constants::VCS_ID_CVS)); - setIcon(QIcon(QLatin1String(":/cvs/images/cvs.png"))); - setDescription(tr("Checks out a CVS repository and tries to load the contained project.")); - setDisplayName(tr("CVS Checkout")); -} - -VcsBase::BaseCheckoutWizard *CheckoutWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new CheckoutWizard(path, parent); -} - // -------------------------------------------------------------------- // CheckoutWizard: // -------------------------------------------------------------------- diff --git a/src/plugins/cvs/checkoutwizard.h b/src/plugins/cvs/checkoutwizard.h index cd0b1e2dc68..fb88cadf1f7 100644 --- a/src/plugins/cvs/checkoutwizard.h +++ b/src/plugins/cvs/checkoutwizard.h @@ -36,16 +36,6 @@ namespace Cvs { namespace Internal { -class CheckoutWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - CheckoutWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; - class CheckoutWizard : public VcsBase::BaseCheckoutWizard { Q_OBJECT diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 69948e3365c..37f0716232b 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -37,6 +37,7 @@ #include "checkoutwizard.h" #include +#include #include #include #include @@ -256,7 +257,15 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) for (int i = 0; i < editorCount; i++) addAutoReleasedObject(new CVSEditorFactory(editorParameters + i, this, describeSlotC)); - addAutoReleasedObject(new CheckoutWizardFactory); + auto checkoutWizardFactory = new BaseCheckoutWizardFactory; + checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_CVS)); + checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/cvs/images/cvs.png"))); + checkoutWizardFactory->setDescription(tr("Checks out a CVS repository and tries to load the contained project.")); + checkoutWizardFactory->setDisplayName(tr("CVS Checkout")); + checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { + return new CheckoutWizard(path, parent); + }); + addAutoReleasedObject(checkoutWizardFactory); const QString prefix = QLatin1String("cvs"); m_commandLocator = new CommandLocator("CVS", prefix, prefix); diff --git a/src/plugins/git/clonewizard.cpp b/src/plugins/git/clonewizard.cpp index a119ff9e3dc..3a09dcd5f19 100644 --- a/src/plugins/git/clonewizard.cpp +++ b/src/plugins/git/clonewizard.cpp @@ -40,19 +40,6 @@ namespace Git { namespace Internal { -CloneWizardFactory::CloneWizardFactory() -{ - setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); - setIcon(QIcon(QLatin1String(":/git/images/git.png"))); - setDescription(tr("Clones a Git repository and tries to load the contained project.")); - setDisplayName(tr("Git Repository Clone")); -} - -VcsBase::BaseCheckoutWizard *CloneWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new CloneWizard(path, parent); -} - // -------------------------------------------------------------------- // CloneWizard: // -------------------------------------------------------------------- diff --git a/src/plugins/git/clonewizard.h b/src/plugins/git/clonewizard.h index 611cc0e4926..b86f331dfab 100644 --- a/src/plugins/git/clonewizard.h +++ b/src/plugins/git/clonewizard.h @@ -36,16 +36,6 @@ namespace Git { namespace Internal { -class CloneWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - CloneWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; - class CloneWizard : public VcsBase::BaseCheckoutWizard { Q_OBJECT diff --git a/src/plugins/git/gitorious/gitoriousclonewizard.cpp b/src/plugins/git/gitorious/gitoriousclonewizard.cpp index c593f299af5..b642ffe3cea 100644 --- a/src/plugins/git/gitorious/gitoriousclonewizard.cpp +++ b/src/plugins/git/gitorious/gitoriousclonewizard.cpp @@ -68,20 +68,6 @@ void GitoriousCloneWizardPage::initializePage() setRepository(m_repositoryPage->repositoryURL().toString()); } -// -------- GitoriousCloneWizard -GitoriousCloneWizardFactory::GitoriousCloneWizardFactory() -{ - setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); - setIcon(QIcon(QLatin1String(":/git/images/gitorious.png"))); - setDescription(tr("Clones a Gitorious repository and tries to load the contained project.")); - setDisplayName(tr("Gitorious Repository Clone")); -} - -VcsBase::BaseCheckoutWizard *GitoriousCloneWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new GitoriousCloneWizard(path, parent); -} - // -------------------------------------------------------------------- // GitoriousCloneWizard: // -------------------------------------------------------------------- diff --git a/src/plugins/git/gitorious/gitoriousclonewizard.h b/src/plugins/git/gitorious/gitoriousclonewizard.h index 3cefab8e465..9588a51b7c3 100644 --- a/src/plugins/git/gitorious/gitoriousclonewizard.h +++ b/src/plugins/git/gitorious/gitoriousclonewizard.h @@ -38,15 +38,6 @@ namespace Internal { // GitoriousCloneWizard: A wizard allowing for browsing // Gitorious-hosted projects. -class GitoriousCloneWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - GitoriousCloneWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; class GitoriousCloneWizard : public VcsBase::BaseCheckoutWizard { diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 33d41f952db..904bc6c8b42 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -296,8 +297,27 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new GitEditorFactory(editorParameters + i, m_gitClient, describeSlot)); addAutoReleasedObject(new GitSubmitEditorFactory(&submitParameters)); - addAutoReleasedObject(new CloneWizardFactory); - addAutoReleasedObject(new Gitorious::Internal::GitoriousCloneWizardFactory); + + auto cloneWizardFactory = new VcsBase::BaseCheckoutWizardFactory; + cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); + cloneWizardFactory->setIcon(QIcon(QLatin1String(":/git/images/git.png"))); + cloneWizardFactory->setDescription(tr("Clones a Git repository and tries to load the contained project.")); + cloneWizardFactory->setDisplayName(tr("Git Repository Clone")); + cloneWizardFactory->setWizardCreator([this] (const Utils::FileName &path, QWidget *parent) { + return new CloneWizard(path, parent); + }); + addAutoReleasedObject(cloneWizardFactory); + + // A wizard allowing for browsing Gitorious-hosted projects. + cloneWizardFactory = new VcsBase::BaseCheckoutWizardFactory; + cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); + cloneWizardFactory->setIcon(QIcon(QLatin1String(":/git/images/gitorious.png"))); + cloneWizardFactory->setDescription(tr("Clones a Gitorious repository and tries to load the contained project.")); + cloneWizardFactory->setDisplayName(tr("Gitorious Repository Clone")); + cloneWizardFactory->setWizardCreator([this] (const Utils::FileName &path, QWidget *parent) { + return new Gitorious::Internal::GitoriousCloneWizard(path, parent); + }); + addAutoReleasedObject(cloneWizardFactory); const QString prefix = QLatin1String("git"); m_commandLocator = new CommandLocator("Git", prefix, prefix); diff --git a/src/plugins/mercurial/clonewizard.cpp b/src/plugins/mercurial/clonewizard.cpp index 453de71ff0c..1884958f9b1 100644 --- a/src/plugins/mercurial/clonewizard.cpp +++ b/src/plugins/mercurial/clonewizard.cpp @@ -40,19 +40,6 @@ using namespace Mercurial::Internal; using namespace VcsBase; -CloneWizardFactory::CloneWizardFactory() -{ - setId(QLatin1String(Constants::VCS_ID_MERCURIAL)); - setIcon(QIcon(QLatin1String(":/mercurial/images/hg.png"))); - setDescription(tr("Clones a Mercurial repository and tries to load the contained project.")); - setDisplayName(tr("Mercurial Clone")); -} - -BaseCheckoutWizard *CloneWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new CloneWizard(path, parent); -} - // -------------------------------------------------------------------- // CloneWizard: // -------------------------------------------------------------------- diff --git a/src/plugins/mercurial/clonewizard.h b/src/plugins/mercurial/clonewizard.h index 8394fbd8053..05f14ea2cb2 100644 --- a/src/plugins/mercurial/clonewizard.h +++ b/src/plugins/mercurial/clonewizard.h @@ -36,16 +36,6 @@ namespace Mercurial { namespace Internal { -class CloneWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - CloneWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; - class CloneWizard : public VcsBase::BaseCheckoutWizard { Q_OBJECT diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 8789987cf45..5908f0eec12 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -68,18 +69,26 @@ #include #include -using namespace Mercurial::Internal; -using namespace Mercurial; +#ifdef WITH_TESTS +#include +#endif + using namespace VcsBase; using namespace Utils; +namespace Mercurial { +namespace Internal { + +using namespace VcsBase::Constants; +using namespace Mercurial::Constants; + static const VcsBaseEditorParameters editorParameters[] = { { LogOutput, - Constants::FILELOG_ID, - Constants::FILELOG_DISPLAY_NAME, - Constants::FILELOG, - Constants::LOGAPP}, + FILELOG_ID, + FILELOG_DISPLAY_NAME, + FILELOG, + LOGAPP}, { AnnotateOutput, Constants::ANNOTATELOG_ID, @@ -149,7 +158,15 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters)); - addAutoReleasedObject(new CloneWizardFactory); + auto cloneWizardFactory = new BaseCheckoutWizardFactory; + cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_MERCURIAL)); + cloneWizardFactory->setIcon(QIcon(QLatin1String(":/mercurial/images/hg.png"))); + cloneWizardFactory->setDescription(tr("Clones a Mercurial repository and tries to load the contained project.")); + cloneWizardFactory->setDisplayName(tr("Mercurial Clone")); + cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { + return new CloneWizard(path, parent); + }); + addAutoReleasedObject(cloneWizardFactory); const QString prefix = QLatin1String("hg"); m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix); @@ -679,7 +696,6 @@ void MercurialPlugin::updateActions(VcsBasePlugin::ActionState as) } #ifdef WITH_TESTS -#include void MercurialPlugin::testDiffFileResolving_data() { @@ -736,4 +752,7 @@ void MercurialPlugin::testLogResolving() } #endif +} // namespace Internal +} // namespace Mercurial + Q_EXPORT_PLUGIN(MercurialPlugin) diff --git a/src/plugins/subversion/checkoutwizard.cpp b/src/plugins/subversion/checkoutwizard.cpp index 566ec4bdecf..9c520bd809c 100644 --- a/src/plugins/subversion/checkoutwizard.cpp +++ b/src/plugins/subversion/checkoutwizard.cpp @@ -38,24 +38,9 @@ #include #include -#include - namespace Subversion { namespace Internal { -CheckoutWizardFactory::CheckoutWizardFactory() -{ - setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION)); - setIcon(QIcon(QLatin1String(":/subversion/images/subversion.png"))); - setDescription(tr("Checks out a Subversion repository and tries to load the contained project.")); - setDisplayName(tr("Subversion Checkout")); -} - -VcsBase::BaseCheckoutWizard *CheckoutWizardFactory::create(const Utils::FileName &path, QWidget *parent) const -{ - return new CheckoutWizard(path, parent); -} - // -------------------------------------------------------------------- // CheckoutWizard: // -------------------------------------------------------------------- diff --git a/src/plugins/subversion/checkoutwizard.h b/src/plugins/subversion/checkoutwizard.h index 712299dcad9..690aaf5150b 100644 --- a/src/plugins/subversion/checkoutwizard.h +++ b/src/plugins/subversion/checkoutwizard.h @@ -36,16 +36,6 @@ namespace Subversion { namespace Internal { -class CheckoutWizardFactory : public VcsBase::BaseCheckoutWizardFactory -{ - Q_OBJECT - -public: - CheckoutWizardFactory(); - - VcsBase::BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const; -}; - class CheckoutWizard : public VcsBase::BaseCheckoutWizard { Q_OBJECT diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 6affa58cfda..eb2fbef1b7f 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -272,7 +273,15 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e for (int i = 0; i < editorCount; i++) addAutoReleasedObject(new SubversionEditorFactory(editorParameters + i, this, describeSlot)); - addAutoReleasedObject(new CheckoutWizardFactory); + auto checkoutWizardFactory = new BaseCheckoutWizardFactory; + checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION)); + checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/subversion/images/subversion.png"))); + checkoutWizardFactory->setDescription(tr("Checks out a Subversion repository and tries to load the contained project.")); + checkoutWizardFactory->setDisplayName(tr("Subversion Checkout")); + checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { + return new CheckoutWizard(path, parent); + }); + addAutoReleasedObject(checkoutWizardFactory); const QString prefix = QLatin1String("svn"); m_commandLocator = new CommandLocator("Subversion", prefix, prefix); diff --git a/src/plugins/vcsbase/basecheckoutwizardfactory.cpp b/src/plugins/vcsbase/basecheckoutwizardfactory.cpp index f5ca07f639a..ff4d312f91a 100644 --- a/src/plugins/vcsbase/basecheckoutwizardfactory.cpp +++ b/src/plugins/vcsbase/basecheckoutwizardfactory.cpp @@ -83,7 +83,7 @@ void BaseCheckoutWizardFactory::runWizard(const QString &path, QWidget *parent, Utils::FileName checkoutPath; { - QScopedPointer wizard(create(Utils::FileName::fromString(path), parent)); + QScopedPointer wizard(m_wizardCreator(Utils::FileName::fromString(path), parent)); wizard->setWindowTitle(displayName()); checkoutPath = wizard->run(); } @@ -151,4 +151,9 @@ QString BaseCheckoutWizardFactory::openProject(const Utils::FileName &path, QStr return projectFile; } +void BaseCheckoutWizardFactory::setWizardCreator(const BaseCheckoutWizardFactory::WizardCreator &creator) +{ + m_wizardCreator = creator; +} + } // namespace VcsBase diff --git a/src/plugins/vcsbase/basecheckoutwizardfactory.h b/src/plugins/vcsbase/basecheckoutwizardfactory.h index 8901d950f1b..95bb2580b4f 100644 --- a/src/plugins/vcsbase/basecheckoutwizardfactory.h +++ b/src/plugins/vcsbase/basecheckoutwizardfactory.h @@ -35,6 +35,8 @@ #include +#include + namespace VcsBase { class BaseCheckoutWizard; class Command; @@ -50,7 +52,11 @@ public: static QString openProject(const Utils::FileName &path, QString *errorMessage); - virtual BaseCheckoutWizard *create(const Utils::FileName &path, QWidget *parent = 0) const = 0; + typedef std::function WizardCreator; + void setWizardCreator(const WizardCreator &creator); + +private: + WizardCreator m_wizardCreator; }; } // namespace VcsBase