From 58a248cb9d877935a966f226381a08d934b628b0 Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Wed, 27 Jan 2010 19:03:20 +0100
Subject: [PATCH] Navigation widgets need separate id and display name.

Such that the layout of the left hand sidebar can be restored
even if the display language is changed.
---
 src/plugins/bookmarks/bookmarkmanager.cpp     |  9 ++++++--
 src/plugins/bookmarks/bookmarkmanager.h       |  7 +++---
 .../editormanager/openeditorsview.cpp         |  9 ++++++--
 .../editormanager/openeditorsview.h           |  7 +++---
 .../coreplugin/inavigationwidgetfactory.cpp   |  2 +-
 .../coreplugin/inavigationwidgetfactory.h     |  5 +++--
 src/plugins/coreplugin/navigationwidget.cpp   | 22 +++++++++----------
 src/plugins/coreplugin/navigationwidget.h     |  2 +-
 src/plugins/coreplugin/outputpane.cpp         |  1 +
 .../foldernavigationwidget.cpp                |  9 ++++++--
 .../projectexplorer/foldernavigationwidget.h  |  9 ++++----
 .../projectexplorer/projecttreewidget.cpp     |  9 ++++++--
 .../projectexplorer/projecttreewidget.h       |  9 ++++----
 13 files changed, 63 insertions(+), 37 deletions(-)

diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index 71507d4d6d6..0d2ea2f45ed 100644
--- a/src/plugins/bookmarks/bookmarkmanager.cpp
+++ b/src/plugins/bookmarks/bookmarkmanager.cpp
@@ -774,12 +774,17 @@ BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm)
 
 }
 
-QString BookmarkViewFactory::displayName()
+QString BookmarkViewFactory::displayName() const
 {
     return BookmarkView::tr("Bookmarks");
 }
 
-QKeySequence BookmarkViewFactory::activationSequence()
+QString BookmarkViewFactory::id() const
+{
+    return QLatin1String("Bookmarks");
+}
+
+QKeySequence BookmarkViewFactory::activationSequence() const
 {
     return QKeySequence(Qt::ALT + Qt::Key_M);
 }
diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h
index 02c30368334..843bfe00335 100644
--- a/src/plugins/bookmarks/bookmarkmanager.h
+++ b/src/plugins/bookmarks/bookmarkmanager.h
@@ -169,9 +169,10 @@ class BookmarkViewFactory : public Core::INavigationWidgetFactory
 {
 public:
     BookmarkViewFactory(BookmarkManager *bm);
-    virtual QString displayName();
-    virtual QKeySequence activationSequence();
-    virtual Core::NavigationView createWidget();
+    QString displayName() const;
+    QString id() const;
+    QKeySequence activationSequence() const;
+    Core::NavigationView createWidget();
 private:
     BookmarkManager *m_manager;
 };
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
index d0d6d7262c2..3c9939de0b2 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
@@ -242,12 +242,17 @@ NavigationView OpenEditorsViewFactory::createWidget()
     return n;
 }
 
-QString OpenEditorsViewFactory::displayName()
+QString OpenEditorsViewFactory::displayName() const
 {
     return OpenEditorsWidget::tr("Open Documents");
 }
 
-QKeySequence OpenEditorsViewFactory::activationSequence()
+QString OpenEditorsViewFactory::id() const
+{
+    return QLatin1String("Open Documents");
+}
+
+QKeySequence OpenEditorsViewFactory::activationSequence() const
 {
     return QKeySequence(Qt::ALT + Qt::Key_O);
 }
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h
index 706b3d3637c..42a3a7459b6 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.h
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.h
@@ -88,9 +88,10 @@ class OpenEditorsViewFactory : public Core::INavigationWidgetFactory
 {
 public:
     OpenEditorsViewFactory();
-    virtual ~OpenEditorsViewFactory();
-    QString displayName();
-    virtual QKeySequence activationSequence();
+    ~OpenEditorsViewFactory();
+    QString displayName() const;
+    QString id() const;
+    QKeySequence activationSequence() const;
     Core::NavigationView createWidget();
 };
 
diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.cpp b/src/plugins/coreplugin/inavigationwidgetfactory.cpp
index 74cd93cde48..399107c5ea8 100644
--- a/src/plugins/coreplugin/inavigationwidgetfactory.cpp
+++ b/src/plugins/coreplugin/inavigationwidgetfactory.cpp
@@ -41,7 +41,7 @@ INavigationWidgetFactory::~INavigationWidgetFactory()
 {
 }
 
-QKeySequence INavigationWidgetFactory::activationSequence()
+QKeySequence INavigationWidgetFactory::activationSequence() const
 {
     return QKeySequence();
 }
diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.h b/src/plugins/coreplugin/inavigationwidgetfactory.h
index 25d2b71cafd..d148caafcf6 100644
--- a/src/plugins/coreplugin/inavigationwidgetfactory.h
+++ b/src/plugins/coreplugin/inavigationwidgetfactory.h
@@ -55,8 +55,9 @@ public:
     INavigationWidgetFactory();
     virtual ~INavigationWidgetFactory();
 
-    virtual QString displayName() = 0;
-    virtual QKeySequence activationSequence();
+    virtual QString displayName() 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
     // It could be implemented as returning an object which has both the widget 
     // and the docktoolbar widgets
diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp
index 9c43df4eb8d..8ba5e69fde5 100644
--- a/src/plugins/coreplugin/navigationwidget.cpp
+++ b/src/plugins/coreplugin/navigationwidget.cpp
@@ -199,15 +199,15 @@ void NavigationWidget::activateSubWidget()
 {
     setShown(true);
     QShortcut *original = qobject_cast<QShortcut *>(sender());
-    QString title = m_shortcutMap[original];
+    QString id = m_shortcutMap[original];
 
     foreach (NavigationSubWidget *subWidget, m_subWidgets)
-        if (subWidget->factory()->displayName() == title) {
+        if (subWidget->factory()->id() == id) {
             subWidget->setFocusWidget();
             return;
         }
 
-    m_subWidgets.first()->setFactory(title);
+    m_subWidgets.first()->setFactory(id);
     m_subWidgets.first()->setFocusWidget();
 }
 
@@ -237,7 +237,7 @@ void NavigationWidget::saveSettings(QSettings *settings)
 {
     QStringList views;
     for (int i=0; i<m_subWidgets.count(); ++i) {
-        views.append(m_subWidgets.at(i)->factory()->displayName());
+        views.append(m_subWidgets.at(i)->factory()->id());
     }
     settings->setValue("Navigation/Views", views);
     settings->setValue("Navigation/Visible", isShown());
@@ -349,16 +349,16 @@ void NavigationWidget::objectAdded(QObject * obj)
     QList<int> navicontext = QList<int>() << core->uniqueIDManager()->
         uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE);
 
-    QString displayName = factory->displayName();
+    QString id = factory->id();
     QShortcut *shortcut = new QShortcut(this);
-    shortcut->setWhatsThis(tr("Activate %1 Pane").arg(displayName));
+    shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
     Core::Command *cmd = am->registerShortcut(shortcut,
-        QLatin1String("QtCreator.Sidebar.") + displayName, navicontext);
+        QLatin1String("QtCreator.Sidebar.") + id, navicontext);
     cmd->setDefaultKeySequence(factory->activationSequence());
     connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
 
-    m_shortcutMap.insert(shortcut, displayName);
-    m_commandMap.insert(displayName, cmd);
+    m_shortcutMap.insert(shortcut, id);
+    m_commandMap.insert(id, cmd);
 }
 
 ////
@@ -486,12 +486,12 @@ void NavigationSubWidget::setFactory(INavigationWidgetFactory *factory)
     m_navigationComboBox->setCurrentIndex(index);
 }
 
-void NavigationSubWidget::setFactory(const QString &name)
+void NavigationSubWidget::setFactory(const QString &id)
 {
     for (int i = 0; i < m_navigationComboBox->count(); ++i) {
         INavigationWidgetFactory *factory =
                 m_navigationComboBox->itemData(i).value<INavigationWidgetFactory *>();
-        if (factory->displayName() == name)
+        if (factory->id() == id)
             m_navigationComboBox->setCurrentIndex(i);
     }
 }
diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h
index 7620c544554..f63e4264922 100644
--- a/src/plugins/coreplugin/navigationwidget.h
+++ b/src/plugins/coreplugin/navigationwidget.h
@@ -128,7 +128,7 @@ public:
 
     INavigationWidgetFactory *factory();
     void setFactory(INavigationWidgetFactory *factory);
-    void setFactory(const QString &name);
+    void setFactory(const QString &id);
     void setFocusWidget();
 
     void saveSettings(int position);
diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp
index 10f642e2d9a..49e8501528f 100644
--- a/src/plugins/coreplugin/outputpane.cpp
+++ b/src/plugins/coreplugin/outputpane.cpp
@@ -309,6 +309,7 @@ void OutputPaneManager::init()
 #else
     cmd->setDefaultKeySequence(QKeySequence("Alt+9"));
 #endif
+    cmd->setAttribute(Command::CA_UpdateText);
     mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
     m_minMaxButton->setDefaultAction(cmd->action());
     connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index 37b75635167..eb30b850bba 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -413,12 +413,17 @@ FolderNavigationWidgetFactory::~FolderNavigationWidgetFactory()
 {
 }
 
-QString FolderNavigationWidgetFactory::displayName()
+QString FolderNavigationWidgetFactory::displayName() const
 {
     return tr("File System");
 }
 
-QKeySequence FolderNavigationWidgetFactory::activationSequence()
+QString FolderNavigationWidgetFactory::id() const
+{
+    return QLatin1String("File System");
+}
+
+QKeySequence FolderNavigationWidgetFactory::activationSequence() const
 {
     return QKeySequence(Qt::ALT + Qt::Key_Y);
 }
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h
index 79f099d7cf8..cfb4f8870f2 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.h
+++ b/src/plugins/projectexplorer/foldernavigationwidget.h
@@ -97,11 +97,12 @@ class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
     Q_OBJECT
 public:
     FolderNavigationWidgetFactory();
-    virtual ~FolderNavigationWidgetFactory();
+    ~FolderNavigationWidgetFactory();
 
-    virtual QString displayName();
-    virtual QKeySequence activationSequence();
-    virtual Core::NavigationView createWidget();
+    QString displayName() const;
+    QString id() const;
+    QKeySequence activationSequence() const;
+    Core::NavigationView createWidget();
 };
 
 } // namespace Internal
diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp
index bd9e0b658f8..b89aba25132 100644
--- a/src/plugins/projectexplorer/projecttreewidget.cpp
+++ b/src/plugins/projectexplorer/projecttreewidget.cpp
@@ -365,12 +365,17 @@ ProjectTreeWidgetFactory::~ProjectTreeWidgetFactory()
 {
 }
 
-QString ProjectTreeWidgetFactory::displayName()
+QString ProjectTreeWidgetFactory::displayName() const
 {
     return tr("Projects");
 }
 
-QKeySequence ProjectTreeWidgetFactory::activationSequence()
+QString ProjectTreeWidgetFactory::id() const
+{
+    return QLatin1String("Projects");
+}
+
+QKeySequence ProjectTreeWidgetFactory::activationSequence() const
 {
     return QKeySequence(Qt::ALT + Qt::Key_X);
 }
diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h
index 2413bd95497..564a85de63d 100644
--- a/src/plugins/projectexplorer/projecttreewidget.h
+++ b/src/plugins/projectexplorer/projecttreewidget.h
@@ -98,10 +98,11 @@ class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory
     Q_OBJECT
 public:
     ProjectTreeWidgetFactory();
-    virtual ~ProjectTreeWidgetFactory();
-    virtual QString displayName();
-    virtual QKeySequence activationSequence();
-    virtual Core::NavigationView createWidget();
+    ~ProjectTreeWidgetFactory();
+    QString displayName() const;
+    QString id() const;
+    QKeySequence activationSequence() const;
+    Core::NavigationView createWidget();
     void restoreSettings(int position, QWidget *widget);
     void saveSettings(int position, QWidget *widget);
 };
-- 
GitLab