Commit 351abd03 authored by hjk's avatar hjk

Vcs: Flatten the VcsBase::BaseCheckoutWizard hierarchy

Following the new simple-factory pattern

Change-Id: Idceb7a339169af37a040f9da7d36d3fe22dfb347
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 2961c1c2
......@@ -57,6 +57,7 @@
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbasesubmiteditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseoutputwindow.h>
......@@ -183,7 +184,15 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
addAutoReleasedObject(new VcsSubmitEditorFactory<CommitEditor>(&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);
......
......@@ -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:
......
......@@ -33,21 +33,9 @@
#include <vcsbase/basecheckoutwizardfactory.h>
#include <vcsbase/basecheckoutwizard.h>
#include <QIcon>
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
......
......@@ -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:
// --------------------------------------------------------------------
......
......@@ -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
......
......@@ -37,6 +37,7 @@
#include "checkoutwizard.h"
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
......@@ -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);
......
......@@ -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:
// --------------------------------------------------------------------
......
......@@ -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
......
......@@ -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:
// --------------------------------------------------------------------
......
......@@ -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
{
......
......@@ -68,6 +68,7 @@
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/submitfilemodel.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/cleandialog.h>
......@@ -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);
......
......@@ -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:
// --------------------------------------------------------------------
......
......@@ -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
......
......@@ -57,6 +57,7 @@
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <QtPlugin>
......@@ -68,18 +69,26 @@
#include <QDialog>
#include <QFileDialog>
using namespace Mercurial::Internal;
using namespace Mercurial;
#ifdef WITH_TESTS
#include <QTest>
#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<CommitEditor>(&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 <QTest>
void MercurialPlugin::testDiffFileResolving_data()
{
......@@ -736,4 +752,7 @@ void MercurialPlugin::testLogResolving()
}
#endif
} // namespace Internal
} // namespace Mercurial
Q_EXPORT_PLUGIN(MercurialPlugin)
......@@ -38,24 +38,9 @@
#include <vcsbase/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
#include <QIcon>
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:
// --------------------------------------------------------------------
......
......@@ -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
......
......@@ -42,6 +42,7 @@
#include <vcsbase/command.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
......@@ -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);
......
......@@ -83,7 +83,7 @@ void BaseCheckoutWizardFactory::runWizard(const QString &path, QWidget *parent,
Utils::FileName checkoutPath;
{
QScopedPointer<BaseCheckoutWizard> wizard(create(Utils::FileName::fromString(path), parent));
QScopedPointer<BaseCheckoutWizard> 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
......@@ -35,6 +35,8 @@
#include <utils/fileutils.h>
#include <functional>
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<BaseCheckoutWizard *(const Utils::FileName &path, QWidget *parent)> WizardCreator;
void setWizardCreator(const WizardCreator &creator);
private:
WizardCreator m_wizardCreator;
};
} // namespace VcsBase
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment