From 0757139cb88c618ddb1ceb5e8bd76c6807fd028d Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Wed, 31 Mar 2010 10:09:34 +0200
Subject: [PATCH] Avoid multiple shows of same form editor info bar.

---
 src/plugins/designer/designerxmleditor.cpp | 18 ------------------
 src/plugins/designer/designerxmleditor.h   |  4 ----
 src/plugins/designer/formeditorfactory.cpp | 20 ++++++++++++++++++++
 src/plugins/designer/formeditorfactory.h   |  4 ++++
 4 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/plugins/designer/designerxmleditor.cpp b/src/plugins/designer/designerxmleditor.cpp
index d9f438b97cc..562d87ddc58 100644
--- a/src/plugins/designer/designerxmleditor.cpp
+++ b/src/plugins/designer/designerxmleditor.cpp
@@ -50,8 +50,6 @@ DesignerXmlEditor::DesignerXmlEditor(QDesignerFormWindowInterface *form,
     m_designerEditor(new FormWindowEditor(this, form))
 {
     setReadOnly(true);
-    connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
-             SLOT(updateEditorInfoBar(Core::IEditor*)));
 }
 
 TextEditor::BaseTextEditorEditable *DesignerXmlEditor::createEditableInterface()
@@ -61,22 +59,6 @@ TextEditor::BaseTextEditorEditable *DesignerXmlEditor::createEditableInterface()
     return m_designerEditor->textEditable();
 }
 
-void DesignerXmlEditor::updateEditorInfoBar(Core::IEditor *editor)
-{
-    if (editor == m_designerEditor) {
-        Core::EditorManager::instance()->showEditorInfoBar(Constants::INFO_READ_ONLY,
-            tr("This file can only be edited in Design Mode."),
-            tr("Open Designer"), this, SLOT(designerModeClicked()));
-    }
-    if (!editor)
-        Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_READ_ONLY);
-}
-
-void DesignerXmlEditor::designerModeClicked()
-{
-    Core::ICore::instance()->modeManager()->activateMode(QLatin1String(Core::Constants::MODE_DESIGN));
-}
-
 FormWindowEditor *DesignerXmlEditor::designerEditor() const
 {
     return m_designerEditor;
diff --git a/src/plugins/designer/designerxmleditor.h b/src/plugins/designer/designerxmleditor.h
index dcedcb808a6..e4671a9b4dc 100644
--- a/src/plugins/designer/designerxmleditor.h
+++ b/src/plugins/designer/designerxmleditor.h
@@ -58,10 +58,6 @@ public:
 
     FormWindowEditor *designerEditor() const;
 
-private slots:
-    void designerModeClicked();
-    void updateEditorInfoBar(Core::IEditor *editor);
-
 protected:
     virtual TextEditor::BaseTextEditorEditable *createEditableInterface();
 
diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp
index 042fd5c77bd..6b39e50fee8 100644
--- a/src/plugins/designer/formeditorfactory.cpp
+++ b/src/plugins/designer/formeditorfactory.cpp
@@ -34,9 +34,11 @@
 #include "designerconstants.h"
 #include "designerxmleditor.h"
 
+#include <coreplugin/coreconstants.h>
 #include <coreplugin/icore.h>
 #include <coreplugin/fileiconprovider.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/modemanager.h>
 
 #include <QtCore/QFileInfo>
 #include <QtCore/QDebug>
@@ -53,6 +55,8 @@ FormEditorFactory::FormEditorFactory()
     Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
     iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/formeditor/images/qt_ui.png")),
                                                QLatin1String("ui"));
+    connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
+             SLOT(updateEditorInfoBar(Core::IEditor*)));
 }
 
 QString FormEditorFactory::id() const
@@ -82,6 +86,22 @@ QStringList FormEditorFactory::mimeTypes() const
     return m_mimeTypes;
 }
 
+void FormEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
+{
+    if (qobject_cast<FormWindowEditor *>(editor)) {
+        Core::EditorManager::instance()->showEditorInfoBar(Constants::INFO_READ_ONLY,
+            tr("This file can only be edited in Design Mode."),
+            tr("Open Designer"), this, SLOT(designerModeClicked()));
+    } else {
+        Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_READ_ONLY);
+    }
+}
+
+void FormEditorFactory::designerModeClicked()
+{
+    Core::ICore::instance()->modeManager()->activateMode(QLatin1String(Core::Constants::MODE_DESIGN));
+}
+
 } // namespace Internal
 } // namespace Designer
 
diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h
index 75c0db8778c..d43fe4a2fb0 100644
--- a/src/plugins/designer/formeditorfactory.h
+++ b/src/plugins/designer/formeditorfactory.h
@@ -56,6 +56,10 @@ public:
     Core::IFile *open(const QString &fileName);
     Core::IEditor *createEditor(QWidget *parent);
 
+private slots:
+    void designerModeClicked();
+    void updateEditorInfoBar(Core::IEditor *editor);
+
 private:
     const QStringList m_mimeTypes;
 };
-- 
GitLab