changeset 542:7829da6abe97 fswatcher

Provide all tracked files to the fs watcher, so now we get updates properly -- requires moving the "what should we display?" logic for show-all-files toggle from main window to file status widget, but it's probably better there anyway
author Chris Cannam
date Tue, 14 Feb 2012 16:48:01 +0000
parents 0a16db274f2c
children a220f99f1134
files src/filestatuswidget.cpp src/filestatuswidget.h src/fswatcher.cpp src/fswatcher.h src/mainwindow.cpp
diffstat 5 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/filestatuswidget.cpp	Tue Feb 14 16:17:23 2012 +0000
+++ b/src/filestatuswidget.cpp	Tue Feb 14 16:48:01 2012 +0000
@@ -178,6 +178,13 @@
     return m_showAllFiles->isChecked();
 }
 
+bool FileStatusWidget::shouldShow(FileStates::State s) const
+{
+    if (shouldShowAll()) return true;
+    else return (s != FileStates::Clean &&
+                 s != FileStates::Ignored);
+}
+
 QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation)
 {
     QSettings settings;
@@ -193,11 +200,9 @@
                 .arg(m_simpleLabels[s])
                 .arg(m_descriptions[s]);
         }
-    } else {
-        return QString("<qt><b>%1</b></qt>")
-            .arg(m_simpleLabels[s]);
     }
-    settings.endGroup();
+    return QString("<qt><b>%1</b></qt>")
+        .arg(m_simpleLabels[s]);
 }
 
 void FileStatusWidget::setNoModificationsLabelText()
@@ -425,6 +430,12 @@
 
         QListWidget *w = m_stateListMap[s];
         w->clear();
+
+        if (!shouldShow(s)) {
+            w->parentWidget()->hide();
+            continue;
+        }
+
         QStringList files = m_fileStates.filesInState(s);
 
         QStringList highPriority, lowPriority;
--- a/src/filestatuswidget.h	Tue Feb 14 16:17:23 2012 +0000
+++ b/src/filestatuswidget.h	Tue Feb 14 16:48:01 2012 +0000
@@ -55,6 +55,7 @@
     QStringList getSelectedRemovableFiles() const;
 
     bool shouldShowAll() const;
+    bool shouldShow(FileStates::State) const;
 
 signals:
     void selectionChanged();
--- a/src/fswatcher.cpp	Tue Feb 14 16:17:23 2012 +0000
+++ b/src/fswatcher.cpp	Tue Feb 14 16:48:01 2012 +0000
@@ -82,6 +82,7 @@
 	QSet<QString>::fromList(m_watcher.files());
 
     foreach (QString path, paths) {
+        path = m_workDirPath + QDir::separator() + path;
         if (!alreadyWatched.contains(path)) {
             m_watcher.addPath(path);
         } else {
--- a/src/fswatcher.h	Tue Feb 14 16:17:23 2012 +0000
+++ b/src/fswatcher.h	Tue Feb 14 16:48:01 2012 +0000
@@ -49,7 +49,8 @@
 
     /**
      * Provide a set of paths for files which should be tracked. These
-     * will be the only non-directory files monitored for changes.
+     * will be the only non-directory files monitored for changes. The
+     * paths should be relative to the work directory.
      */
     void setTrackedFilePaths(QStringList paths);
     
--- a/src/mainwindow.cpp	Tue Feb 14 16:17:23 2012 +0000
+++ b/src/mainwindow.cpp	Tue Feb 14 16:48:01 2012 +0000
@@ -122,7 +122,6 @@
     setUnifiedTitleAndToolBarOnMac(true);
     connectActions();
     clearState();
-    updateFsWatcher();
     enableDisableActions();
 
     if (m_firstStart) {
@@ -254,11 +253,9 @@
 {
     QStringList params;
 
-    if (m_showAllFiles) {
-        params << "stat" << "-A";
-    } else {
-        params << "stat" << "-ardum";
-    }
+    // We always stat all files, regardless of whether we're showing
+    // them all, because we need them for the filesystem monitor
+    params << "stat" << "-A";
 
     m_lastStatOutput = "";
 
@@ -1429,7 +1426,6 @@
             if (result) {
                 enableDisableActions();
                 clearState();
-                updateFsWatcher();
                 hgQueryPaths();
                 done = true;
             }
@@ -1515,7 +1511,6 @@
     if (openLocal(local)) {
         enableDisableActions();
         clearState();
-        updateFsWatcher();
         hgQueryPaths();
     }
 }