diff options
author | hjk <qtc-committer@nokia.com> | 2011-11-09 12:07:41 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-11-10 15:46:13 +0100 |
commit | f80db703bbdda8d4ff8d979c144ae28b8fcd23a2 (patch) | |
tree | fd8acd2bd0fd5ca60b8cd520910180935a62b44e | |
parent | e6a2f702449d5234e39ead35cfa95a4f91ac0dc6 (diff) | |
download | qt-creator-f80db703bbdda8d4ff8d979c144ae28b8fcd23a2.tar.gz |
use Core::Id for ids in INavigationWidgetFactory
Change-Id: Ic793e01edf6a4d2fe61baadb3aa5bef817436d35
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
21 files changed, 53 insertions, 64 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 41624408f6..1d9daa06cb 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -777,9 +777,9 @@ int BookmarkViewFactory::priority() const return 300; } -QString BookmarkViewFactory::id() const +Id BookmarkViewFactory::id() const { - return QLatin1String("Bookmarks"); + return Id("Bookmarks"); } QKeySequence BookmarkViewFactory::activationSequence() const diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index d1c4a46179..756692496c 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -172,7 +172,7 @@ public: BookmarkViewFactory(BookmarkManager *bm); QString displayName() const; int priority() const; - QString id() const; + Core::Id id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); private: diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 4c4ae07f36..5ffe2cc77b 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -73,9 +73,9 @@ int NavigationWidgetFactory::priority() const return 500; } -QString NavigationWidgetFactory::id() const +Core::Id NavigationWidgetFactory::id() const { - return QLatin1String("Class View"); + return Core::Id("Class View"); } QKeySequence NavigationWidgetFactory::activationSequence() const diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.h b/src/plugins/classview/classviewnavigationwidgetfactory.h index 260ac67427..c2ee5f8fd8 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.h +++ b/src/plugins/classview/classviewnavigationwidgetfactory.h @@ -69,7 +69,7 @@ public: int priority() const; //! \implements Core::INavigationWidgetFactory::id - QString id() const; + Core::Id id() const; //! \implements Core::INavigationWidgetFactory::activationSequence QKeySequence activationSequence() const; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index b8e6e19713..f963c4e453 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -233,9 +233,9 @@ int OpenEditorsViewFactory::priority() const return 200; } -QString OpenEditorsViewFactory::id() const +Core::Id OpenEditorsViewFactory::id() const { - return QLatin1String("Open Documents"); + return Core::Id("Open Documents"); } QKeySequence OpenEditorsViewFactory::activationSequence() const diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h index 361d0b5213..2d6c0e2044 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.h +++ b/src/plugins/coreplugin/editormanager/openeditorsview.h @@ -89,7 +89,7 @@ public: ~OpenEditorsViewFactory(); QString displayName() const; int priority() const; - QString id() const; + Core::Id id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); }; diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.cpp b/src/plugins/coreplugin/inavigationwidgetfactory.cpp index f7d1a26f7d..108de0c76a 100644 --- a/src/plugins/coreplugin/inavigationwidgetfactory.cpp +++ b/src/plugins/coreplugin/inavigationwidgetfactory.cpp @@ -36,14 +36,6 @@ using namespace Core; -INavigationWidgetFactory::INavigationWidgetFactory() -{ -} - -INavigationWidgetFactory::~INavigationWidgetFactory() -{ -} - QKeySequence INavigationWidgetFactory::activationSequence() const { return QKeySequence(); diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.h b/src/plugins/coreplugin/inavigationwidgetfactory.h index 2f89f5529a..ed485f0bfb 100644 --- a/src/plugins/coreplugin/inavigationwidgetfactory.h +++ b/src/plugins/coreplugin/inavigationwidgetfactory.h @@ -33,7 +33,8 @@ #ifndef INAVIGATIONWIDGET_H #define INAVIGATIONWIDGET_H -#include <coreplugin/core_global.h> +#include <coreplugin/id.h> + #include <QtCore/QObject> #include <QtCore/QList> @@ -54,13 +55,13 @@ struct NavigationView class CORE_EXPORT INavigationWidgetFactory : public QObject { Q_OBJECT + public: - INavigationWidgetFactory(); - virtual ~INavigationWidgetFactory(); + INavigationWidgetFactory() {} virtual QString displayName() const = 0; virtual int priority() const = 0; - virtual QString id() const = 0; + virtual Id id() const = 0; virtual QKeySequence activationSequence() const; // This design is not optimal, think about it again once we need to extend it // It could be implemented as returning an object which has both the widget diff --git a/src/plugins/coreplugin/navigationsubwidget.cpp b/src/plugins/coreplugin/navigationsubwidget.cpp index 69bf911b66..4bc743711c 100644 --- a/src/plugins/coreplugin/navigationsubwidget.cpp +++ b/src/plugins/coreplugin/navigationsubwidget.cpp @@ -176,8 +176,8 @@ void NavigationSubWidget::restoreSettings() Core::Command *NavigationSubWidget::command(const QString &title) const { - const QHash<QString, Core::Command*> commandMap = m_parentWidget->commandMap(); - QHash<QString, Core::Command*>::const_iterator r = commandMap.find(title); + const QHash<Id, Command *> commandMap = m_parentWidget->commandMap(); + QHash<Id, Command *>::const_iterator r = commandMap.find(Id(title)); if (r != commandMap.end()) return r.value(); return 0; diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 98fbfdce72..95640e68ae 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -139,12 +139,13 @@ void NavigationWidgetPlaceHolder::currentModeAboutToChange(Core::IMode *mode) } } -struct NavigationWidgetPrivate { +struct NavigationWidgetPrivate +{ explicit NavigationWidgetPrivate(QAction *toggleSideBarAction); QList<Internal::NavigationSubWidget *> m_subWidgets; - QHash<QShortcut *, QString> m_shortcutMap; - QHash<QString, Core::Command*> m_commandMap; + QHash<QShortcut *, Core::Id> m_shortcutMap; + QHash<Core::Id, Core::Command *> m_commandMap; QStandardItemModel *m_factoryModel; bool m_shown; @@ -191,7 +192,7 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact Context navicontext(Core::Constants::C_NAVIGATION_PANE); foreach (INavigationWidgetFactory *factory, factories) { - const QString id = factory->id(); + const Id id = factory->id(); QShortcut *shortcut = new QShortcut(this); shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName())); @@ -199,13 +200,13 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact d->m_shortcutMap.insert(shortcut, id); Command *cmd = am->registerShortcut(shortcut, - Id(QLatin1String("QtCreator.Sidebar.") + id), navicontext); + Id(QLatin1String("QtCreator.Sidebar.") + id.name()), navicontext); cmd->setDefaultKeySequence(factory->activationSequence()); d->m_commandMap.insert(id, cmd); QStandardItem *newRow = new QStandardItem(factory->displayName()); newRow->setData(qVariantFromValue(factory), FactoryObjectRole); - newRow->setData(factory->id(), FactoryIdRole); + newRow->setData(QVariant::fromValue(factory->id()), FactoryIdRole); newRow->setData(factory->priority(), FactoryPriorityRole); d->m_factoryModel->appendRow(newRow); } @@ -266,11 +267,11 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int void NavigationWidget::activateSubWidget() { QShortcut *original = qobject_cast<QShortcut *>(sender()); - QString id = d->m_shortcutMap[original]; + Id id = d->m_shortcutMap[original]; activateSubWidget(id); } -void NavigationWidget::activateSubWidget(const QString &factoryId) +void NavigationWidget::activateSubWidget(const Id &factoryId) { setShown(true); foreach (Internal::NavigationSubWidget *subWidget, d->m_subWidgets) { @@ -312,7 +313,7 @@ void NavigationWidget::saveSettings(QSettings *settings) QStringList viewIds; for (int i=0; i<d->m_subWidgets.count(); ++i) { d->m_subWidgets.at(i)->saveSettings(); - viewIds.append(d->m_subWidgets.at(i)->factory()->id()); + viewIds.append(d->m_subWidgets.at(i)->factory()->id().toString()); } settings->setValue(QLatin1String("Navigation/Views"), viewIds); settings->setValue(QLatin1String("Navigation/Visible"), isShown()); @@ -343,7 +344,7 @@ void NavigationWidget::restoreSettings(QSettings *settings) int position = 0; foreach (const QString &id, viewIds) { - int index = factoryIndex(id); + int index = factoryIndex(Id(id)); if (index >= 0) { // Only add if the id was actually found! insertSubItem(position, index); @@ -355,7 +356,7 @@ void NavigationWidget::restoreSettings(QSettings *settings) if (d->m_subWidgets.isEmpty()) // Make sure we have at least the projects widget - insertSubItem(0, qMax(0, factoryIndex(QLatin1String("Projects")))); + insertSubItem(0, qMax(0, factoryIndex(Id("Projects")))); setShown(settings->value(QLatin1String("Navigation/Visible"), true).toBool()); @@ -421,17 +422,17 @@ void NavigationWidget::setSuppressed(bool b) NavigationWidgetPlaceHolder::m_current->setVisible(d->m_shown && !d->m_suppressed); } -int NavigationWidget::factoryIndex(const QString &id) +int NavigationWidget::factoryIndex(const Id &id) { for (int row = 0; row < d->m_factoryModel->rowCount(); ++row) { - if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).toString() == id) { + if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).value<Core::Id>() == id) { return row; } } return -1; } -QHash<QString, Core::Command*> NavigationWidget::commandMap() const +QHash<Id, Command *> NavigationWidget::commandMap() const { return d->m_commandMap; } diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h index a8ef2db99f..b54104608b 100644 --- a/src/plugins/coreplugin/navigationwidget.h +++ b/src/plugins/coreplugin/navigationwidget.h @@ -34,6 +34,7 @@ #define NAVIGATIONWIDGET_H #include <coreplugin/minisplitter.h> +#include <coreplugin/id.h> #include <QtCore/QHash> @@ -92,7 +93,7 @@ public: void saveSettings(QSettings *settings); void restoreSettings(QSettings *settings); - void activateSubWidget(const QString &factoryId); + void activateSubWidget(const Id &factoryId); void closeSubWidgets(); bool isShown() const; @@ -108,7 +109,7 @@ public: // Called from the place holders void placeHolderChanged(NavigationWidgetPlaceHolder *holder); - QHash<QString, Core::Command*> commandMap() const; + QHash<Id, Core::Command *> commandMap() const; QAbstractItemModel *factoryModel() const; protected: @@ -122,7 +123,7 @@ private slots: private: void updateToggleText(); Internal::NavigationSubWidget *insertSubItem(int position, int index); - int factoryIndex(const QString &id); + int factoryIndex(const Id &id); NavigationWidgetPrivate *d; }; diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index 426fef768f..d218724e6c 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -416,7 +416,7 @@ void CppPlugin::openTypeHierarchy() CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (editor) { Core::NavigationWidget *navigation = Core::NavigationWidget::instance(); - navigation->activateSubWidget(QLatin1String(Constants::TYPE_HIERARCHY_ID)); + navigation->activateSubWidget(Core::Id(Constants::TYPE_HIERARCHY_ID)); emit typeHierarchyRequested(); } } diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp index aa38b8e64c..7d43c0ba00 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.cpp +++ b/src/plugins/cppeditor/cpptypehierarchy.cpp @@ -237,9 +237,9 @@ int CppTypeHierarchyFactory::priority() const return Constants::TYPE_HIERARCHY_PRIORITY; } -QString CppTypeHierarchyFactory::id() const +Core::Id CppTypeHierarchyFactory::id() const { - return QLatin1String(Constants::TYPE_HIERARCHY_ID); + return Core::Id(Constants::TYPE_HIERARCHY_ID); } QKeySequence CppTypeHierarchyFactory::activationSequence() const diff --git a/src/plugins/cppeditor/cpptypehierarchy.h b/src/plugins/cppeditor/cpptypehierarchy.h index 4be85f3e73..7545e0f504 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.h +++ b/src/plugins/cppeditor/cpptypehierarchy.h @@ -111,7 +111,7 @@ public: virtual QString displayName() const; virtual int priority() const; - virtual QString id() const; + virtual Core::Id id() const; virtual QKeySequence activationSequence() const; virtual Core::NavigationView createWidget(); }; diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index 4e3d9bcc93..6a87cd23c9 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -404,9 +404,9 @@ int FolderNavigationWidgetFactory::priority() const return 400; } -QString FolderNavigationWidgetFactory::id() const +Core::Id FolderNavigationWidgetFactory::id() const { - return QLatin1String("File System"); + return "File System"; } QKeySequence FolderNavigationWidgetFactory::activationSequence() const diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h index 279e692331..4b65185e9e 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.h +++ b/src/plugins/projectexplorer/foldernavigationwidget.h @@ -100,7 +100,7 @@ public: QString displayName() const; int priority() const; - QString id() const; + Core::Id id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); }; diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 5642a6ab01..c3bebe4350 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -407,9 +407,9 @@ int ProjectTreeWidgetFactory::priority() const return 100; } -QString ProjectTreeWidgetFactory::id() const +Core::Id ProjectTreeWidgetFactory::id() const { - return QLatin1String("Projects"); + return Core::Id("Projects"); } QKeySequence ProjectTreeWidgetFactory::activationSequence() const diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 27fdb81ab2..ed04102647 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -113,7 +113,7 @@ public: ~ProjectTreeWidgetFactory(); QString displayName() const; int priority() const; - QString id() const; + Core::Id id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); void restoreSettings(int position, QWidget *widget); diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 43cf55df14..efa69cfbe7 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -668,19 +668,18 @@ void DesignModeWidget::setup() QWidget *fileSystemExplorer = 0; - foreach(Core::INavigationWidgetFactory *factory, factories) - { + foreach (Core::INavigationWidgetFactory *factory, factories) { Core::NavigationView navigationView; navigationView.widget = 0; - if (factory->id() == QLatin1String("Projects")) { + if (factory->id() == Core::Id("Projects")) { navigationView = factory->createWidget(); projectsExplorer = navigationView.widget; projectsExplorer->setWindowTitle(tr("Projects")); - } else if (factory->id() == QLatin1String("File System")) { + } else if (factory->id() == Core::Id("File System")) { navigationView = factory->createWidget(); fileSystemExplorer = navigationView.widget; fileSystemExplorer->setWindowTitle(tr("File System")); - } else if (factory->id() == QLatin1String("Open Documents")) { + } else if (factory->id() == Core::Id("Open Documents")) { navigationView = factory->createWidget(); openDocumentsWidget = navigationView.widget; openDocumentsWidget->setWindowTitle(tr("Open Documents")); diff --git a/src/plugins/texteditor/outlinefactory.cpp b/src/plugins/texteditor/outlinefactory.cpp index 717ad7dd66..0a960bf0a0 100644 --- a/src/plugins/texteditor/outlinefactory.cpp +++ b/src/plugins/texteditor/outlinefactory.cpp @@ -178,11 +178,6 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor) } } -OutlineFactory::OutlineFactory() : - Core::INavigationWidgetFactory() -{ -} - QList<IOutlineWidgetFactory*> OutlineFactory::widgetFactories() const { return m_factories; @@ -203,9 +198,9 @@ int OutlineFactory::priority() const return 600; } -QString OutlineFactory::id() const +Core::Id OutlineFactory::id() const { - return QLatin1String("Outline"); + return Core::Id("Outline"); } QKeySequence OutlineFactory::activationSequence() const diff --git a/src/plugins/texteditor/outlinefactory.h b/src/plugins/texteditor/outlinefactory.h index d5e8398a71..4cd953d983 100644 --- a/src/plugins/texteditor/outlinefactory.h +++ b/src/plugins/texteditor/outlinefactory.h @@ -83,7 +83,7 @@ class OutlineFactory : public Core::INavigationWidgetFactory { Q_OBJECT public: - OutlineFactory(); + OutlineFactory() {} QList<IOutlineWidgetFactory*> widgetFactories() const; void setWidgetFactories(QList<IOutlineWidgetFactory*> factories); @@ -91,7 +91,7 @@ public: // from INavigationWidgetFactory virtual QString displayName() const; virtual int priority() const; - virtual QString id() const; + virtual Core::Id id() const; virtual QKeySequence activationSequence() const; virtual Core::NavigationView createWidget(); virtual void saveSettings(int position, QWidget *widget); |