diff options
author | Denis Mingulov <denis.mingulov@gmail.com> | 2010-09-09 14:35:26 +0200 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2010-09-09 14:39:59 +0200 |
commit | b23b4588bf01f380f20c1cbbc8c4520194b9cd5e (patch) | |
tree | e552e483fb4ff07bd79b67afa9edf6c222acfad3 /src | |
parent | 0c9d85a933b74122170cd289d3fc8d92e7613374 (diff) | |
download | qt-creator-b23b4588bf01f380f20c1cbbc8c4520194b9cd5e.tar.gz |
Navigation Widget: add 'Priority' support
Merge-request: 176
Reviewed-by: hjk <qtc-committer@nokia.com>
Diffstat (limited to 'src')
19 files changed, 65 insertions, 18 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 1bc1460944..9d9b8aa9ba 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -778,6 +778,11 @@ QString BookmarkViewFactory::displayName() const return BookmarkView::tr("Bookmarks"); } +int BookmarkViewFactory::priority() const +{ + return 300; +} + QString BookmarkViewFactory::id() const { return QLatin1String("Bookmarks"); diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index 1c2d45135d..63b00372f9 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -173,6 +173,7 @@ class BookmarkViewFactory : public Core::INavigationWidgetFactory public: BookmarkViewFactory(BookmarkManager *bm); QString displayName() const; + int priority() const; QString id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); diff --git a/src/plugins/classview/classviewconstants.h b/src/plugins/classview/classviewconstants.h index 17b03bd560..4bb65f440e 100644 --- a/src/plugins/classview/classviewconstants.h +++ b/src/plugins/classview/classviewconstants.h @@ -36,6 +36,9 @@ namespace Constants { //! Navi Widget Factory id const char * const CLASSVIEWNAVIGATION_ID = "Class View"; +//! Navi Widget Factory priority +const int CLASSVIEWNAVIGATION_PRIORITY = 500; + //! Settings' group const char * const CLASSVIEW_SETTINGS_GROUP = "ClassView"; diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 2209c7fdc3..623728a399 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -87,6 +87,11 @@ QString NavigationWidgetFactory::displayName() const return tr("Class View"); } +int NavigationWidgetFactory::priority() const +{ + return Constants::CLASSVIEWNAVIGATION_PRIORITY; +} + QString NavigationWidgetFactory::id() const { return QLatin1String(Constants::CLASSVIEWNAVIGATION_ID); diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.h b/src/plugins/classview/classviewnavigationwidgetfactory.h index 619a97d36a..055c75d769 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.h +++ b/src/plugins/classview/classviewnavigationwidgetfactory.h @@ -62,6 +62,9 @@ public: //! \implements Core::INavigationWidgetFactory::displayName QString displayName() const; + //! \implements Core::INavigationWidgetFactory::priority + int priority() const; + //! \implements Core::INavigationWidgetFactory::id QString id() const; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index c479950984..f9559a7044 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -247,6 +247,11 @@ QString OpenEditorsViewFactory::displayName() const return OpenEditorsWidget::tr("Open Documents"); } +int OpenEditorsViewFactory::priority() const +{ + return 200; +} + QString OpenEditorsViewFactory::id() const { return QLatin1String("Open Documents"); diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h index 91d905bcc2..e719de1c51 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.h +++ b/src/plugins/coreplugin/editormanager/openeditorsview.h @@ -85,6 +85,7 @@ public: OpenEditorsViewFactory(); ~OpenEditorsViewFactory(); QString displayName() const; + int priority() const; QString id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.h b/src/plugins/coreplugin/inavigationwidgetfactory.h index e43f9ec3ec..6e14efb53d 100644 --- a/src/plugins/coreplugin/inavigationwidgetfactory.h +++ b/src/plugins/coreplugin/inavigationwidgetfactory.h @@ -56,6 +56,7 @@ public: virtual ~INavigationWidgetFactory(); virtual QString displayName() const = 0; + virtual int priority() const = 0; virtual QString id() const = 0; virtual QKeySequence activationSequence() const; // This design is not optimal, think about it again once we need to extend it diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 709757c389..4294419f9b 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -143,6 +143,7 @@ NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) : m_width(0), m_toggleSideBarAction(toggleSideBarAction) { + m_factoryModel->setSortRole(FactoryPriorityRole); setOrientation(Qt::Vertical); insertSubItem(0, -1); // we don't have any entry to show yet m_instance = this; @@ -180,8 +181,10 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact QStandardItem *newRow = new QStandardItem(factory->displayName()); newRow->setData(qVariantFromValue(factory), FactoryObjectRole); newRow->setData(factory->id(), FactoryIdRole); + newRow->setData(factory->priority(), FactoryPriorityRole); m_factoryModel->appendRow(newRow); } + m_factoryModel->sort(0); } int NavigationWidget::storedWidth() @@ -403,8 +406,7 @@ int NavigationWidget::factoryIndex(const QString &id) NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex) : m_parentWidget(parentWidget), - m_position(position), - m_currentIndex(-1) + m_position(position) { m_navigationComboBox = new NavComboBox(this); m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); @@ -412,6 +414,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int pos m_navigationComboBox->setMinimumContentsLength(0); m_navigationComboBox->setModel(parentWidget->factoryModel()); m_navigationWidget = 0; + m_navigationWidgetFactory = 0; m_toolBar = new Utils::StyledBar(this); QHBoxLayout *toolBarLayout = new QHBoxLayout; @@ -453,27 +456,24 @@ NavigationSubWidget::~NavigationSubWidget() void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex) { - if (m_currentIndex == factoryIndex) - return; - saveSettings(); - m_currentIndex = factoryIndex; - // Remove toolbutton foreach (QWidget *w, m_additionalToolBarWidgets) delete w; + m_additionalToolBarWidgets.clear(); // Remove old Widget delete m_navigationWidget; + m_navigationWidget = 0; + m_navigationWidgetFactory = 0; if (factoryIndex == -1) return; // Get new stuff - INavigationWidgetFactory *factory - = m_navigationComboBox->itemData(factoryIndex, - NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>(); - NavigationView n = factory->createWidget(); + m_navigationWidgetFactory = m_navigationComboBox->itemData(factoryIndex, + NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>(); + NavigationView n = m_navigationWidgetFactory->createWidget(); m_navigationWidget = n.widget; layout()->addWidget(m_navigationWidget); @@ -495,10 +495,7 @@ void NavigationSubWidget::setFocusWidget() INavigationWidgetFactory *NavigationSubWidget::factory() { - if (m_currentIndex == -1) - return 0; - return m_navigationComboBox->itemData(m_currentIndex, - NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>(); + return m_navigationWidgetFactory; } @@ -527,7 +524,7 @@ Core::Command *NavigationSubWidget::command(const QString &title) const int NavigationSubWidget::factoryIndex() const { - return m_currentIndex; + return m_navigationComboBox->currentIndex(); } void NavigationSubWidget::setFactoryIndex(int i) diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h index e269787286..086dc7c13b 100644 --- a/src/plugins/coreplugin/navigationwidget.h +++ b/src/plugins/coreplugin/navigationwidget.h @@ -77,7 +77,8 @@ class CORE_EXPORT NavigationWidget : public MiniSplitter public: enum FactoryModelRoles { FactoryObjectRole = Qt::UserRole, - FactoryIdRole + FactoryIdRole, + FactoryPriorityRole }; @@ -168,10 +169,10 @@ private: NavigationWidget *m_parentWidget; QComboBox *m_navigationComboBox; QWidget *m_navigationWidget; + INavigationWidgetFactory *m_navigationWidgetFactory; Utils::StyledBar *m_toolBar; QList<QToolButton *> m_additionalToolBarWidgets; int m_position; - int m_currentIndex; }; class NavComboBox : public QComboBox diff --git a/src/plugins/cppeditor/cppeditorconstants.h b/src/plugins/cppeditor/cppeditorconstants.h index 8993e03a28..5a68c78e4c 100644 --- a/src/plugins/cppeditor/cppeditorconstants.h +++ b/src/plugins/cppeditor/cppeditorconstants.h @@ -48,6 +48,7 @@ const char * const FIND_REFERENCES = "CppEditor.FindReferences"; const char * const JUMP_TO_DEFINITION = "CppEditor.JumpToDefinition"; const char * const UPDATE_CODEMODEL = "CppEditor.UpdateCodeModel"; +const int TYPE_HIERARCHY_PRIORITY = 700; const char * const TYPE_HIERARCHY_ID = "CppEditor.TypeHierarchy"; const char * const OPEN_TYPE_HIERARCHY = "CppEditor.OpenTypeHierarchy"; diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp index f4e6834e7a..a837911ecf 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.cpp +++ b/src/plugins/cppeditor/cpptypehierarchy.cpp @@ -262,6 +262,11 @@ QString CppTypeHierarchyFactory::displayName() const return tr("Type Hierarchy"); } +int CppTypeHierarchyFactory::priority() const +{ + return Constants::TYPE_HIERARCHY_PRIORITY; +} + QString CppTypeHierarchyFactory::id() const { return QLatin1String(Constants::TYPE_HIERARCHY_ID); diff --git a/src/plugins/cppeditor/cpptypehierarchy.h b/src/plugins/cppeditor/cpptypehierarchy.h index 3410f35e6b..db61747151 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.h +++ b/src/plugins/cppeditor/cpptypehierarchy.h @@ -133,6 +133,7 @@ public: virtual ~CppTypeHierarchyFactory(); virtual QString displayName() const; + virtual int priority() const; virtual QString 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 6add41d699..b505d7d9fd 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -466,6 +466,11 @@ QString FolderNavigationWidgetFactory::displayName() const return tr("File System"); } +int FolderNavigationWidgetFactory::priority() const +{ + return 400; +} + QString FolderNavigationWidgetFactory::id() const { return QLatin1String("File System"); diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h index e0930394c5..04cf40eac1 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.h +++ b/src/plugins/projectexplorer/foldernavigationwidget.h @@ -102,6 +102,7 @@ public: ~FolderNavigationWidgetFactory(); QString displayName() const; + int priority() const; QString id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index c3931e2ea5..20d18d0718 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -340,6 +340,11 @@ QString ProjectTreeWidgetFactory::displayName() const return tr("Projects"); } +int ProjectTreeWidgetFactory::priority() const +{ + return 100; +} + QString ProjectTreeWidgetFactory::id() const { return QLatin1String("Projects"); diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 00f7a2905f..bf86f227a6 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -100,6 +100,7 @@ public: ProjectTreeWidgetFactory(); ~ProjectTreeWidgetFactory(); QString displayName() const; + int priority() const; QString id() const; QKeySequence activationSequence() const; Core::NavigationView createWidget(); diff --git a/src/plugins/texteditor/outlinefactory.cpp b/src/plugins/texteditor/outlinefactory.cpp index 9829115f12..5f3add6a23 100644 --- a/src/plugins/texteditor/outlinefactory.cpp +++ b/src/plugins/texteditor/outlinefactory.cpp @@ -164,6 +164,11 @@ QString OutlineFactory::displayName() const return tr("Outline"); } +int OutlineFactory::priority() const +{ + return 600; +} + QString OutlineFactory::id() const { return QLatin1String("Outline"); diff --git a/src/plugins/texteditor/outlinefactory.h b/src/plugins/texteditor/outlinefactory.h index e14e0c29fc..52599097ab 100644 --- a/src/plugins/texteditor/outlinefactory.h +++ b/src/plugins/texteditor/outlinefactory.h @@ -58,6 +58,7 @@ public: // from INavigationWidgetFactory virtual QString displayName() const; + virtual int priority() const; virtual QString id() const; virtual QKeySequence activationSequence() const; virtual Core::NavigationView createWidget(); |