Skip to content

Commit

Permalink
Bugfix for not usable source selection with empty include&exclude lists
Browse files Browse the repository at this point in the history
It seems the root item gets locked, can't get expanded or collapsed. So it
needs to be expanded on creation otherwise it remains collapsed and can't be
expanded by user. Useless.
Also clean up code a bit for the logic to expand to show selected folders.
  • Loading branch information
spersson committed Dec 19, 2015
1 parent ea288d1 commit 51c132d
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions kcm/backupplanwidget.cpp
Expand Up @@ -100,6 +100,7 @@ FolderSelectionWidget::FolderSelectionWidget(FolderSelectionModel *pModel, QWidg
ConfigExcludeDummy *lExcludeDummy = new ConfigExcludeDummy(mModel, this);
lExcludeDummy->setObjectName(QStringLiteral("kcfg_Paths excluded"));
setHeaderHidden(true);
expand(mModel->index(QStringLiteral("/"))); // always expand the root, prevents problem with empty include&exclude lists.
}

void FolderSelectionWidget::setHiddenFoldersVisible(bool pVisible) {
Expand All @@ -113,27 +114,21 @@ void FolderSelectionWidget::setHiddenFoldersVisible(bool pVisible) {

void FolderSelectionWidget::expandToShowSelections() {
foreach(const QString& lFolder, mModel->includedFolders() + mModel->excludedFolders()) {
if(!mModel->hiddenFoldersVisible()) {
QFileInfo lFolderInfo(lFolder);
bool lShouldAbort = false;
forever {
if(lFolderInfo.isHidden()) {
lShouldAbort = true; // skip if this folder should not be shown.
break;
} else if(lFolderInfo.absolutePath() == QStringLiteral("/")) {
break;
}
lFolderInfo = lFolderInfo.absolutePath();
}
if(lShouldAbort) {
continue;
QFileInfo lFolderInfo(lFolder);
bool lShouldBeShown = true;
while(lFolderInfo.absoluteFilePath() != QStringLiteral("/")) {
if(lFolderInfo.isHidden() && !mModel->hiddenFoldersVisible()) {
lShouldBeShown = false; // skip if this folder should not be shown.
break;
}
lFolderInfo = lFolderInfo.absolutePath(); // move up one level
}

QModelIndex lIndex = mModel->index(lFolder).parent();
while(lIndex.isValid()) {
expand(lIndex);
lIndex = lIndex.parent();
if(lShouldBeShown) {
QModelIndex lIndex = mModel->index(lFolder).parent();
while(lIndex.isValid()) {
expand(lIndex);
lIndex = lIndex.parent();
}
}
}
}
Expand Down

0 comments on commit 51c132d

Please sign in to comment.