From 2deb73536727648b34e1f4c880a1c069e4c98875 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Thu, 5 Mar 2009 12:30:10 +0100
Subject: [PATCH] Fixes:    fakevim/editorview: move the 'minibuffer' to the
 bottom of the editor

---
 .../editormanager/editormanager.cpp           | 14 ++++
 .../coreplugin/editormanager/editormanager.h  |  7 ++
 .../coreplugin/editormanager/editorview.cpp   | 65 +++++++++++++++++--
 .../coreplugin/editormanager/editorview.h     | 11 +++-
 src/plugins/fakevim/fakevimplugin.cpp         |  6 +-
 5 files changed, 93 insertions(+), 10 deletions(-)

diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index e742a7df477..76a49f54f40 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1581,6 +1581,20 @@ void EditorManager::hideEditorInfoBar(const QString &kind)
     currentEditorView()->hideEditorInfoBar(kind);
 }
 
+void EditorManager::showEditorStatusBar(const QString &kind,
+                                      const QString &infoText,
+                                      const QString &buttonText,
+                                      QObject *object, const char *member)
+{
+
+    currentEditorView()->showEditorStatusBar(kind, infoText, buttonText, object, member);
+}
+
+void EditorManager::hideEditorStatusBar(const QString &kind)
+{
+    currentEditorView()->hideEditorStatusBar(kind);
+}
+
 QString EditorManager::externalEditorHelpText() const
 {
     QString help = tr(
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index d4ed4b31bde..1d03906bfd0 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -157,6 +157,13 @@ public:
 
     void hideEditorInfoBar(const QString &kind);
 
+    void showEditorStatusBar(const QString &kind,
+                           const QString &infoText,
+                           const QString &buttonText = QString(),
+                           QObject *object = 0, const char *member = 0);
+
+    void hideEditorStatusBar(const QString &kind);
+
     EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true) const;
 
     void setExternalEditor(const QString &);
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index eb960197bcb..020cb200ff3 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -207,6 +207,7 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) :
     m_lockButton(new QToolButton),
     m_defaultToolBar(new QToolBar(this)),
     m_infoWidget(new QFrame(this)),
+    m_statusWidget(new QFrame(this)),
     m_editorForInfoWidget(0)
 {
     QVBoxLayout *tl = new QVBoxLayout(this);
@@ -269,7 +270,6 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) :
         m_infoWidget->setBackgroundRole(QPalette::ToolTipBase);
         m_infoWidget->setAutoFillBackground(true);
 
-
         QHBoxLayout *hbox = new QHBoxLayout(m_infoWidget);
         hbox->setMargin(2);
         m_infoWidgetLabel = new QLabel("Placeholder");
@@ -289,12 +289,47 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) :
 
         hbox->addWidget(closeButton);
 
-
         m_infoWidget->setVisible(false);
         tl->addWidget(m_infoWidget);
     }
+
     tl->addWidget(m_container);
 
+    {
+        m_statusWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
+        m_statusWidget->setLineWidth(1);
+        m_statusWidget->setForegroundRole(QPalette::ToolTipText);
+        m_statusWidget->setBackgroundRole(QPalette::ToolTipBase);
+        m_statusWidget->setAutoFillBackground(true);
+
+
+        QHBoxLayout *hbox = new QHBoxLayout(m_statusWidget);
+        hbox->setMargin(2);
+        m_statusWidgetLabel = new QLabel("Placeholder");
+        m_statusWidgetLabel->setForegroundRole(QPalette::ToolTipText);
+        hbox->addWidget(m_statusWidgetLabel);
+        hbox->addStretch(1);
+
+        m_statusWidgetButton = new QToolButton;
+        m_statusWidgetButton->setText(tr("Placeholder"));
+        hbox->addWidget(m_statusWidgetButton);
+
+        QToolButton *closeButton = new QToolButton;
+        closeButton->setAutoRaise(true);
+        closeButton->setIcon(QIcon(":/core/images/clear.png"));
+        closeButton->setToolTip(tr("Close"));
+        connect(closeButton, SIGNAL(clicked()), m_statusWidget, SLOT(hide()));
+
+        hbox->addWidget(closeButton);
+
+        m_statusWidget->setVisible(false);
+        tl->addWidget(m_statusWidget);
+    }
+
+}
+
+EditorView::~EditorView()
+{
 }
 
 void EditorView::showEditorInfoBar(const QString &kind,
@@ -318,9 +353,25 @@ void EditorView::hideEditorInfoBar(const QString &kind)
         m_infoWidget->setVisible(false);
 }
 
