Theme: Fix wizardSelectiveSyncDefaultNothing #3671

This commit is contained in:
Christian Kamm 2015-08-24 12:52:41 +02:00
parent ce233105b6
commit 6cf1caeaf3
3 changed files with 51 additions and 10 deletions

View File

@ -165,6 +165,28 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
SelectiveSyncTreeViewItem *root = static_cast<SelectiveSyncTreeViewItem*>(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();

View File

@ -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();

View File

@ -258,8 +258,24 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
AccountPtr acc = static_cast<OwncloudWizard *>(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);