From 40f5d38b918cdb84ca0b0548ce605b45af1d532c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Tue, 5 Jan 2010 16:36:27 +0100 Subject: [PATCH] Git: Introduce diff repository and group actions. --- src/plugins/git/gitplugin.cpp | 26 +++++++++++++++++++++----- src/plugins/git/gitplugin.h | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 60d2187c3ff..5ceaeadf217 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -110,6 +110,7 @@ GitPlugin::GitPlugin() : m_core(0), m_diffAction(0), m_diffProjectAction(0), + m_diffRepositoryAction(0), m_statusRepositoryAction(0), m_logAction(0), m_blameAction(0), @@ -270,11 +271,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject())); gitContainer->addAction(command); - m_statusRepositoryAction = new QAction(tr("Repository Status"), this); - command = actionManager->registerAction(m_statusRepositoryAction, "Git.StatusRepository", globalcontext); - connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository())); - gitContainer->addAction(command); - m_logProjectAction = new Utils::ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = actionManager->registerAction(m_logProjectAction, "Git.LogProject", globalcontext); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+K"))); @@ -282,6 +278,18 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject())); gitContainer->addAction(command); + gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Repository"), this)); + + m_diffRepositoryAction = new QAction(tr("Diff Repository"), this); + command = actionManager->registerAction(m_diffRepositoryAction, "Git.DiffRepository", globalcontext); + connect(m_diffRepositoryAction, SIGNAL(triggered()), this, SLOT(diffRepository())); + gitContainer->addAction(command); + + m_statusRepositoryAction = new QAction(tr("Repository Status"), this); + command = actionManager->registerAction(m_statusRepositoryAction, "Git.StatusRepository", globalcontext); + connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository())); + gitContainer->addAction(command); + m_undoRepositoryAction = new QAction(tr("Undo Repository Changes"), this); command = actionManager->registerAction(m_undoRepositoryAction, "Git.UndoRepository", globalcontext); command->setAttribute(Core::Command::CA_UpdateText); @@ -390,6 +398,13 @@ void GitPlugin::diffCurrentProject() m_gitClient->diff(state.currentProjectTopLevel(), QStringList(), state.relativeCurrentProject()); } +void GitPlugin::diffRepository() +{ + const VCSBase::VCSBasePluginState state = currentState(); + QTC_ASSERT(state.hasTopLevel(), return) + m_gitClient->diff(state.topLevel(), QStringList(), QStringList()); +} + void GitPlugin::statusRepository() { const VCSBase::VCSBasePluginState state = currentState(); @@ -673,6 +688,7 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) m_undoRepositoryAction->setEnabled(projectEnabled); const bool repositoryEnabled = currentState().hasTopLevel(); + m_diffRepositoryAction->setEnabled(repositoryEnabled); m_statusRepositoryAction->setEnabled(repositoryEnabled); m_branchListAction->setEnabled(repositoryEnabled); m_stashListAction->setEnabled(repositoryEnabled); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index baa46321cbd..924ccf9f299 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -88,6 +88,7 @@ public: private slots: void diffCurrentFile(); void diffCurrentProject(); + void diffRepository(); void submitEditorDiff(const QStringList &unstaged, const QStringList &staged); void submitCurrentLog(); void statusRepository(); @@ -121,6 +122,7 @@ private: Core::ICore *m_core; Utils::ParameterAction *m_diffAction; Utils::ParameterAction *m_diffProjectAction; + QAction *m_diffRepositoryAction; QAction *m_statusRepositoryAction; Utils::ParameterAction *m_logAction; Utils::ParameterAction *m_blameAction; -- GitLab