]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Selective sync: Sort folders in FolderStatusModel #4612
authorChristian Kamm <mail@ckamm.de>
Thu, 28 Apr 2016 07:18:38 +0000 (09:18 +0200)
committerChristian Kamm <mail@ckamm.de>
Thu, 28 Apr 2016 07:29:07 +0000 (09:29 +0200)
src/gui/folderstatusmodel.cpp
src/gui/selectivesyncdialog.cpp

index 55f35b43b2754eb9a1aadd1fdbd435e1b52b6c12..746708b1517fcbeda4375dce56124a7add389167 100644 (file)
@@ -574,9 +574,6 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
         return;
     }
 
-    QVarLengthArray<int, 10> undecidedIndexes;
-    QVector<SubFolderInfo> newSubs;
-
     std::set<QString> selectiveSyncUndecidedSet; // not QSet because it's not sorted
     foreach (const QString &str, selectiveSyncUndecidedList) {
         if (str.startsWith(parentInfo->_path) || parentInfo->_path == QLatin1String("/")) {
@@ -584,10 +581,16 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
         }
     }
 
-    newSubs.reserve(list.size() - 1);
-    for (int i = 1;  // skip the parent item (first in the list)
-            i < list.size(); ++i) {
-        const QString &path = list.at(i);
+    QStringList sortedSubfolders = list;
+    // skip the parent item (first in the list)
+    sortedSubfolders.erase(sortedSubfolders.begin());
+    sortedSubfolders.sort();
+
+    QVarLengthArray<int, 10> undecidedIndexes;
+
+    QVector<SubFolderInfo> newSubs;
+    newSubs.reserve(sortedSubfolders.size());
+    foreach (const QString& path, sortedSubfolders) {
         auto relativePath = path.mid(pathToRemove.size());
         if (parentInfo->_folder->isFileExcludedRelative(relativePath)) {
             continue;
index abc98181720337e9f10c2e919e36cbb1814636e7..b3e6203d1f72899d0dcca7f72898daafc85c32b5 100644 (file)
@@ -222,6 +222,7 @@ void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
         }
     }
 
+    list.sort();
     foreach (QString path, list) {
         auto size = job ? job->_sizes.value(path) : 0;
         path.remove(pathToRemove);