forked from qt-creator/qt-creator
Add command locator.
Make it possible to trigger actions from the locator bar by registering an instance of Locator::CommandLocator by prefix. Currently used for VCS systems. Acked-by: con Initial-patch-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
#include <locator/commandlocator.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
@@ -150,6 +151,7 @@ CVSPlugin *CVSPlugin::m_cvsPluginInstance = 0;
|
||||
|
||||
CVSPlugin::CVSPlugin() :
|
||||
VCSBase::VCSBasePlugin(QLatin1String(CVS::Constants::CVSCOMMITEDITOR_ID)),
|
||||
m_commandLocator(0),
|
||||
m_addAction(0),
|
||||
m_deleteAction(0),
|
||||
m_revertAction(0),
|
||||
@@ -239,6 +241,10 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
|
||||
addAutoReleasedObject(new CheckoutWizard);
|
||||
|
||||
const QString prefix = QLatin1String("cvs");
|
||||
m_commandLocator = new Locator::CommandLocator(QLatin1String("CVS"), prefix, prefix);
|
||||
addAutoReleasedObject(m_commandLocator);
|
||||
|
||||
//register actions
|
||||
Core::ActionManager *ami = core->actionManager();
|
||||
Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS);
|
||||
@@ -261,6 +267,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+D")));
|
||||
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_filelogCurrentAction,
|
||||
@@ -269,6 +276,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
|
||||
SLOT(filelogCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_annotateCurrentAction,
|
||||
@@ -277,6 +285,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
|
||||
SLOT(annotateCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext));
|
||||
|
||||
@@ -287,6 +296,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+A")));
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_commitCurrentAction = new Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_commitCurrentAction,
|
||||
@@ -295,6 +305,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+C")));
|
||||
connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
||||
@@ -302,6 +313,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
||||
@@ -309,6 +321,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext));
|
||||
|
||||
@@ -318,6 +331,7 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_statusProjectAction = new Utils::ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_statusProjectAction, CMD_ID_STATUS,
|
||||
@@ -325,18 +339,21 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_logProjectAction = new Utils::ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_updateProjectAction = new Utils::ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext));
|
||||
|
||||
@@ -344,18 +361,21 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
||||
command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
|
||||
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_commitAllAction = new QAction(tr("Commit All Files"), this);
|
||||
command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL,
|
||||
globalcontext);
|
||||
connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this);
|
||||
command = ami->registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL,
|
||||
globalcontext);
|
||||
connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll()));
|
||||
cvsMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
// Actions of the submit editor
|
||||
QList<int> cvscommitcontext;
|
||||
@@ -498,10 +518,14 @@ CVSSubmitEditor *CVSPlugin::openCVSSubmitEditor(const QString &fileName)
|
||||
|
||||
void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
{
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
if (!enableMenuAction(as, m_menuAction)) {
|
||||
m_commandLocator->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
|
||||
const bool hasTopLevel = currentState().hasTopLevel();
|
||||
m_commandLocator->setEnabled(hasTopLevel);
|
||||
m_logRepositoryAction->setEnabled(hasTopLevel);
|
||||
|
||||
const QString currentFileName = currentState().currentFileName();
|
||||
m_addAction->setParameter(currentFileName);
|
||||
@@ -518,7 +542,7 @@ void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
m_updateProjectAction->setParameter(currentProjectName);
|
||||
m_logProjectAction->setParameter(currentProjectName);
|
||||
|
||||
m_commitAllAction->setEnabled(currentState().hasTopLevel());
|
||||
m_commitAllAction->setEnabled(hasTopLevel);
|
||||
}
|
||||
|
||||
void CVSPlugin::addCurrentFile()
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace VCSBase {
|
||||
class VCSBaseSubmitEditor;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
class CommandLocator;
|
||||
}
|
||||
|
||||
namespace CVS {
|
||||
namespace Internal {
|
||||
|
||||
@@ -151,6 +155,7 @@ private:
|
||||
QString m_commitMessageFileName;
|
||||
QString m_commitRepository;
|
||||
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
Utils::ParameterAction *m_addAction;
|
||||
Utils::ParameterAction *m_deleteAction;
|
||||
Utils::ParameterAction *m_revertAction;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
#include <locator/commandlocator.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
@@ -113,6 +114,7 @@ GitPlugin *GitPlugin::m_instance = 0;
|
||||
GitPlugin::GitPlugin() :
|
||||
VCSBase::VCSBasePlugin(QLatin1String(Git::Constants::GITSUBMITEDITOR_ID)),
|
||||
m_core(0),
|
||||
m_commandLocator(0),
|
||||
m_diffAction(0),
|
||||
m_diffProjectAction(0),
|
||||
m_diffRepositoryAction(0),
|
||||
@@ -217,6 +219,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
addAutoReleasedObject(new CloneWizard);
|
||||
addAutoReleasedObject(new Gitorious::Internal::GitoriousCloneWizard);
|
||||
|
||||
const QString description = QLatin1String("Git");
|
||||
const QString prefix = QLatin1String("git");
|
||||
m_commandLocator = new Locator::CommandLocator(description, prefix, prefix);
|
||||
addAutoReleasedObject(m_commandLocator);
|
||||
|
||||
//register actions
|
||||
Core::ActionManager *actionManager = m_core->actionManager();
|
||||
|
||||
@@ -224,7 +231,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
actionManager->actionContainer(Core::Constants::M_TOOLS);
|
||||
|
||||
Core::ActionContainer *gitContainer =
|
||||
actionManager->createMenu(QLatin1String("Git"));
|
||||
actionManager->createMenu(description);
|
||||
gitContainer->menu()->setTitle(tr("&Git"));
|
||||
toolsContainer->addMenu(gitContainer);
|
||||
m_menuAction = gitContainer->menu()->menuAction();
|
||||
@@ -236,6 +243,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+D")));
|
||||
connect(m_diffAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_logAction = new Utils::ParameterAction(tr("Log File"), tr("Log of \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
command = actionManager->registerAction(m_logAction, "Git.Log", globalcontext);
|
||||
@@ -243,6 +251,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_logAction, SIGNAL(triggered()), this, SLOT(logFile()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_blameAction = new Utils::ParameterAction(tr("Blame"), tr("Blame for \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
command = actionManager->registerAction(m_blameAction, "Git.Blame", globalcontext);
|
||||
@@ -250,6 +259,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_blameAction, SIGNAL(triggered()), this, SLOT(blameFile()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_undoFileAction = new Utils::ParameterAction(tr("Undo Changes"), tr("Undo Changes for \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
command = actionManager->registerAction(m_undoFileAction, "Git.Undo", globalcontext);
|
||||
@@ -257,6 +267,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_undoFileAction, SIGNAL(triggered()), this, SLOT(undoFileChanges()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_stageAction = new Utils::ParameterAction(tr("Stage File for Commit"), tr("Stage \"%1\" for Commit"), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
command = actionManager->registerAction(m_stageAction, "Git.Stage", globalcontext);
|
||||
@@ -264,12 +275,14 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_stageAction, SIGNAL(triggered()), this, SLOT(stageFile()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_unstageAction = new Utils::ParameterAction(tr("Unstage File from Commit"), tr("Unstage \"%1\" from Commit"), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
command = actionManager->registerAction(m_unstageAction, "Git.Unstage", globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Project"), this));
|
||||
|
||||
@@ -279,6 +292,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(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);
|
||||
@@ -286,6 +300,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Repository"), this));
|
||||
|
||||
@@ -293,16 +308,19 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command = actionManager->registerAction(m_diffRepositoryAction, "Git.DiffRepository", globalcontext);
|
||||
connect(m_diffRepositoryAction, SIGNAL(triggered()), this, SLOT(diffRepository()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(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_commandLocator->appendCommand(command);
|
||||
|
||||
m_logRepositoryAction = new QAction(tr("Log Repository"), this);
|
||||
command = actionManager->registerAction(m_logRepositoryAction, "Git.LogRepository", globalcontext);
|
||||
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_undoRepositoryAction = new QAction(tr("Undo Repository Changes"), this);
|
||||
command = actionManager->registerAction(m_undoRepositoryAction, "Git.UndoRepository", globalcontext);
|
||||
@@ -321,34 +339,40 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command = actionManager->registerAction(m_stashSnapshotAction, "Git.StashSnapshot", globalcontext);
|
||||
connect(m_stashSnapshotAction, SIGNAL(triggered()), this, SLOT(stashSnapshot()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_stashAction = new QAction(tr("Stash"), this);
|
||||
m_stashAction->setToolTip(tr("Saves the current state of your work and resets the repository."));
|
||||
command = actionManager->registerAction(m_stashAction, "Git.Stash", globalcontext);
|
||||
connect(m_stashAction, SIGNAL(triggered()), this, SLOT(stash()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_pullAction = new QAction(tr("Pull"), this);
|
||||
command = actionManager->registerAction(m_pullAction, "Git.Pull", globalcontext);
|
||||
connect(m_pullAction, SIGNAL(triggered()), this, SLOT(pull()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_stashPopAction = new QAction(tr("Stash Pop"), this);
|
||||
m_stashAction->setToolTip(tr("Restores changes saved to the stash list using \"Stash\"."));
|
||||
command = actionManager->registerAction(m_stashPopAction, "Git.StashPop", globalcontext);
|
||||
connect(m_stashPopAction, SIGNAL(triggered()), this, SLOT(stashPop()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_commitAction = new QAction(tr("Commit..."), this);
|
||||
command = actionManager->registerAction(m_commitAction, "Git.Commit", globalcontext);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+C")));
|
||||
connect(m_commitAction, SIGNAL(triggered()), this, SLOT(startCommit()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_pushAction = new QAction(tr("Push"), this);
|
||||
command = actionManager->registerAction(m_pushAction, "Git.Push", globalcontext);
|
||||
connect(m_pushAction, SIGNAL(triggered()), this, SLOT(push()));
|
||||
gitContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Branch"), this));
|
||||
|
||||
@@ -711,11 +735,13 @@ void GitPlugin::stashList()
|
||||
|
||||
void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
{
|
||||
const bool repositoryEnabled = currentState().hasTopLevel();
|
||||
if (m_stashDialog)
|
||||
m_stashDialog->refresh(currentState().topLevel(), false);
|
||||
if (m_branchDialog)
|
||||
m_branchDialog->refresh(currentState().topLevel(), false);
|
||||
|
||||
m_commandLocator->setEnabled(repositoryEnabled);
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
return;
|
||||
// Note: This menu is visible if there is no repository. Only
|
||||
@@ -743,7 +769,6 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
m_logProjectAction->setEnabled(projectEnabled);
|
||||
m_logProjectAction->setParameter(projectName);
|
||||
|
||||
const bool repositoryEnabled = currentState().hasTopLevel();
|
||||
m_diffRepositoryAction->setEnabled(repositoryEnabled);
|
||||
m_statusRepositoryAction->setEnabled(repositoryEnabled);
|
||||
m_branchListAction->setEnabled(repositoryEnabled);
|
||||
|
||||
@@ -54,7 +54,9 @@ class ICore;
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
class CommandLocator;
|
||||
}
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
@@ -125,6 +127,7 @@ private:
|
||||
|
||||
static GitPlugin *m_instance;
|
||||
Core::ICore *m_core;
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
Utils::ParameterAction *m_diffAction;
|
||||
Utils::ParameterAction *m_diffProjectAction;
|
||||
QAction *m_diffRepositoryAction;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "commandlocator.h"
|
||||
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
|
||||
namespace Locator {
|
||||
|
||||
struct CommandLocatorPrivate {
|
||||
CommandLocatorPrivate(const QString &prefix,
|
||||
const QString &displayName) :
|
||||
m_prefix(prefix), m_displayName(displayName) {}
|
||||
|
||||
const QString m_prefix;
|
||||
const QString m_displayName;
|
||||
|
||||
QList<Core::Command *> commands;
|
||||
};
|
||||
|
||||
CommandLocator::CommandLocator(const QString &prefix,
|
||||
const QString &displayName,
|
||||
const QString &shortCutString,
|
||||
QObject *parent) :
|
||||
Locator::ILocatorFilter(parent),
|
||||
d(new CommandLocatorPrivate(prefix, displayName))
|
||||
{
|
||||
setShortcutString(shortCutString);
|
||||
}
|
||||
|
||||
CommandLocator::~CommandLocator()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void CommandLocator::appendCommand(Core::Command *cmd)
|
||||
{
|
||||
d->commands.push_back(cmd);
|
||||
}
|
||||
|
||||
QString CommandLocator::displayName() const
|
||||
{
|
||||
return d->m_displayName;
|
||||
}
|
||||
|
||||
QString CommandLocator::id() const
|
||||
{
|
||||
return d->m_prefix;
|
||||
}
|
||||
|
||||
ILocatorFilter::Priority CommandLocator::priority() const
|
||||
{
|
||||
return Medium;
|
||||
}
|
||||
|
||||
QList<Locator::FilterEntry> CommandLocator::matchesFor(const QString &entry)
|
||||
{
|
||||
QList<FilterEntry> filters;
|
||||
// Get active, enabled actions matching text, store in list.
|
||||
// Reference via index in extraInfo.
|
||||
const QChar ampersand = QLatin1Char('&');
|
||||
const int count = d->commands.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (d->commands.at(i)->isActive()) {
|
||||
if (QAction *action = d->commands.at(i)->action())
|
||||
if (action->isEnabled()) {
|
||||
QString text = action->text();
|
||||
text.remove(ampersand);
|
||||
if (text.contains(entry, Qt::CaseInsensitive)) {
|
||||
filters.append(FilterEntry(this, text, QVariant(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
void CommandLocator::accept(Locator::FilterEntry entry) const
|
||||
{
|
||||
// Retrieve action via index.
|
||||
const int index = entry.internalData.toInt();
|
||||
QTC_ASSERT(index >= 0 && index < d->commands.size(), return)
|
||||
QAction *action = d->commands.at(index)->action();
|
||||
QTC_ASSERT(action->isEnabled(), return)
|
||||
action->trigger();
|
||||
}
|
||||
|
||||
void CommandLocator::setEnabled(bool e)
|
||||
{
|
||||
setHidden(!e);
|
||||
}
|
||||
|
||||
void CommandLocator::refresh(QFutureInterface<void> &)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace Locator
|
||||
@@ -0,0 +1,86 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef COMMANDLOCATOR_H
|
||||
#define COMMANDLOCATOR_H
|
||||
|
||||
#include "locator_global.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class Command;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
/* Command locators: Provides completion for a set of
|
||||
* Core::Command's by sub-string of their action's text. */
|
||||
|
||||
struct CommandLocatorPrivate;
|
||||
|
||||
class LOCATOR_EXPORT CommandLocator : public Locator::ILocatorFilter
|
||||
{
|
||||
Q_DISABLE_COPY(CommandLocator)
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CommandLocator(const QString &prefix,
|
||||
const QString &displayName,
|
||||
const QString &shortCutString,
|
||||
QObject *parent = 0);
|
||||
virtual ~CommandLocator();
|
||||
|
||||
void appendCommand(Core::Command *cmd);
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString id() const;
|
||||
virtual Priority priority() const;
|
||||
virtual QList<FilterEntry> matchesFor(const QString &entry);
|
||||
virtual void accept(FilterEntry selection) const;
|
||||
virtual void refresh(QFutureInterface<void> &future);
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool e);
|
||||
|
||||
private:
|
||||
CommandLocatorPrivate *d;
|
||||
};
|
||||
|
||||
inline CommandLocator &operator<<(CommandLocator &locator, Core::Command *cmd)
|
||||
{
|
||||
locator.appendCommand(cmd);
|
||||
return locator;
|
||||
}
|
||||
|
||||
} // namespace Locator
|
||||
|
||||
#endif // COMMANDLOCATOR_H
|
||||
@@ -4,6 +4,7 @@ DEFINES += LOCATOR_LIBRARY
|
||||
include(../../qtcreatorplugin.pri)
|
||||
include(locator_dependencies.pri)
|
||||
HEADERS += locatorplugin.h \
|
||||
commandlocator.h \
|
||||
locatorwidget.h \
|
||||
locatorfiltersfilter.h \
|
||||
settingspage.h \
|
||||
@@ -16,6 +17,7 @@ HEADERS += locatorplugin.h \
|
||||
basefilefilter.h \
|
||||
locator_global.h
|
||||
SOURCES += locatorplugin.cpp \
|
||||
commandlocator.cpp \
|
||||
locatorwidget.cpp \
|
||||
locatorfiltersfilter.cpp \
|
||||
opendocumentsfilter.cpp \
|
||||
@@ -25,6 +27,7 @@ SOURCES += locatorplugin.cpp \
|
||||
locatormanager.cpp \
|
||||
basefilefilter.cpp \
|
||||
ilocatorfilter.cpp
|
||||
|
||||
FORMS += settingspage.ui \
|
||||
filesystemfilter.ui \
|
||||
directoryfilter.ui
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <locator/commandlocator.h>
|
||||
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -124,6 +126,8 @@ MercurialPlugin::MercurialPlugin() :
|
||||
VCSBase::VCSBasePlugin(QLatin1String(Constants::COMMIT_ID)),
|
||||
optionsPage(0),
|
||||
m_client(0),
|
||||
core(0),
|
||||
m_commandLocator(0),
|
||||
changeLog(0),
|
||||
m_addAction(0),
|
||||
m_deleteAction(0),
|
||||
@@ -172,6 +176,10 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
|
||||
|
||||
addAutoReleasedObject(new CloneWizard);
|
||||
|
||||
const QString prefix = QLatin1String("hg");
|
||||
m_commandLocator = new Locator::CommandLocator(QLatin1String("Mercurial"), prefix, prefix);
|
||||
addAutoReleasedObject(m_commandLocator);
|
||||
|
||||
createMenu();
|
||||
|
||||
createSubmitEditorActions();
|
||||
@@ -234,6 +242,7 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = actionManager->registerAction(diffFile, QLatin1String(Constants::DIFF), context);
|
||||
@@ -241,6 +250,7 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+D")));
|
||||
connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = actionManager->registerAction(logFile, QLatin1String(Constants::LOG), context);
|
||||
@@ -248,6 +258,7 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+L")));
|
||||
connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = actionManager->registerAction(statusFile, QLatin1String(Constants::STATUS), context);
|
||||
@@ -255,6 +266,7 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+S")));
|
||||
connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
createSeparator(context, QLatin1String("FileDirSeperator1"));
|
||||
|
||||
@@ -263,18 +275,21 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = actionManager->registerAction(m_deleteAction, QLatin1String(Constants::DELETE), context);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
revertFile = new Utils::ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = actionManager->registerAction(revertFile, QLatin1String(Constants::REVERT), context);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
}
|
||||
|
||||
void MercurialPlugin::addCurrentFile()
|
||||
@@ -333,26 +348,31 @@ void MercurialPlugin::createDirectoryActions(const QList<int> &context)
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::DIFFMULTI), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(diffRepository()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Log"), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::LOGMULTI), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(logRepository()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Revert..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::REVERTMULTI), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(revertMulti()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Status"), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::STATUSMULTI), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(statusMulti()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
}
|
||||
|
||||
|
||||
void MercurialPlugin::diffRepository()
|
||||
{
|
||||
const VCSBase::VCSBasePluginState state = currentState();
|
||||
@@ -393,36 +413,42 @@ void MercurialPlugin::createRepositoryActions(const QList<int> &context)
|
||||
Core::Command *command = actionManager->registerAction(action, QLatin1String(Constants::PULL), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(pull()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Push..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::PUSH), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(push()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Update..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::UPDATE), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(update()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Import..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::IMPORT), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(import()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Incoming..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::INCOMING), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(incoming()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Outgoing..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
command = actionManager->registerAction(action, QLatin1String(Constants::OUTGOING), context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(outgoing()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
action = new QAction(tr("Commit..."), this);
|
||||
m_repositoryActionList.append(action);
|
||||
@@ -430,6 +456,7 @@ void MercurialPlugin::createRepositoryActions(const QList<int> &context)
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+C")));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(commit()));
|
||||
mercurialContainer->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
||||
command = actionManager->registerAction(m_createRepositoryAction, QLatin1String(Constants::CREATE_REPOSITORY), context);
|
||||
|
||||
@@ -60,6 +60,10 @@ namespace VCSBase {
|
||||
class VCSBaseSubmitEditor;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
class CommandLocator;
|
||||
}
|
||||
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
@@ -150,6 +154,7 @@ private:
|
||||
MercurialClient *m_client;
|
||||
|
||||
Core::ICore *core;
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
Core::ActionManager *actionManager;
|
||||
Core::ActionContainer *mercurialContainer;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <locator/commandlocator.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
@@ -176,6 +177,7 @@ PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
|
||||
|
||||
PerforcePlugin::PerforcePlugin() :
|
||||
VCSBase::VCSBasePlugin(QLatin1String(Constants::PERFORCE_SUBMIT_EDITOR_ID)),
|
||||
m_commandLocator(0),
|
||||
m_editAction(0),
|
||||
m_addAction(0),
|
||||
m_deleteAction(0),
|
||||
@@ -247,6 +249,10 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
for (int i = 0; i < editorCount; i++)
|
||||
addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot));
|
||||
|
||||
const QString prefix = QLatin1String("p4");
|
||||
m_commandLocator = new Locator::CommandLocator(QLatin1String("Perforce"), prefix, prefix);
|
||||
addAutoReleasedObject(m_commandLocator);
|
||||
|
||||
//register actions
|
||||
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
||||
|
||||
@@ -274,6 +280,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Diff Current File"));
|
||||
connect(m_diffFileAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_annotateCurrentAction, CMD_ID_ANNOTATE_CURRENT, globalcontext);
|
||||
@@ -281,6 +288,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Annotate Current File"));
|
||||
connect(m_annotateCurrentAction, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_filelogCurrentAction, CMD_ID_FILELOG_CURRENT, globalcontext);
|
||||
@@ -289,6 +297,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Filelog Current File"));
|
||||
connect(m_filelogCurrentAction, SIGNAL(triggered()), this, SLOT(filelogCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Edit", globalcontext));
|
||||
|
||||
@@ -299,6 +308,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Edit File"));
|
||||
connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_addAction, CMD_ID_ADD, globalcontext);
|
||||
@@ -307,6 +317,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Add File"));
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, globalcontext);
|
||||
@@ -314,6 +325,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Delete File"));
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertFileAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_revertFileAction, CMD_ID_REVERT, globalcontext);
|
||||
@@ -322,6 +334,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(tr("Revert File"));
|
||||
connect(m_revertFileAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Project", globalcontext));
|
||||
|
||||
@@ -333,12 +346,14 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultText(diffProjectDefaultText);
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_logProjectAction = new Utils::ParameterAction(tr("Log Project Log"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_submitProjectAction = new Utils::ParameterAction(tr("Submit Project"), tr("Submit Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_submitProjectAction, CMD_ID_SUBMIT, globalcontext);
|
||||
@@ -346,6 +361,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+S")));
|
||||
connect(m_submitProjectAction, SIGNAL(triggered()), this, SLOT(startSubmitProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
const QString updateProjectDefaultText = tr("Update Current Project");
|
||||
m_updateProjectAction = new Utils::ParameterAction(updateProjectDefaultText, tr("Update Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
||||
@@ -354,18 +370,21 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateCurrentProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertUnchangedAction = new Utils::ParameterAction(tr("Revert Unchanged"), tr("Revert Unchanged Files of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_revertUnchangedAction, CMD_ID_REVERT_UNCHANGED_PROJECT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_revertUnchangedAction, SIGNAL(triggered()), this, SLOT(revertUnchangedCurrentProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertProjectAction = new Utils::ParameterAction(tr("Revert Project"), tr("Revert Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = am->registerAction(m_revertProjectAction, CMD_ID_REVERT_PROJECT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_revertProjectAction, SIGNAL(triggered()), this, SLOT(revertCurrentProject()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Repository", globalcontext));
|
||||
|
||||
@@ -373,27 +392,32 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
||||
command = am->registerAction(m_diffAllAction, CMD_ID_DIFF_ALL, globalcontext);
|
||||
connect(m_diffAllAction, SIGNAL(triggered()), this, SLOT(diffAllOpened()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_openedAction = new QAction(tr("Opened"), this);
|
||||
command = am->registerAction(m_openedAction, CMD_ID_OPENED, globalcontext);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+O")));
|
||||
connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_logRepositoryAction = new QAction(tr("Repository Log"), this);
|
||||
command = am->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
|
||||
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_pendingAction = new QAction(tr("Pending Changes..."), this);
|
||||
command = am->registerAction(m_pendingAction, CMD_ID_PENDING_CHANGES, globalcontext);
|
||||
connect(m_pendingAction, SIGNAL(triggered()), this, SLOT(printPendingChanges()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_updateAllAction = new QAction(tr("Update All"), this);
|
||||
command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext);
|
||||
connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll()));
|
||||
mperforce->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Dialogs", globalcontext));
|
||||
|
||||
@@ -788,10 +812,13 @@ void PerforcePlugin::filelog(const QString &workingDir, const QStringList &fileN
|
||||
|
||||
void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
{
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
if (!enableMenuAction(as, m_menuAction)) {
|
||||
m_commandLocator->setEnabled(false);
|
||||
return;
|
||||
|
||||
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
|
||||
}
|
||||
const bool hasTopLevel = currentState().hasTopLevel();
|
||||
m_commandLocator->setEnabled(hasTopLevel);
|
||||
m_logRepositoryAction->setEnabled(hasTopLevel);
|
||||
|
||||
const QString fileName = currentState().currentFileName();
|
||||
m_editAction->setParameter(fileName);
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
class CommandLocator;
|
||||
}
|
||||
|
||||
namespace Perforce {
|
||||
namespace Internal {
|
||||
|
||||
@@ -192,6 +196,7 @@ private:
|
||||
|
||||
inline PerforceVersionControl *perforceVersionControl() const;
|
||||
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
Utils::ParameterAction *m_editAction;
|
||||
Utils::ParameterAction *m_addAction;
|
||||
Utils::ParameterAction *m_deleteAction;
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <locator/commandlocator.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
@@ -182,6 +185,7 @@ SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;
|
||||
SubversionPlugin::SubversionPlugin() :
|
||||
VCSBase::VCSBasePlugin(QLatin1String(Subversion::Constants::SUBVERSIONCOMMITEDITOR_ID)),
|
||||
m_svnDirectories(svnDirectories()),
|
||||
m_commandLocator(0),
|
||||
m_addAction(0),
|
||||
m_deleteAction(0),
|
||||
m_revertAction(0),
|
||||
@@ -273,6 +277,11 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
|
||||
addAutoReleasedObject(new CheckoutWizard);
|
||||
|
||||
const QString description = QLatin1String("Subversion");
|
||||
const QString prefix = QLatin1String("svn");
|
||||
m_commandLocator = new Locator::CommandLocator(description, prefix, prefix);
|
||||
addAutoReleasedObject(m_commandLocator);
|
||||
|
||||
//register actions
|
||||
Core::ActionManager *ami = core->actionManager();
|
||||
Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS);
|
||||
@@ -294,6 +303,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+D")));
|
||||
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_filelogCurrentAction,
|
||||
@@ -302,6 +312,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
|
||||
SLOT(filelogCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_annotateCurrentAction,
|
||||
@@ -310,6 +321,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
|
||||
SLOT(annotateCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext));
|
||||
|
||||
@@ -320,6 +332,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+A")));
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_commitCurrentAction = new Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_commitCurrentAction,
|
||||
@@ -328,6 +341,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+C")));
|
||||
connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
||||
@@ -335,6 +349,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
||||
@@ -342,6 +357,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext));
|
||||
|
||||
@@ -351,6 +367,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_statusProjectAction = new Utils::ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_statusProjectAction, CMD_ID_STATUS,
|
||||
@@ -358,18 +375,21 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_logProjectAction = new Utils::ParameterAction(tr("Log Project Log"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_updateProjectAction = new Utils::ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
|
||||
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext));
|
||||
|
||||
@@ -377,6 +397,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
|
||||
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_describeAction = new QAction(tr("Describe..."), this);
|
||||
command = ami->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext);
|
||||
@@ -388,12 +409,14 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
globalcontext);
|
||||
connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this);
|
||||
command = ami->registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL,
|
||||
globalcontext);
|
||||
connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll()));
|
||||
subversionMenu->addAction(command);
|
||||
m_commandLocator->appendCommand(command);
|
||||
|
||||
// Actions of the submit editor
|
||||
QList<int> svncommitcontext;
|
||||
@@ -528,10 +551,13 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
|
||||
|
||||
void SubversionPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
{
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
if (!enableMenuAction(as, m_menuAction)) {
|
||||
m_commandLocator->setEnabled(false);
|
||||
return;
|
||||
|
||||
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
|
||||
}
|
||||
const bool hasTopLevel = currentState().hasTopLevel();
|
||||
m_commandLocator->setEnabled(hasTopLevel);
|
||||
m_logRepositoryAction->setEnabled(hasTopLevel);
|
||||
|
||||
const QString projectName = currentState().currentProjectName();
|
||||
m_diffProjectAction->setParameter(projectName);
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace VCSBase {
|
||||
class VCSBaseSubmitEditor;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
class CommandLocator;
|
||||
}
|
||||
|
||||
namespace Subversion {
|
||||
namespace Internal {
|
||||
|
||||
@@ -146,6 +150,7 @@ private:
|
||||
QString m_commitMessageFileName;
|
||||
QString m_commitRepository;
|
||||
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
Utils::ParameterAction *m_addAction;
|
||||
Utils::ParameterAction *m_deleteAction;
|
||||
Utils::ParameterAction *m_revertAction;
|
||||
|
||||
Reference in New Issue
Block a user