Commit b03ab1d7 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

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: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 354fd8d8
......@@ -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;
......
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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