Fixes: Enable switching of VCS according to currentProject

Task: 205821
RevBy: con
Details:  Add a IVersionControl to git. Extend IF to able to return a name and add enabling options. Connect project explorer to enable the right VCS.
This commit is contained in:
Friedemann Kleint
2008-12-03 15:04:51 +01:00
parent 876c775805
commit 0b99d82d4e
21 changed files with 283 additions and 138 deletions

View File

@@ -17,7 +17,8 @@ HEADERS += gitplugin.h \
giteditor.h \
annotationhighlighter.h \
gitsubmiteditorwidget.h \
gitsubmiteditor.h
gitsubmiteditor.h \
gitversioncontrol.h
SOURCES += gitplugin.cpp \
gitoutputwindow.cpp \
@@ -28,7 +29,8 @@ SOURCES += gitplugin.cpp \
giteditor.cpp \
annotationhighlighter.cpp \
gitsubmiteditorwidget.cpp \
gitsubmiteditor.cpp
gitsubmiteditor.cpp \
gitversioncontrol.cpp
FORMS += changeselectiondialog.ui \
settingspage.ui \

View File

@@ -87,11 +87,6 @@ GitClient::~GitClient()
{
}
bool GitClient::vcsOpen(const QString &fileName)
{
return m_plugin->vcsOpen(fileName);
}
QString GitClient::findRepositoryForFile(const QString &fileName)
{
const QString gitDirectory = QLatin1String(kGitDirectoryC);

View File

@@ -62,17 +62,14 @@ class GitCommand;
struct CommitData;
struct GitSubmitEditorPanelData;
class GitClient : public Core::IVersionControl
class GitClient : public QObject
{
Q_OBJECT
public:
GitClient(GitPlugin *plugin, Core::ICore *core);
explicit GitClient(GitPlugin *plugin, Core::ICore *core);
~GitClient();
bool vcsOpen(const QString &fileName);
bool vcsAdd(const QString &) { return false; }
bool vcsDelete(const QString &) { return false; }
bool managesDirectory(const QString &) const { return false; }
QString findTopLevelForDirectory(const QString &) const { return QString(); }

View File

@@ -33,6 +33,7 @@
#include "gitplugin.h"
#include "gitclient.h"
#include "gitversioncontrol.h"
#include "giteditor.h"
#include "gitconstants.h"
#include "changeselectiondialog.h"
@@ -132,6 +133,7 @@ GitPlugin::GitPlugin() :
m_settingsPage(0),
m_coreListener(0),
m_submitEditorFactory(0),
m_versionControl(0),
m_changeTmpFile(0)
{
Q_ASSERT(m_instance == 0);
@@ -170,6 +172,12 @@ GitPlugin::~GitPlugin()
m_submitEditorFactory = 0;
}
if (m_versionControl) {
removeObject(m_versionControl);
delete m_versionControl;
m_versionControl = 0;
}
cleanChangeTmpFile();
delete m_gitClient;
m_instance = 0;
@@ -235,6 +243,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message)
m_submitEditorFactory = new GitSubmitEditorFactory(&submitParameters);
addObject(m_submitEditorFactory);
m_versionControl = new GitVersionControl(m_gitClient);
addObject(m_versionControl);
//register actions
Core::ActionManagerInterface *actionManager = m_core->actionManager();
@@ -245,6 +256,10 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *error_message)
actionManager->createMenu(QLatin1String("Git"));
gitContainer->menu()->setTitle(tr("&Git"));
toolsContainer->addMenu(gitContainer);
if (QAction *ma = gitContainer->menu()->menuAction()) {
ma->setEnabled(m_versionControl->isEnabled());
connect(m_versionControl, SIGNAL(enabledChanged(bool)), ma, SLOT(setVisible(bool)));
}
Core::ICommand *command;
QAction *tmpaction;
@@ -383,12 +398,6 @@ void GitPlugin::extensionsInitialized()
m_projectExplorer = ExtensionSystem::PluginManager::instance()->getObject<ProjectExplorer::ProjectExplorerPlugin>();
}
bool GitPlugin::vcsOpen(const QString &fileName)
{
Q_UNUSED(fileName);
return false;
}
void GitPlugin::submitEditorDiff(const QStringList &files)
{
if (files.empty())

View File

@@ -55,6 +55,7 @@ QT_END_NAMESPACE
namespace Core {
class IEditorFactory;
class ICore;
class IVersionControl;
}
namespace Git {
@@ -87,8 +88,6 @@ public:
~GitPlugin();
static GitPlugin *instance();
bool vcsOpen(const QString &fileName);
bool initialize(const QStringList &arguments
, QString *error_message);
void extensionsInitialized();
@@ -154,6 +153,7 @@ private:
QList<Core::IEditorFactory*> m_editorFactories;
CoreListener *m_coreListener;
Core::IEditorFactory *m_submitEditorFactory;
Core::IVersionControl *m_versionControl;
QString m_submitRepository;
QStringList m_submitOrigCommitFiles;
QTemporaryFile *m_changeTmpFile;