[Pkg-owncloud-commits] [owncloud-client] 142/498: Confirm feature: The UI part in the selective sync view

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit cc3543dbd2c518abbc9c453d0812ba1aca92c380
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu Jun 11 15:46:01 2015 +0200

    Confirm feature: The UI part in the selective sync view
    
    Folder that are over the threshold will appear in red in the
    selective sync view and will be deselected by default
---
 src/gui/folder.cpp             | 32 ++++++++++++++++++++++++++++++++
 src/gui/folder.h               |  2 ++
 src/gui/folderstatusmodel.cpp  | 36 ++++++++++++++++++++++++++++++++----
 src/gui/folderstatusmodel.h    |  5 +++--
 src/libsync/discoveryphase.cpp |  1 +
 5 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 23974cd..3ac5dd6 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -814,6 +814,7 @@ void Folder::startSync(const QStringList &pathList)
     connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
     connect(_engine.data(), SIGNAL(jobCompleted(const SyncFileItem &)), this, SLOT(slotJobCompleted(const SyncFileItem &)));
     connect(_engine.data(), SIGNAL(syncItemDiscovered(const SyncFileItem &)), this, SLOT(slotSyncItemDiscovered(const SyncFileItem &)));
+    connect(_engine.data(), SIGNAL(newSharedFolder(QString)), this, SLOT(slotNewSharedBigFolderDiscovered(QString)));
 
     setDirtyNetworkLimits();
 
@@ -914,6 +915,11 @@ void Folder::slotSyncFinished()
         qDebug() << "the last" << _consecutiveFailingSyncs << "syncs failed";
     }
 
+    if (_syncResult.status() == SyncResult::Success) {
+        // Clear the white list as all the folder that should be on that list are sync-ed
+        journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, QStringList());
+    }
+
     emit syncStateChange();
 
     // The syncFinished result that is to be triggered here makes the folderman
@@ -993,6 +999,32 @@ void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
     emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item);
 }
 
+void Folder::slotNewSharedBigFolderDiscovered(const QString &newF)
+{
+    auto newFolder = newF;
+    if (!newFolder.endsWith(QLatin1Char('/'))) {
+        newFolder += QLatin1Char('/');
+    }
+    auto journal = journalDb();
+
+    // Add the entry to the blacklist if it is neither in the blacklist or whitelist already
+    auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
+    auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
+    if (!blacklist.contains(newFolder) && !whitelist.contains(newFolder)) {
+        blacklist.append(newFolder);
+        journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blacklist);
+    }
+
+    // And add the entry to the undecided list and signal the UI
+    auto undecidedList = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
+    if (!undecidedList.contains(newFolder)) {
+        undecidedList.append(newFolder);
+        journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
+        emit newSharedBigFolderDiscovered();
+    }
+}
+
+
 
 void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
 {
diff --git a/src/gui/folder.h b/src/gui/folder.h
index f5a4f62..bac74d6 100644
--- a/src/gui/folder.h
+++ b/src/gui/folder.h
@@ -174,6 +174,7 @@ signals:
     void syncFinished(const SyncResult &result);
     void scheduleToSync(Folder*);
     void progressInfo(const ProgressInfo& progress);
+    void newSharedBigFolderDiscovered(); // A new folder bigger than the threshold was discovered
 
 public slots:
 
@@ -228,6 +229,7 @@ private slots:
     void slotEmitFinishedDelayed();
 
     void watcherSlot(QString);
+    void slotNewSharedBigFolderDiscovered(const QString &);
 
 private:
     bool init();
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 98d64fa..fb6bae7 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -102,6 +102,11 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
             return x._checked;
         case Qt::DecorationRole:
             return QFileIconProvider().icon(QFileIconProvider::Folder);
+        case Qt::ForegroundRole:
+            if (x._isUndecided) {
+                return QColor(Qt::red);
+            }
+            break;
         }
     }
         return QVariant();
