forked from qt-creator/qt-creator
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 <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user