diff options
author | hjk <qtc-committer@nokia.com> | 2012-05-07 18:28:03 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2012-05-08 10:18:12 +0200 |
commit | cad296649809da562d91f0296b04bd2c6c3269ab (patch) | |
tree | 0652ce148b95fac58d05153d15323322e80704a7 | |
parent | 2d612a252bb3b9ac2724966fe95d6f64054fd993 (diff) | |
download | qt-creator-cad296649809da562d91f0296b04bd2c6c3269ab.tar.gz |
use Core::Id for IMode::id and IMode::type
Change-Id: Ic7ce5b883e054c6eeba078327042e99e1c556345
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
31 files changed, 88 insertions, 83 deletions
diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index b11b17c3ed..29e7533744 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -125,8 +125,8 @@ public: setDisplayName(tr("Analyze")); setIcon(QIcon(QLatin1String(":/images/analyzer_mode.png"))); setPriority(P_MODE_ANALYZE); - setId(QLatin1String(MODE_ANALYZE)); - setType(QLatin1String(MODE_EDIT_TYPE)); + setId(MODE_ANALYZE); + setType(MODE_EDIT_TYPE); } ~AnalyzerMode() diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 7178f52028..e2d347a418 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -92,7 +92,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) if (success) { m_editMode = new EditMode; addObject(m_editMode); - m_mainWindow->modeManager()->activateMode(m_editMode->id()); + ModeManager::activateMode(m_editMode->id()); m_designMode = new DesignMode; } return success; diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp index 47f19d36d5..e5ce5226fb 100644 --- a/src/plugins/coreplugin/designmode.cpp +++ b/src/plugins/coreplugin/designmode.cpp @@ -130,8 +130,8 @@ DesignMode::DesignMode() setDisplayName(tr("Design")); setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Design.png"))); setPriority(Constants::P_MODE_DESIGN); - setId(QLatin1String(Constants::MODE_DESIGN)); - setType(QLatin1String(Constants::MODE_DESIGN_TYPE)); + setId(Constants::MODE_DESIGN); + setType(Constants::MODE_DESIGN_TYPE); ExtensionSystem::PluginManager::instance()->addObject(d->m_coreListener); @@ -237,7 +237,7 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor) if (!mimeEditorAvailable) { setActiveContext(Context()); if (ModeManager::currentMode() == this) - ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + ModeManager::activateMode(Core::Constants::MODE_EDIT); setEnabled(false); d->m_currentEditor = QWeakPointer<Core::IEditor>(); emit actionsUpdated(d->m_currentEditor.data()); diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp index e141b0160b..9461f9aa18 100644 --- a/src/plugins/coreplugin/editmode.cpp +++ b/src/plugins/coreplugin/editmode.cpp @@ -60,8 +60,8 @@ EditMode::EditMode() : setDisplayName(tr("Edit")); setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Edit.png"))); setPriority(Constants::P_MODE_EDIT); - setId(QLatin1String(Constants::MODE_EDIT)); - setType(QLatin1String(Constants::MODE_EDIT_TYPE)); + setId(Constants::MODE_EDIT); + setType(Constants::MODE_EDIT_TYPE); m_rightSplitWidgetLayout->setSpacing(0); m_rightSplitWidgetLayout->setMargin(0); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index ca05d2ef09..7a6dc9b24d 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1374,13 +1374,13 @@ QStringList EditorManager::getOpenFileNames() const /// forcePrefered = false, only switch if it is not visible void EditorManager::switchToPreferedMode() { - QString preferedMode; + Id preferedMode; // Figure out preferred mode for editor if (d->m_currentEditor) preferedMode = d->m_currentEditor->preferredModeType(); - if (preferedMode.isEmpty()) - preferedMode = QLatin1String(Constants::MODE_EDIT_TYPE); + if (!preferedMode.isValid()) + preferedMode = Id(Constants::MODE_EDIT_TYPE); ModeManager::activateModeType(preferedMode); } diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h index 131b6b379c..e663337f20 100644 --- a/src/plugins/coreplugin/editormanager/ieditor.h +++ b/src/plugins/coreplugin/editormanager/ieditor.h @@ -72,7 +72,7 @@ public: virtual QWidget *toolBar() = 0; - virtual QString preferredModeType() const { return QString(); } + virtual Id preferredModeType() const { return Id(); } signals: void changed(); diff --git a/src/plugins/coreplugin/id.h b/src/plugins/coreplugin/id.h index 527ff693ed..cea21131d1 100644 --- a/src/plugins/coreplugin/id.h +++ b/src/plugins/coreplugin/id.h @@ -51,10 +51,10 @@ public: QByteArray name() const; QString toString() const; bool isValid() const { return m_id; } - bool operator==(const Id &id) const { return m_id == id.m_id; } - bool operator!=(const Id &id) const { return m_id != id.m_id; } - bool operator<(const Id &id) const { return m_id < id.m_id; } - bool operator>(const Id &id) const { return m_id > id.m_id; } + bool operator==(Id id) const { return m_id == id.m_id; } + bool operator!=(Id id) const { return m_id != id.m_id; } + bool operator<(Id id) const { return m_id < id.m_id; } + bool operator>(Id id) const { return m_id > id.m_id; } int uniqueIdentifier() const { return m_id; } static Id fromUniqueIdentifier(int uid) { return Id(uid, uid); } diff --git a/src/plugins/coreplugin/imode.h b/src/plugins/coreplugin/imode.h index 40b4871c93..4235c020df 100644 --- a/src/plugins/coreplugin/imode.h +++ b/src/plugins/coreplugin/imode.h @@ -34,6 +34,7 @@ #define IMODE_H #include "icontext.h" +#include "id.h" #include <QIcon> @@ -50,16 +51,16 @@ public: QString displayName() const { return m_displayName; } QIcon icon() const { return m_icon; } int priority() const { return m_priority; } - QString id() const { return m_id; } - QString type() const { return m_type; } + Id id() const { return m_id; } + Id type() const { return m_type; } bool isEnabled() const; void setEnabled(bool enabled); void setDisplayName(const QString &displayName) { m_displayName = displayName; } void setIcon(const QIcon &icon) { m_icon = icon; } void setPriority(int priority) { m_priority = priority; } - void setId(const QString &id) { m_id = id; } - void setType(const QString &type) { m_type = type; } + void setId(Id id) { m_id = id; } + void setType(Id type) { m_type = type; } signals: void enabledStateChanged(bool enabled); @@ -68,8 +69,8 @@ private: QString m_displayName; QIcon m_icon; int m_priority; - QString m_id; - QString m_type; + Id m_id; + Id m_type; bool m_isEnabled; }; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index be9028903a..6e11b3775e 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -912,7 +912,7 @@ void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags f if (!document && (flags & ICore::StopOnLoadFail)) return; if (document && (flags & ICore::SwitchMode)) - ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + ModeManager::activateMode(Id(Core::Constants::MODE_EDIT)); } else { QFlags<EditorManager::OpenEditorFlag> emFlags; if (flags & ICore::SwitchMode) @@ -969,7 +969,7 @@ void MainWindow::setFocusToEditor() } // switch to edit mode if necessary - ModeManager::activateMode(QLatin1String(Constants::MODE_EDIT)); + ModeManager::activateMode(Id(Constants::MODE_EDIT)); } void MainWindow::showNewItemDialog(const QString &title, diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index b8d664f47e..898dc35ec7 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -85,13 +85,13 @@ struct ModeManagerPrivate static ModeManagerPrivate *d; static ModeManager *m_instance = 0; -static int indexOf(const QString &id) +static int indexOf(Id id) { for (int i = 0; i < d->m_modes.count(); ++i) { if (d->m_modes.at(i)->id() == id) return i; } - qDebug() << "Warning, no such mode:" << id; + qDebug() << "Warning, no such mode:" << id.toString(); return -1; } @@ -109,7 +109,7 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow, connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int))); connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int))); - connect(d->m_signalMapper, SIGNAL(mapped(QString)), this, SLOT(slotActivateMode(QString))); + connect(d->m_signalMapper, SIGNAL(mapped(int)), this, SLOT(slotActivateMode(int))); } void ModeManager::init() @@ -143,7 +143,7 @@ IMode *ModeManager::currentMode() return d->m_modes.at(currentIndex); } -IMode *ModeManager::mode(const QString &id) +IMode *ModeManager::mode(Id id) { const int index = indexOf(id); if (index >= 0) @@ -151,7 +151,7 @@ IMode *ModeManager::mode(const QString &id) return 0; } -void ModeManager::activateModeType(const QString &type) +void ModeManager::activateModeType(Id type) { if (currentMode() && currentMode()->type() == type) return; @@ -166,12 +166,12 @@ void ModeManager::activateModeType(const QString &type) d->m_modeStack->setCurrentIndex(index); } -void ModeManager::slotActivateMode(const QString &id) +void ModeManager::slotActivateMode(int id) { - m_instance->activateMode(id); + m_instance->activateMode(Id::fromUniqueIdentifier(id)); } -void ModeManager::activateMode(const QString &id) +void ModeManager::activateMode(Id id) { const int index = indexOf(id); if (index >= 0) @@ -198,7 +198,7 @@ void ModeManager::objectAdded(QObject *obj) // Register mode shortcut ActionManager *am = d->m_mainWindow->actionManager(); - const Id shortcutId(QLatin1String("QtCreator.Mode.") + mode->id()); + const Id shortcutId(QLatin1String("QtCreator.Mode.") + mode->id().toString()); 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)); @@ -221,7 +221,7 @@ void ModeManager::objectAdded(QObject *obj) currentCmd->setKeySequence(currentCmd->defaultKeySequence()); } - d->m_signalMapper->setMapping(shortcut, mode->id()); + d->m_signalMapper->setMapping(shortcut, mode->id().uniqueIdentifier()); connect(shortcut, SIGNAL(activated()), d->m_signalMapper, SLOT(map())); connect(mode, SIGNAL(enabledStateChanged(bool)), this, SLOT(enabledStateChanged())); diff --git a/src/plugins/coreplugin/modemanager.h b/src/plugins/coreplugin/modemanager.h index cb4433ed45..211c095334 100644 --- a/src/plugins/coreplugin/modemanager.h +++ b/src/plugins/coreplugin/modemanager.h @@ -33,8 +33,9 @@ #ifndef MODEMANAGER_H #define MODEMANAGER_H -#include <QObject> #include <coreplugin/core_global.h> +#include <coreplugin/id.h> +#include <QObject> QT_BEGIN_NAMESPACE class QAction; @@ -61,15 +62,15 @@ public: static ModeManager *instance(); static IMode *currentMode(); - static IMode *mode(const QString &id); + static IMode *mode(Id id); static void addAction(QAction *action, int priority); static void addProjectSelector(QAction *action); static void addWidget(QWidget *widget); - static void activateModeType(const QString &type); + static void activateModeType(Id type); static void setModeBarHidden(bool hidden); - static void activateMode(const QString &id); + static void activateMode(Id id); static void setFocusToCurrentMode(); signals: @@ -79,7 +80,7 @@ signals: void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode = 0); private slots: - void slotActivateMode(const QString &id); + void slotActivateMode(int id); void objectAdded(QObject *obj); void aboutToRemoveObject(QObject *obj); void currentTabAboutToChange(int index); diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 0517bc57af..f1fbd6f447 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -450,7 +450,7 @@ void OutputPaneManager::showPage(int idx, bool focus) if (!OutputPanePlaceHolder::getCurrent()) { // In this mode we don't have a placeholder // switch to the output mode and switch the page - ModeManager::activateMode(QLatin1String(Constants::MODE_EDIT)); + ModeManager::activateMode(Id(Constants::MODE_EDIT)); } if (OutputPanePlaceHolder::getCurrent()) { // make the page visible diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 578ebb4ee2..a1e68b133e 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -306,7 +306,7 @@ void DebuggerMainWindow::setEngineDebugLanguages(DebuggerLanguages languages) void DebuggerMainWindow::onModeChanged(IMode *mode) { - d->m_inDebugMode = (mode && mode->id() == QLatin1String(Constants::MODE_DEBUG)); + d->m_inDebugMode = (mode && mode->id() == Constants::MODE_DEBUG); setDockActionsVisible(d->m_inDebugMode); // Hide all the debugger windows if mode is different. diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 4e72a3db78..fc42b270a1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -552,8 +552,8 @@ public: setDisplayName(DebuggerPlugin::tr("Debug")); setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Debug.png"))); setPriority(85); - setId(QLatin1String(MODE_DEBUG)); - setType(QLatin1String(CC::MODE_EDIT_TYPE)); + setId(MODE_DEBUG); + setType(CC::MODE_EDIT_TYPE); } ~DebugMode() @@ -1123,7 +1123,7 @@ public: DebuggerMainWindow *m_mainWindow; DebuggerRunControlFactory *m_debuggerRunControlFactory; - QString m_previousMode; + Id m_previousMode; QList<DebuggerStartParameters> m_scheduledStarts; Utils::ProxyAction *m_visibleStartAction; @@ -2453,7 +2453,7 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode) m_mainWindow->onModeChanged(mode); - if (mode->id() != QLatin1String(Constants::MODE_DEBUG)) { + if (mode->id() != Constants::MODE_DEBUG) { m_toolTipManager->leavingDebugMode(); return; } @@ -2497,10 +2497,10 @@ void DebuggerPluginPrivate::dumpLog() /*! Activates the previous mode when the current mode is the debug mode. */ void DebuggerPluginPrivate::activatePreviousMode() { - if (ModeManager::currentMode() == ModeManager::mode(QLatin1String(MODE_DEBUG)) - && !m_previousMode.isEmpty()) { + if (ModeManager::currentMode() == ModeManager::mode(MODE_DEBUG) + && m_previousMode.isValid()) { ModeManager::activateMode(m_previousMode); - m_previousMode.clear(); + m_previousMode = Id(); } } @@ -2509,7 +2509,7 @@ void DebuggerPluginPrivate::activateDebugMode() m_reverseDirectionAction->setChecked(false); m_reverseDirectionAction->setEnabled(false); m_previousMode = ModeManager::currentMode()->id(); - ModeManager::activateMode(_(MODE_DEBUG)); + ModeManager::activateMode(MODE_DEBUG); } void DebuggerPluginPrivate::sessionLoaded() diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index 323d15c0f3..a1862399a0 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -99,7 +99,7 @@ QStringList FormEditorFactory::mimeTypes() const void FormEditorFactory::designerModeClicked() { - Core::ModeManager::activateMode(QLatin1String(Core::Constants::MODE_DESIGN)); + Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN); } } // namespace Internal diff --git a/src/plugins/designer/formeditorstack.cpp b/src/plugins/designer/formeditorstack.cpp index 7e5d217538..7a5568cbc5 100644 --- a/src/plugins/designer/formeditorstack.cpp +++ b/src/plugins/designer/formeditorstack.cpp @@ -188,10 +188,10 @@ SharedTools::WidgetHost *FormEditorStack::formWindowEditorForXmlEditor(const Cor void FormEditorStack::modeAboutToChange(Core::IMode *m) { if (Designer::Constants::Internal::debug && m) - qDebug() << "FormEditorStack::modeAboutToChange" << m->id(); + qDebug() << "FormEditorStack::modeAboutToChange" << m->id().toString(); // Sync the editor when entering edit mode - if (m && m->id() == QLatin1String(Core::Constants::MODE_EDIT)) + if (m && m->id() == Core::Constants::MODE_EDIT) foreach(const EditorData &data, m_formEditors) data.formWindowEditor->syncXmlEditor(); } diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index a8358db380..47a9b116a2 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -279,9 +279,9 @@ TextEditor::PlainTextEditor *FormWindowEditor::textEditor() return &d->m_textEditor; } -QString FormWindowEditor::preferredModeType() const +Core::Id FormWindowEditor::preferredModeType() const { - return QLatin1String(Core::Constants::MODE_DESIGN_TYPE); + return Core::Constants::MODE_DESIGN_TYPE; } } // namespace Designer diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h index bea7b25cd0..2f1b74c6d8 100644 --- a/src/plugins/designer/formwindoweditor.h +++ b/src/plugins/designer/formwindoweditor.h @@ -87,7 +87,7 @@ public: virtual QWidget *toolBar(); - virtual QString preferredModeType() const; + virtual Core::Id preferredModeType() const; // For uic code model support QString contents() const; diff --git a/src/plugins/glsleditor/glsleditoreditable.cpp b/src/plugins/glsleditor/glsleditoreditable.cpp index 83959c4243..36bed6d9d0 100644 --- a/src/plugins/glsleditor/glsleditoreditable.cpp +++ b/src/plugins/glsleditor/glsleditoreditable.cpp @@ -53,9 +53,9 @@ GLSLEditorEditable::GLSLEditorEditable(GLSLTextEditorWidget *editor) TextEditor::Constants::C_TEXTEDITOR)); } -QString GLSLEditorEditable::preferredModeType() const +Core::Id GLSLEditorEditable::preferredModeType() const { - return QString(); + return Core::Id(); } } // namespace Internal diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h index 326456d6b2..0c381f44c0 100644 --- a/src/plugins/glsleditor/glsleditoreditable.h +++ b/src/plugins/glsleditor/glsleditoreditable.h @@ -52,7 +52,7 @@ public: Core::Id id() const; bool isTemporary() const { return false; } bool open(QString *errorString, const QString &fileName, const QString &realFileName); - QString preferredModeType() const; + Core::Id preferredModeType() const; }; } // namespace Internal diff --git a/src/plugins/helloworld/helloworldplugin.cpp b/src/plugins/helloworld/helloworldplugin.cpp index 025f926df2..64fb34d1e0 100644 --- a/src/plugins/helloworld/helloworldplugin.cpp +++ b/src/plugins/helloworld/helloworldplugin.cpp @@ -62,8 +62,8 @@ public: setDisplayName(tr("Hello world!")); setIcon(QIcon()); setPriority(0); - setId(QLatin1String("HelloWorld.HelloWorldMode")); - setType(QLatin1String("HelloWorld.HelloWorldMode")); + setId("HelloWorld.HelloWorldMode"); + setType("HelloWorld.HelloWorldMode"); setContextHelpId(QString()); } }; diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 509d08d246..55d9c3aa67 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -665,7 +665,7 @@ void HelpPlugin::resetRightPaneScale() void HelpPlugin::activateHelpMode() { if (contextHelpOption() != Help::Constants::ExternalHelpAlways) - Core::ModeManager::activateMode(QLatin1String(Constants::ID_MODE_HELP)); + Core::ModeManager::activateMode(Id(Constants::ID_MODE_HELP)); else showExternalWindow(); } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index bdf78d7801..a4f4553b05 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -270,8 +270,8 @@ public: setDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects")); setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png"))); setPriority(Constants::P_MODE_SESSION); - setId(QLatin1String(Constants::MODE_SESSION)); - setType(QString()); + setId(Constants::MODE_SESSION); + setType(Core::Id()); setContextHelpId(QLatin1String("Managing Projects")); } }; @@ -1216,7 +1216,7 @@ void ProjectExplorerPlugin::showSessionManager() updateActions(); - Core::IMode *welcomeMode = Core::ModeManager::mode(QLatin1String(Core::Constants::MODE_WELCOME)); + Core::IMode *welcomeMode = Core::ModeManager::mode(Core::Constants::MODE_WELCOME); if (Core::ModeManager::currentMode() == welcomeMode) updateWelcomePage(); } @@ -1372,9 +1372,9 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName if (!openedPro.isEmpty()) { if (switchToProjectsMode) - Core::ModeManager::activateMode(QLatin1String(ProjectExplorer::Constants::MODE_SESSION)); + Core::ModeManager::activateMode(ProjectExplorer::Constants::MODE_SESSION); else - Core::ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + Core::ModeManager::activateMode(Core::Constants::MODE_EDIT); Core::ModeManager::setFocusToCurrentMode(); } @@ -1440,7 +1440,7 @@ void ProjectExplorerPlugin::updateWelcomePage() void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode) { Q_UNUSED(oldMode); - if (mode && mode->id() == Core::Id(Core::Constants::MODE_WELCOME).toString()) + if (mode && mode->id() == Core::Constants::MODE_WELCOME) updateWelcomePage(); } @@ -1468,7 +1468,7 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup() d->m_sessionToRestoreAtStartup = d->m_session->lastSession(); if (!d->m_sessionToRestoreAtStartup.isNull()) - Core::ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + Core::ModeManager::activateMode(Core::Constants::MODE_EDIT); } /*! diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 3fa142260b..b3263a0a02 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -130,7 +130,7 @@ bool SessionManager::isDefaultSession(const QString &session) const void SessionManager::saveActiveMode(Core::IMode *mode) { - setValue(QLatin1String("ActiveMode"), mode->id()); + setValue(QLatin1String("ActiveMode"), mode->id().toString()); } void SessionManager::clearProjectFileCache() @@ -862,13 +862,16 @@ bool SessionManager::loadSession(const QString &session) // restore the active mode QString modeIdentifier = value(QLatin1String("ActiveMode")).toString(); + Id modeId; if (modeIdentifier.isEmpty()) - modeIdentifier = QLatin1String(Core::Constants::MODE_EDIT); + modeId = Id(Core::Constants::MODE_EDIT); + else + modeId = Id(modeIdentifier); - ModeManager::activateMode(modeIdentifier); + ModeManager::activateMode(modeId); ModeManager::setFocusToCurrentMode(); } else { - ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + ModeManager::activateMode(Id(Core::Constants::MODE_EDIT)); ModeManager::setFocusToCurrentMode(); } emit sessionLoaded(session); diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp index 7c1306d086..b0de0e5e9d 100644 --- a/src/plugins/qmljseditor/qmljseditoreditable.cpp +++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp @@ -63,7 +63,7 @@ static bool openInDesignMode() // Check if Bauhaus is loaded, that is, a Design mode widget is // registered for the QML mime type. if (!bauhausDetected) { - if (const Core::IMode *dm = Core::ModeManager::mode(QLatin1String(Core::Constants::MODE_DESIGN))) + if (const Core::IMode *dm = Core::ModeManager::mode(Core::Constants::MODE_DESIGN)) if (const Core::DesignMode *designMode = qobject_cast<const Core::DesignMode *>(dm)) bauhausPresent = designMode->registeredMimeTypes().contains(QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)); bauhausDetected = true; @@ -74,7 +74,7 @@ static bool openInDesignMode() return bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT); } -QString QmlJSEditorEditable::preferredModeType() const +Core::Id QmlJSEditorEditable::preferredModeType() const { Core::IMode *mode = Core::ModeManager::currentMode(); if (mode && (mode->type() == Core::Constants::MODE_DESIGN_TYPE @@ -88,8 +88,8 @@ QString QmlJSEditorEditable::preferredModeType() const // have the user also access to this failsafe setting. if (editorWidget()->mimeType() == QLatin1String(QmlJSTools::Constants::QML_MIMETYPE) && openInDesignMode()) - return QLatin1String(Core::Constants::MODE_DESIGN_TYPE); - return QString(); + return Core::Constants::MODE_DESIGN_TYPE; + return Core::Id(); } void QmlJSEditorEditable::setTextCodec(QTextCodec *codec, TextCodecReason reason) diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h index ad3717ccf7..389c6ef7b0 100644 --- a/src/plugins/qmljseditor/qmljseditoreditable.h +++ b/src/plugins/qmljseditor/qmljseditoreditable.h @@ -51,7 +51,7 @@ public: Core::Id id() const; bool isTemporary() const { return false; } bool open(QString *errorString, const QString &fileName, const QString &realFileName); - QString preferredModeType() const; + Core::Id preferredModeType() const; void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason); }; diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 8f9ae69a30..8c4e1d18a0 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -597,7 +597,7 @@ void QmlProfilerTool::showSaveDialog() void QmlProfilerTool::showLoadDialog() { - if (ModeManager::currentMode()->id() != QLatin1String(MODE_ANALYZE)) + if (ModeManager::currentMode()->id() != MODE_ANALYZE) AnalyzerManager::showMode(); if (AnalyzerManager::currentSelectedTool() != this) diff --git a/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp b/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp index a24cf30946..bdf921dd50 100644 --- a/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp +++ b/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp @@ -187,7 +187,7 @@ void TargetSetupPageWrapper::done() { m_targetSetupPage->setupProject(m_project); ProjectExplorer::ProjectExplorerPlugin::instance()->requestProjectModeUpdate(m_project); - Core::ICore::instance()->modeManager()->activateMode(QLatin1String(Core::Constants::MODE_EDIT)); + Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_EDIT); } void TargetSetupPageWrapper::noteTextLinkActivated() diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 96fe2eac28..37e30de7b5 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -422,7 +422,7 @@ void ExamplesWelcomePage::openProject(const QString &projectFile, const QStringL Core::ICore::openFiles(filesToOpen); if (project->needsConfiguration()) project->configureAsExampleProject(platforms); - Core::ModeManager::activateModeType(QLatin1String(Core::Constants::MODE_EDIT_TYPE)); + Core::ModeManager::activateModeType(Core::Constants::MODE_EDIT_TYPE); Core::ICore::helpManager()->handleHelpRequest(help.toString()+QLatin1String("?view=split")); } if (!errorMessage.isEmpty()) diff --git a/src/plugins/texteditor/linenumberfilter.cpp b/src/plugins/texteditor/linenumberfilter.cpp index 24a760933b..b43b5d8300 100644 --- a/src/plugins/texteditor/linenumberfilter.cpp +++ b/src/plugins/texteditor/linenumberfilter.cpp @@ -69,7 +69,7 @@ void LineNumberFilter::accept(FilterEntry selection) const editorManager->addCurrentPositionToNavigationHistory(); editor->gotoLine(selection.internalData.toInt()); editor->widget()->setFocus(); - Core::ModeManager::activateModeType(QLatin1String(Core::Constants::MODE_EDIT_TYPE)); + Core::ModeManager::activateModeType(Id(Core::Constants::MODE_EDIT_TYPE)); } } diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index 50c1739064..d9e8c6072f 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -138,8 +138,8 @@ WelcomeMode::WelcomeMode() : setDisplayName(tr("Welcome")); setIcon(QIcon(QLatin1String(Core::Constants::ICON_QTLOGO_32))); setPriority(Core::Constants::P_MODE_WELCOME); - setId(QLatin1String(Core::Constants::MODE_WELCOME)); - setType(QLatin1String(Core::Constants::MODE_WELCOME_TYPE)); + setId(Core::Constants::MODE_WELCOME); + setType(Core::Constants::MODE_WELCOME_TYPE); setContextHelpId(QLatin1String("Qt Creator Manual")); setContext(Core::Context(Core::Constants::C_WELCOME_MODE)); |