Commit f56dacc7 authored by hjk's avatar hjk

Core::Context: remove special handling of C_GLOBAL_ID/C_GLOBAL

parent 060385b4
......@@ -69,7 +69,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
Core::Context textcontext(TextEditor::Constants::C_TEXTEDITOR);
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionContainer *mtools =
am->actionContainer(Core::Constants::M_TOOLS);
......
......@@ -97,7 +97,7 @@ namespace {
QAction *myAction = new QAction(tr("My Action"), this);
Core::Command *cmd = am->registerAction(myAction,
"myplugin.myaction",
QList<int>() << C_GLOBAL_ID);
Core::Context(C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+u")));
connect(myAction, SIGNAL(triggered()), this, SLOT(performMyAction()));
\endcode
......
......@@ -93,7 +93,6 @@ const char * const M_HELP = "QtCreator.Menu.Help";
//contexts
const char * const C_GLOBAL = "Global Context";
const int C_GLOBAL_ID = 0;
const char * const C_WELCOME_MODE = "Core.WelcomeMode";
const char * const C_EDIT_MODE = "Core.EditMode";
const char * const C_DESIGN_MODE = "Core.DesignMode";
......
......@@ -386,6 +386,8 @@ void ShortcutSettings::markPossibleCollisions(ShortcutItem *item)
if (item->m_key.isEmpty())
return;
int globalId = Context(Constants::C_GLOBAL).at(0);
foreach (ShortcutItem *currentItem, m_scitems) {
if (currentItem->m_key.isEmpty() || item == currentItem ||
......@@ -398,9 +400,9 @@ void ShortcutSettings::markPossibleCollisions(ShortcutItem *item)
// conflict if context is identical, OR if one
// of the contexts is the global context
if (item->m_cmd->context().contains(context) ||
(item->m_cmd->context().contains(Constants::C_GLOBAL_ID) &&
(item->m_cmd->context().contains(globalId) &&
!currentItem->m_cmd->context().isEmpty()) ||
(currentItem->m_cmd->context().contains(Constants::C_GLOBAL_ID) &&
(currentItem->m_cmd->context().contains(globalId) &&
!item->m_cmd->context().isEmpty())) {
currentItem->m_item->setForeground(2, Qt::red);
item->m_item->setForeground(2, Qt::red);
......
......@@ -46,7 +46,6 @@ class CORE_EXPORT Context
public:
Context() {}
explicit Context(int c1) { d.append(c1); } // For C_GLOBAL_ID. FIXME: Sanitize.
explicit Context(const char *c1) { add(c1); }
Context(const char *c1, const char *c2) { add(c1); add(c2); }
Context(const char *c1, const char *c2, const char *c3) { add(c1); add(c2); add(c3); }
......
This diff is collapsed.
......@@ -179,7 +179,6 @@ private:
CoreImpl *m_coreImpl;
UniqueIDManager *m_uniqueIDManager;
Context m_globalContext;
Context m_additionalContexts;
QSettings *m_settings;
QSettings *m_globalSettings;
......
......@@ -179,7 +179,7 @@ void ModeManager::objectAdded(QObject *obj)
const QString shortcutId = QLatin1String("QtCreator.Mode.") + mode->id();
QShortcut *shortcut = new QShortcut(d->m_mainWindow);
shortcut->setWhatsThis(tr("Switch to <b>%1</b> mode").arg(mode->displayName()));
Command *cmd = am->registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL_ID));
Command *cmd = am->registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));
d->m_modeShortcuts.insert(index, cmd);
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));
......
......@@ -282,7 +282,7 @@ void OutputPaneManager::init()
{
ActionManager *am = Core::ICore::instance()->actionManager();
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
Context globalcontext = Context(Core::Constants::C_GLOBAL_ID);
const Context globalcontext(Core::Constants::C_GLOBAL);
// Window->Output Panes
ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES);
......@@ -356,7 +356,7 @@ void OutputPaneManager::init()
actionId.remove(QLatin1Char(' '));
QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = am->registerAction(action, actionId, Context(Constants::C_GLOBAL_ID));
Command *cmd = am->registerAction(action, actionId, Context(Constants::C_GLOBAL));
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
m_actions.insert(cmd->action(), idx);
......
......@@ -37,7 +37,6 @@ UniqueIDManager *UniqueIDManager::m_instance = 0;
UniqueIDManager::UniqueIDManager()
{
m_instance = this;
m_uniqueIdentifiers.insert(Constants::C_GLOBAL, Constants::C_GLOBAL_ID);
}
UniqueIDManager::~UniqueIDManager()
......
......@@ -272,7 +272,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cppToolsMenu->addAction(cmd);
// Update context in global context
Core::Context globalContext(Core::Constants::C_GLOBAL_ID);
Core::Context globalContext(Core::Constants::C_GLOBAL);
cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR2));
m_updateCodeModelAction = new QAction(tr("Update Code Model"), this);
cmd = am->registerAction(m_updateCodeModelAction, QLatin1String(Constants::UPDATE_CODEMODEL), globalContext);
......
......@@ -982,7 +982,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
Core::ActionManager *am = core->actionManager();
QTC_ASSERT(am, return false);
const Core::Context globalcontext(CC::C_GLOBAL_ID);
const Core::Context globalcontext(CC::C_GLOBAL);
const Core::Context cppDebuggercontext(C_CPPDEBUGGER);
const Core::Context cppeditorcontext(CppEditor::Constants::C_CPPEDITOR);
......
......@@ -85,9 +85,6 @@ struct DebuggerUISwitcherPrivate
QStackedWidget *m_toolbarStack;
Internal::DebuggerMainWindow *m_mainWindow;
// global context
Core::Context m_globalContext;
QHash<int, Core::Context> m_contextsForLanguage;
QActionGroup *m_languageActionGroup;
......@@ -139,8 +136,6 @@ DebuggerUISwitcher::DebuggerUISwitcher(Core::BaseMode *mode, QObject* parent) :
d->m_languageActionGroup->setExclusive(true);
d->m_globalContext.add(Core::Constants::C_GLOBAL_ID);
DebuggerUISwitcherPrivate::m_instance = this;
}
......@@ -212,7 +207,7 @@ void DebuggerUISwitcher::createViewsMenuItems()
{
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
QMenu *mLang = d->m_languageMenu->menu();
mLang->setTitle(tr("&Languages"));
......@@ -248,10 +243,12 @@ void DebuggerUISwitcher::addLanguage(const QString &langName, const Core::Contex
d->m_languageActionGroup->addAction(langChange);
QString prefix = tr("Alt+L");
connect(langChange, SIGNAL(triggered()), SLOT(langChangeTriggered()));
Core::Command *cmd = am->registerAction(langChange,
"Debugger.Language." + langName, d->m_globalContext);
"Debugger.Language." + langName,
Core::Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(
QString("%1,%2").arg(prefix).arg(d->m_languages.count())));
......
......@@ -587,7 +587,7 @@ bool FakeVimPluginPrivate::initialize()
Core::ActionManager *actionManager = Core::ICore::instance()->actionManager();
QTC_ASSERT(actionManager, return false);
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
m_fakeVimOptionsPage = new FakeVimOptionPage;
q->addObject(m_fakeVimOptionsPage);
......
......@@ -192,7 +192,7 @@ void FindPlugin::setupMenu()
mfind->appendGroup(Constants::G_FIND_FILTERS);
mfind->appendGroup(Constants::G_FIND_FLAGS);
mfind->appendGroup(Constants::G_FIND_ACTIONS);
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Command *cmd;
QAction *separator;
separator = new QAction(this);
......@@ -220,7 +220,7 @@ void FindPlugin::setupFilterMenuItems()
QList<IFindFilter*> findInterfaces =
ExtensionSystem::PluginManager::instance()->getObjects<IFindFilter>();
Core::Command *cmd;
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionContainer *mfindadvanced = am->actionContainer(Constants::M_FIND_ADVANCED);
d->m_filterActions.clear();
......
......@@ -131,7 +131,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
QMetaTypeId<QStringList>::qt_metatype_id();
// register actions
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND);
Core::Command *cmd;
......
......@@ -119,7 +119,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
Q_UNUSED(arguments)
Q_UNUSED(error)
m_core = Core::ICore::instance();
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Context modecontext(Constants::C_MODE_HELP);
const QString &locale = qApp->property("qtc_locale").toString();
......
......@@ -111,7 +111,7 @@ bool LocatorPlugin::initialize(const QStringList &, QString *)
const QString actionId = QLatin1String("QtCreator.Locate");
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Core::Command *cmd = core->actionManager()->registerAction(action, actionId, Core::Context(Core::Constants::C_GLOBAL_ID));
Core::Command *cmd = core->actionManager()->registerAction(action, actionId, Core::Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence("Ctrl+K"));
connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
......
......@@ -266,7 +266,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
mtools->addMenu(mperforce);
m_menuAction = mperforce->menu()->menuAction();
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Context perforcesubmitcontext(Constants::PERFORCESUBMITEDITOR_CONTEXT);
Core::Command *command;
......
......@@ -82,7 +82,7 @@ OutputPane::OutputPane()
// Stop
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
m_stopAction = new QAction(QIcon(Constants::ICON_STOP), tr("Stop"), this);
m_stopAction->setToolTip(tr("Stop"));
......
......@@ -263,7 +263,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_proWindow = new ProjectWindow;
Core::Context globalcontext(Core::Constants::C_GLOBAL_ID);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Context pecontext(Constants::C_PROJECTEXPLORER);
d->m_projectsMode = new Core::BaseMode;
......
......@@ -85,7 +85,7 @@ QemuRuntimeManager::QemuRuntimeManager(QObject *parent)
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *actionManager = core->actionManager();
Core::Command *qemuCommand = actionManager->registerAction(m_qemuAction,
"MaemoEmulator", Core::Context(Core::Constants::C_GLOBAL_ID));
"MaemoEmulator", Core::Context(Core::Constants::C_GLOBAL));
qemuCommand->setAttribute(Core::Command::CA_UpdateText);
qemuCommand->setAttribute(Core::Command::CA_UpdateIcon);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment