diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index fad1b3a2e4..273cbf7966 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -165,6 +165,28 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list) SelectiveSyncTreeViewItem *root = static_cast(topLevelItem(0)); + QUrl url = _account->davUrl(); + QString pathToRemove = url.path(); + if (!pathToRemove.endsWith('/')) { + pathToRemove.append('/'); + } + pathToRemove.append(_folderPath); + if (!_folderPath.isEmpty()) + pathToRemove.append('/'); + + // Since / cannot be in the blacklist, expand it to the actual + // list of top-level folders as soon as possible. + if (_oldBlackList == QStringList("/")) { + _oldBlackList.clear(); + foreach (QString path, list) { + path.remove(pathToRemove); + if (path.isEmpty()) { + continue; + } + _oldBlackList.append(path); + } + } + if (!root && list.size() <= 1) { _loading->setText(tr("No subfolders currently on the server.")); _loading->resize(_loading->sizeHint()); // because it's not in a layout @@ -185,15 +207,6 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list) } } - QUrl url = _account->davUrl(); - QString pathToRemove = url.path(); - if (!pathToRemove.endsWith('/')) { - pathToRemove.append('/'); - } - pathToRemove.append(_folderPath); - if (!_folderPath.isEmpty()) - pathToRemove.append('/'); - foreach (QString path, list) { auto size = job ? job->_sizes.value(path) : 0; path.remove(pathToRemove); @@ -325,6 +338,11 @@ QStringList SelectiveSyncTreeView::createBlackList(QTreeWidgetItem* root) const return result; } +QStringList SelectiveSyncTreeView::oldBlackList() const +{ + return _oldBlackList; +} + qint64 SelectiveSyncTreeView::estimatedSize(QTreeWidgetItem* root) { if (!root) { @@ -427,6 +445,11 @@ QStringList SelectiveSyncDialog::createBlackList() const return _treeView->createBlackList(); } +QStringList SelectiveSyncDialog::oldBlackList() const +{ + return _treeView->oldBlackList(); +} + qint64 SelectiveSyncDialog::estimatedSize() { return _treeView->estimatedSize(); diff --git a/src/gui/selectivesyncdialog.h b/src/gui/selectivesyncdialog.h index 15702d86e0..41b2a04aef 100644 --- a/src/gui/selectivesyncdialog.h +++ b/src/gui/selectivesyncdialog.h @@ -36,6 +36,7 @@ public: /// Returns a list of blacklisted paths, each including the trailing / QStringList createBlackList(QTreeWidgetItem* root = 0) const; + QStringList oldBlackList() const; //Estimate the total size of checked item (recursively) qint64 estimatedSize(QTreeWidgetItem *root = 0); @@ -77,6 +78,7 @@ public: virtual void accept() Q_DECL_OVERRIDE; QStringList createBlackList() const; + QStringList oldBlackList() const; // Estimate the size of the total of sync'ed files from the server qint64 estimatedSize(); diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index 5253e91696..a933761112 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -258,8 +258,24 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked() AccountPtr acc = static_cast(wizard())->account(); SelectiveSyncDialog *dlg = new SelectiveSyncDialog(acc, _remoteFolder, _selectiveSyncBlacklist, this); - if (dlg->exec() == QDialog::Accepted) { + + const int result = dlg->exec(); + bool updateBlacklist = false; + + // We need to update the selective sync blacklist either when the dialog + // was accepted, or when it was used in conjunction with the + // wizardSelectiveSyncDefaultNothing feature and was cancelled - in that + // case the stub blacklist of / was expanded to the actual list of top + // level folders by the selective sync dialog. + if (result == QDialog::Accepted) { _selectiveSyncBlacklist = dlg->createBlackList(); + updateBlacklist = true; + } else if (result == QDialog::Rejected && _selectiveSyncBlacklist == QStringList("/")) { + _selectiveSyncBlacklist = dlg->oldBlackList(); + updateBlacklist = true; + } + + if (updateBlacklist) { if (!_selectiveSyncBlacklist.isEmpty()) { _ui.rSelectiveSync->blockSignals(true); _ui.rSelectiveSync->setChecked(true);