From cc48ee0ab63de4d5135f0ba459bc9778db87b9db Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Thu, 22 Jul 2010 13:02:47 +0200
Subject: [PATCH] Outline: Disable filter button if no filters are available

Fixes that the filter button could be 'checked' for a cpp file.
---
 src/plugins/texteditor/outlinefactory.cpp | 4 +++-
 src/plugins/texteditor/outlinefactory.h   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/plugins/texteditor/outlinefactory.cpp b/src/plugins/texteditor/outlinefactory.cpp
index 72a32f1c082..e2542ee9536 100644
--- a/src/plugins/texteditor/outlinefactory.cpp
+++ b/src/plugins/texteditor/outlinefactory.cpp
@@ -39,7 +39,6 @@ OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
     m_filterButton->setPopupMode(QToolButton::InstantPopup);
     m_filterMenu = new QMenu(m_filterButton);
     m_filterButton->setMenu(m_filterMenu);
-    connect(m_filterMenu, SIGNAL(aboutToShow()), this, SLOT(updateFilterMenu()));
 
     Core::EditorManager *editorManager = Core::EditorManager::instance();
     connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
@@ -108,6 +107,7 @@ void OutlineWidgetStack::updateFilterMenu()
             m_filterMenu->addAction(filterAction);
         }
     }
+    m_filterButton->setEnabled(!m_filterMenu->actions().isEmpty());
 }
 
 void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
@@ -138,6 +138,8 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
             addWidget(newWidget);
             setCurrentWidget(newWidget);
         }
+
+        updateFilterMenu();
     }
 }
 
diff --git a/src/plugins/texteditor/outlinefactory.h b/src/plugins/texteditor/outlinefactory.h
index 3614b932998..e14e0c29fc8 100644
--- a/src/plugins/texteditor/outlinefactory.h
+++ b/src/plugins/texteditor/outlinefactory.h
@@ -31,10 +31,10 @@ public:
 private:
     bool isCursorSynchronized() const;
     QWidget *dummyWidget() const;
+    void updateFilterMenu();
 
 private slots:
     void toggleCursorSynchronization();
-    void updateFilterMenu();
     void updateCurrentEditor(Core::IEditor *editor);
 
 private:
-- 
GitLab