+void EditorView::showEditorStatusBar(const QString &kind,
+                                           const QString &infoText,
+                                           const QString &buttonText,
+                                           QObject *object, const char *member)
+{
+    m_statusWidgetKind = kind;
+    m_statusWidgetLabel->setText(infoText);
+    m_statusWidgetButton->setText(buttonText);
+    m_statusWidgetButton->disconnect();
+    if (object && member)
+        connect(m_infoWidgetButton, SIGNAL(clicked()), object, member);
+    m_statusWidget->setVisible(true);
+    //m_editorForInfoWidget = currentEditor();
+}
 
-EditorView::~EditorView()
+void EditorView::hideEditorStatusBar(const QString &kind)
 {
+    if (kind == m_statusWidgetKind)
+        m_statusWidget->setVisible(false);
 }
 
 void EditorView::addEditor(IEditor *editor)
@@ -406,7 +457,7 @@ void EditorView::setCurrentEditor(IEditor *editor)
     updateEditorStatus(editor);
     updateToolBar(editor);
 
-
+    // FIXME: this keeps the editor hidden if switching from A to B and back
     if (editor != m_editorForInfoWidget) {
         m_infoWidget->hide();
         m_editorForInfoWidget = 0;
@@ -415,9 +466,9 @@ void EditorView::setCurrentEditor(IEditor *editor)
 
 void EditorView::checkEditorStatus()
 {
-        IEditor *editor = qobject_cast<IEditor *>(sender());
-        if (editor == currentEditor())
-            updateEditorStatus(editor);
+    IEditor *editor = qobject_cast<IEditor *>(sender());
+    if (editor == currentEditor())
+        updateEditorStatus(editor);
 }
 
 void EditorView::updateEditorStatus(IEditor *editor)
diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h
index 7204d966d81..e6f7472d0d7 100644
--- a/src/plugins/coreplugin/editormanager/editorview.h
+++ b/src/plugins/coreplugin/editormanager/editorview.h
@@ -113,6 +113,11 @@ public:
                            QObject *object, const char *member);
     void hideEditorInfoBar(const QString &kind);
 
+    void showEditorStatusBar(const QString &kind,
+                           const QString &infoText,
+                           const QString &buttonText,
+                           QObject *object, const char *member);
+    void hideEditorStatusBar(const QString &kind);
 
 public slots:
     void closeView();
@@ -139,8 +144,12 @@ private:
     QLabel *m_infoWidgetLabel;
     QToolButton *m_infoWidgetButton;
     IEditor *m_editorForInfoWidget;
+    QString m_statusWidgetKind;
+    QFrame *m_statusWidget;
+    QLabel *m_statusWidgetLabel;
+    QToolButton *m_statusWidgetButton;
     QSortFilterProxyModel m_proxyModel;
-    QList<IEditor *>m_editors;
+    QList<IEditor *> m_editors;
     QMap<QWidget *, IEditor *> m_widgetEditorMap;
 };
 
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index f2ac9977c5b..876e298e289 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -357,12 +357,14 @@ void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
 
 void FakeVimPluginPrivate::showCommandBuffer(const QString &contents)
 {
-    //qDebug() << "SHOW COMMAND BUFFER" << contents;
     FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
     if (handler) {
-        Core::EditorManager::instance()->showEditorInfoBar( 
+        //qDebug() << "SHOW COMMAND BUFFER" << contents;
+        Core::EditorManager::instance()->showEditorStatusBar( 
             QLatin1String(Constants::MINI_BUFFER), contents,
             tr("Quit FakeVim"), handler, SLOT(quit()));
+    } else {
+        qDebug() << "\nNO HANDLER\n";
     }
 }
 
-- 
GitLab