FolderModel: Refresh the tree when new folder are added or removed. #3570
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 17 Aug 2015 10:46:24 +0000 (12:46 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Mon, 17 Aug 2015 10:50:22 +0000 (12:50 +0200)
src/gui/folderstatusmodel.cpp

index da41de0ba3348615553c65b25829e361acb86b1b..3e13c54343f5e10b7265a6d4d03bf041bc702c95 100644 (file)
@@ -797,6 +797,23 @@ void FolderStatusModel::slotFolderSyncStateChange()
 
     // update the icon etc. now
     slotUpdateFolderState(f);
+
+    if (state == SyncResult::Success) {
+        foreach (const SyncFileItemPtr &i, f->syncResult().syncFileItemVector()) {
+            if (i->_isDirectory && (i->_instruction == CSYNC_INSTRUCTION_NEW
+                    || i->_instruction == CSYNC_INSTRUCTION_REMOVE)) {
+                // There is a new or a removed folder. reset all data
+                _folders[folderIndex]._fetched = false;
+                _folders[folderIndex]._fetching = false;
+                if (!_folders.at(folderIndex)._subs.isEmpty()) {
+                    beginRemoveRows(index(folderIndex), 0, _folders.at(folderIndex)._subs.count() - 1);
+                    _folders[folderIndex]._subs.clear();
+                    endRemoveRows();
+                }
+                return;
+            }
+        }
+    }
 }
 
 void FolderStatusModel::resetFolders()