@@ -399,6 +404,12 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
     parentInfo->_fetched = true;
     parentInfo->_fetching = false;
 
+    QStringList selectiveSyncBlackList;
+    if (parentInfo->_checked == Qt::PartiallyChecked) {
+        selectiveSyncBlackList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
+    }
+    auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
+
     int i = 0;
     foreach (QString path, list) {
         SubFolderInfo newInfo;
@@ -416,9 +427,10 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
 
         if (parentInfo->_checked == Qt::Unchecked) {
             newInfo._checked = Qt::Unchecked;
+        } else if (parentInfo->_checked == Qt::Checked) {
+            newInfo._checked = Qt::Checked;
         } else {
-            auto *f = _folders.at(parentInfo->_pathIdx.first())._folder;
-            foreach(const QString &str , f->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList)) {
+            foreach(const QString &str , selectiveSyncBlackList) {
                 if (str == path || str == QLatin1String("/")) {
                     newInfo._checked = Qt::Unchecked;
                     break;
@@ -427,6 +439,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
                 }
             }
         }
+        newInfo._isUndecided = selectiveSyncUndecidedList.contains(path);
         parentInfo->_subs.append(newInfo);
     }
 
@@ -512,7 +525,22 @@ void FolderStatusModel::slotApplySelectiveSync()
         QStringList blackList = createBlackList(&_folders[i], oldBlackList);
         folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
 
-        FolderMan *folderMan = FolderMan::instance();
+        // The folders that were undecided should be part of the white list if they are not in the blacklist
+        QStringList toAddToWhiteList;
+        foreach (const auto &undec, folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList)) {
+            if (!blackList.contains(undec)) {
+                toAddToWhiteList.append(undec);
+            }
+        }
+        if (!toAddToWhiteList.isEmpty()) {
+            auto whiteList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
+            whiteList += toAddToWhiteList;
+            folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, whiteList);
+        }
+        // clear the undecided list
+        folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList());
+
+        // do the sync if there was changes
         auto blackListSet = blackList.toSet();
         auto oldBlackListSet = oldBlackList.toSet();
         auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet);
@@ -525,7 +553,7 @@ void FolderStatusModel::slotApplySelectiveSync()
             foreach(const auto &it, changes) {
                 folder->journalDb()->avoidReadFromDbOnNextSync(it);
             }
-            folderMan->slotScheduleSync(folder);
+            FolderMan::instance()->slotScheduleSync(folder);
         }
     }
 
diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h
index 8989fc9..cb9a865 100644
--- a/src/gui/folderstatusmodel.h
+++ b/src/gui/folderstatusmodel.h
@@ -46,15 +46,16 @@ public:
 
 
     struct SubFolderInfo {
+        Folder *_folder = nullptr;
         QString _name;
         QString _path;
         QVector<int> _pathIdx;
+        QVector<SubFolderInfo> _subs;
         int _size = 0;
         bool _fetched = false; // If we did the LSCOL for this folder already
         bool _fetching = false;
-        QVector<SubFolderInfo> _subs;
+        bool _isUndecided = false; // undecided folder are the big folder that the user has not accepted yet
         Qt::CheckState _checked = Qt::Checked;
-        Folder *_folder;
 
         struct Progress {
             bool isNull() const
diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp
index 096107a..8048b83 100644
--- a/src/libsync/discoveryphase.cpp
+++ b/src/libsync/discoveryphase.cpp
@@ -587,6 +587,7 @@ void DiscoveryJob::remote_vio_closedir_hook (csync_vio_handle_t *dhandle,  void
 
 void DiscoveryJob::start() {
     _selectiveSyncBlackList.sort();
+    _selectiveSyncWhiteList.sort();
     _csync_ctx->callbacks.update_callback_userdata = this;
     _csync_ctx->callbacks.update_callback = update_job_update_callback;
     _csync_ctx->callbacks.checkSelectiveSyncBlackListHook = isInSelectiveSyncBlackListCallback;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list