diff src/filestatuswidget.cpp @ 555:a1d210c767ab find

Implement basic search function in both work and history tabs
author Chris Cannam
date Wed, 22 Feb 2012 14:54:30 +0000
parents 7829da6abe97
children 57a7f95ef400
line wrap: on
line diff
--- a/src/filestatuswidget.cpp	Mon Feb 20 18:15:53 2012 +0000
+++ b/src/filestatuswidget.cpp	Wed Feb 22 14:54:30 2012 +0000
@@ -413,6 +413,14 @@
 }
 
 void
+FileStatusWidget::setSearchText(QString text)
+{
+    if (m_searchText == text) return;
+    m_searchText = text;
+    updateWidgets();
+}
+
+void
 FileStatusWidget::updateWidgets()
 {
     QDateTime lastInteractionTime;
@@ -425,6 +433,7 @@
     foreach (QString f, m_selectedFiles) selectedFiles.insert(f);
 
     int visibleCount = 0;
+    bool finding = (m_searchText != "");
 
     foreach (FileStates::State s, m_stateListMap.keys()) {
 
@@ -442,6 +451,13 @@
 
         foreach (QString file, files) {
 
+            if (finding) {
+                if (file.contains(m_searchText, Qt::CaseInsensitive)) {
+                    highPriority.push_back(file);
+                }
+                continue;
+            }
+
             bool highlighted = false;
 
             if (s == FileStates::Unknown) {
@@ -467,7 +483,11 @@
         foreach (QString file, highPriority) {
             QListWidgetItem *item = new QListWidgetItem(file);
             w->addItem(item);
-            item->setForeground(QColor("#d40000"));
+            if (finding) {
+                item->setForeground(QColor("#008400"));
+            } else {
+                item->setForeground(QColor("#d40000"));
+            }                
             item->setSelected(selectedFiles.contains(file));
         }