Selective sync ui: Fix #2390

This commit is contained in:
Christian Kamm 2014-10-24 15:46:35 +02:00
parent 86e13ea06f
commit 1c4072e231
2 changed files with 9 additions and 2 deletions

View file

@ -81,7 +81,7 @@ void SelectiveSyncTreeView::recursiveInsert(QTreeWidgetItem* parent, QStringList
|| parent->checkState(0) == Qt::PartiallyChecked) { || parent->checkState(0) == Qt::PartiallyChecked) {
item->setCheckState(0, Qt::Checked); item->setCheckState(0, Qt::Checked);
foreach(const QString &str , _oldBlackList) { foreach(const QString &str , _oldBlackList) {
if (str + "/" == path) { if (str == path) {
item->setCheckState(0, Qt::Unchecked); item->setCheckState(0, Qt::Unchecked);
break; break;
} else if (str.startsWith(path)) { } else if (str.startsWith(path)) {
@ -137,6 +137,9 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
if (paths.last().isEmpty()) paths.removeLast(); if (paths.last().isEmpty()) paths.removeLast();
if (paths.isEmpty()) if (paths.isEmpty())
continue; continue;
if (!path.endsWith('/')) {
path.append('/');
}
recursiveInsert(root, paths, path); recursiveInsert(root, paths, path);
} }
root->setExpanded(true); root->setExpanded(true);
@ -223,7 +226,7 @@ QStringList SelectiveSyncTreeView::createBlackList(QTreeWidgetItem* root) const
switch(root->checkState(0)) { switch(root->checkState(0)) {
case Qt::Unchecked: case Qt::Unchecked:
return QStringList(root->data(0, Qt::UserRole).toString()); return QStringList(root->data(0, Qt::UserRole).toString() + "/");
case Qt::Checked: case Qt::Checked:
return QStringList(); return QStringList();
case Qt::PartiallyChecked: case Qt::PartiallyChecked:

View file

@ -29,8 +29,12 @@ class SelectiveSyncTreeView : public QTreeWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit SelectiveSyncTreeView(Account *account, QWidget* parent = 0); explicit SelectiveSyncTreeView(Account *account, QWidget* parent = 0);
/// Returns a list of blacklisted paths, each including the trailing /
QStringList createBlackList(QTreeWidgetItem* root = 0) const; QStringList createBlackList(QTreeWidgetItem* root = 0) const;
void refreshFolders(); void refreshFolders();
// oldBlackList is a list of excluded paths, each including a trailing /
void setFolderInfo(const QString &folderPath, const QString &rootName, void setFolderInfo(const QString &folderPath, const QString &rootName,
const QStringList &oldBlackList = QStringList()) { const QStringList &oldBlackList = QStringList()) {
_folderPath = folderPath; _folderPath = folderPath;