forked from qt-creator/qt-creator
Vcs: Dissolve VcsManager::registerVersionControl
It's a somewhat unusual pattern, spelling it out will help to move the vcs plugins setup closer to the now-usual pattern. Change-Id: Ie7b70e52d75e34cd36b6a1d55ca868e3edab44a7 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -151,7 +151,9 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
|
||||
Context context(Constants::BAZAAR_CONTEXT);
|
||||
|
||||
m_client = new BazaarClient;
|
||||
auto vcsCtrl = initializeVcs<BazaarControl>(context, m_client);
|
||||
auto vcsCtrl = new BazaarControl(m_client);
|
||||
initializeVcs(vcsCtrl, context);
|
||||
|
||||
connect(m_client, &VcsBaseClient::changed, vcsCtrl, &BazaarControl::changed);
|
||||
|
||||
new OptionsPage(vcsCtrl, this);
|
||||
|
@@ -411,7 +411,8 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
|
||||
|
||||
Context context(CLEARCASE_CONTEXT);
|
||||
|
||||
initializeVcs<ClearCaseControl>(context, this);
|
||||
auto vcsCtrl = new ClearCaseControl(this);
|
||||
initializeVcs(vcsCtrl, context);
|
||||
|
||||
m_clearcasePluginInstance = this;
|
||||
connect(ICore::instance(), &ICore::coreAboutToClose, this, &ClearCasePlugin::closing);
|
||||
|
@@ -143,6 +143,12 @@ QString IVersionControl::vcsTopic(const QString &topLevel)
|
||||
return m_topicCache ? m_topicCache->topic(topLevel) : QString();
|
||||
}
|
||||
|
||||
IVersionControl::IVersionControl(IVersionControl::TopicCache *topicCache)
|
||||
: m_topicCache(topicCache)
|
||||
{
|
||||
Core::VcsManager::addVersionControl(this);
|
||||
}
|
||||
|
||||
IVersionControl::~IVersionControl()
|
||||
{
|
||||
delete m_topicCache;
|
||||
|
@@ -86,7 +86,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
explicit IVersionControl(TopicCache *topicCache = nullptr) : m_topicCache(topicCache) {}
|
||||
explicit IVersionControl(TopicCache *topicCache = nullptr);
|
||||
~IVersionControl() override;
|
||||
|
||||
virtual QString displayName() const = 0;
|
||||
|
@@ -56,14 +56,6 @@ class CORE_EXPORT VcsManager : public QObject
|
||||
public:
|
||||
static VcsManager *instance();
|
||||
|
||||
template <typename T, typename... Args>
|
||||
static T *registerVersionControl(Args&&... args)
|
||||
{
|
||||
auto vc = new T(std::forward<Args>(args)...);
|
||||
addVersionControl(vc);
|
||||
return vc;
|
||||
}
|
||||
|
||||
static void extensionsInitialized();
|
||||
|
||||
static const QList<IVersionControl *> versionControls();
|
||||
@@ -110,11 +102,11 @@ private:
|
||||
explicit VcsManager(QObject *parent = nullptr);
|
||||
~VcsManager() override;
|
||||
|
||||
void handleConfigurationChanges();
|
||||
static void addVersionControl(IVersionControl *vc);
|
||||
|
||||
void handleConfigurationChanges();
|
||||
|
||||
friend class Core::Internal::MainWindow;
|
||||
friend class Core::IVersionControl;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -197,7 +197,8 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
Context context(CVS_CONTEXT);
|
||||
|
||||
initializeVcs<CvsControl>(context, this);
|
||||
auto vcsCtrl = new CvsControl(this);
|
||||
initializeVcs(vcsCtrl, context);
|
||||
|
||||
m_cvsPluginInstance = this;
|
||||
|
||||
|
@@ -299,7 +299,8 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
m_gitClient = new GitClient;
|
||||
|
||||
auto vc = initializeVcs<GitVersionControl>(context, m_gitClient);
|
||||
auto vc = new GitVersionControl(m_gitClient);
|
||||
initializeVcs(vc, context);
|
||||
|
||||
// Create the settings Page
|
||||
auto settingsPage = new SettingsPage(vc, this);
|
||||
|
@@ -122,7 +122,8 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
Core::Context context(Constants::MERCURIAL_CONTEXT);
|
||||
|
||||
m_client = new MercurialClient;
|
||||
auto vc = initializeVcs<MercurialControl>(context, m_client);
|
||||
auto vc = new MercurialControl(m_client);
|
||||
initializeVcs(vc, context);
|
||||
|
||||
new OptionsPage(vc, this);
|
||||
|
||||
|
@@ -182,7 +182,8 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
|
||||
Q_UNUSED(errorMessage)
|
||||
Context context(PERFORCE_CONTEXT);
|
||||
|
||||
initializeVcs<PerforceVersionControl>(context, this);
|
||||
auto vcsCtrl = new PerforceVersionControl(this);
|
||||
initializeVcs(vcsCtrl, context);
|
||||
|
||||
m_instance = this;
|
||||
|
||||
|
@@ -211,7 +211,8 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
|
||||
Context context(SUBVERSION_CONTEXT);
|
||||
|
||||
initializeVcs<SubversionControl>(context, this);
|
||||
auto vcsCtrl = new SubversionControl(this);
|
||||
initializeVcs(vcsCtrl, context);
|
||||
|
||||
m_subversionPluginInstance = this;
|
||||
|
||||
|
@@ -130,14 +130,6 @@ class VCSBASE_EXPORT VcsBasePlugin : public ExtensionSystem::IPlugin
|
||||
protected:
|
||||
explicit VcsBasePlugin();
|
||||
|
||||
template<class T, typename... Args>
|
||||
T *initializeVcs(const Core::Context &context, Args&&... args)
|
||||
{
|
||||
T *vc = Core::VcsManager::registerVersionControl<T>(std::forward<Args>(args)...);
|
||||
initializeVcs(vc, context);
|
||||
return vc;
|
||||
}
|
||||
|
||||
void extensionsInitialized() override;
|
||||
|
||||
public:
|
||||
@@ -216,12 +208,12 @@ protected:
|
||||
// Returns whether actions should be set up further.
|
||||
bool enableMenuAction(ActionState as, QAction *in) const;
|
||||
|
||||
void initializeVcs(Core::IVersionControl *vc, const Core::Context &context);
|
||||
|
||||
private:
|
||||
void slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result);
|
||||
void slotStateChanged(const VcsBase::Internal::State &s, Core::IVersionControl *vc);
|
||||
|
||||
void initializeVcs(Core::IVersionControl *vc, const Core::Context &context);
|
||||
|
||||
VcsBasePluginPrivate *d;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user