Commit 6b10466b authored by Tobias Hunger's avatar Tobias Hunger

Core: Add some helper methods to VcsManager

Make VcsManager provide a generic way to list all IVersionControls
and to search for a specific one based on its id.

At some point we want to register the IVersionControls directly
with the VcsManager instead of going through the object pool and this
is a first step into this direction.

Change-Id: Id4ded85b29487f6d8adcd0cec1de490afae07132
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 5cefe1db
......@@ -223,6 +223,18 @@ void VcsManager::extensionsInitialized()
}
}
QList<IVersionControl *> VcsManager::versionControls()
{
return ExtensionSystem::PluginManager::getObjects<IVersionControl>();
}
IVersionControl *VcsManager::versionControl(Id id)
{
return Utils::findOrDefault(versionControls(), [id](const Core::IVersionControl *vc) {
return vc->id() == id;
});
}
void VcsManager::resetVersionControlForDirectory(const QString &inputDirectory)
{
if (inputDirectory.isEmpty())
......
......@@ -32,6 +32,7 @@
#define VCSMANAGER_H
#include "core_global.h"
#include "id.h"
#include <QString>
#include <QObject>
......@@ -63,6 +64,9 @@ public:
static void extensionsInitialized();
static QList<IVersionControl *> versionControls();
static IVersionControl *versionControl(Id id);
static void resetVersionControlForDirectory(const QString &inputDirectory);
static IVersionControl *findVersionControlForDirectory(const QString &directory,
QString *topLevelDirectory = 0);
......
......@@ -38,7 +38,6 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/iwizardfactory.h>
#include <coreplugin/vcsmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
......@@ -433,7 +432,7 @@ void ProjectWizardPage::initializeVersionControls()
}
} else {
// Create
foreach (IVersionControl *vc, ExtensionSystem::PluginManager::getObjects<IVersionControl>()) {
foreach (IVersionControl *vc, VcsManager::versionControls()) {
if (vc->supportsOperation(IVersionControl::CreateRepositoryOperation)) {
versionControlChoices.append(vc->displayName());
m_activeVersionControls.append(vc);
......
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