changeset 557:57a7f95ef400 find

Make find widget behave as if text is cleared when it's closed, and restored when it's opened again
author Chris Cannam
date Thu, 23 Feb 2012 15:28:29 +0000
parents 04f18b2a32e8
children d932ce55c364
files src/filestatuswidget.cpp src/findwidget.cpp
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/filestatuswidget.cpp	Thu Feb 23 11:44:50 2012 +0000
+++ b/src/filestatuswidget.cpp	Thu Feb 23 15:28:29 2012 +0000
@@ -446,6 +446,7 @@
         }
 
         QStringList files = m_fileStates.filesInState(s);
+        bool foundSomething = false;
 
         QStringList highPriority, lowPriority;
 
@@ -454,8 +455,11 @@
             if (finding) {
                 if (file.contains(m_searchText, Qt::CaseInsensitive)) {
                     highPriority.push_back(file);
+                    foundSomething = true;
                 }
                 continue;
+            } else {
+                foundSomething = true;
             }
 
             bool highlighted = false;
@@ -499,7 +503,7 @@
 
         setLabelFor(w, s, !highPriority.empty());
 
-        if (files.empty()) {
+        if (!foundSomething) {
             w->parentWidget()->hide();
         } else {
             w->parentWidget()->show();
--- a/src/findwidget.cpp	Thu Feb 23 11:44:50 2012 +0000
+++ b/src/findwidget.cpp	Thu Feb 23 15:28:29 2012 +0000
@@ -61,9 +61,15 @@
     if (m_lineEdit->isVisible()) {
 	m_lineEdit->hide();
 	button->setText(tr("Find..."));
+        if (m_lineEdit->text() != "") {
+            emit findTextChanged("");
+        }
     } else {
 	m_lineEdit->show();
 	button->setText(tr("Find:"));
+        if (m_lineEdit->text() != "") {
+            emit findTextChanged(m_lineEdit->text());
+        }
     }
 }