From 51c132d8c499db5b009508959236c525a8b10b5f Mon Sep 17 00:00:00 2001 From: Simon Persson Date: Sat, 19 Dec 2015 20:36:44 +0800 Subject: [PATCH] Bugfix for not usable source selection with empty include&exclude lists 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. --- kcm/backupplanwidget.cpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/kcm/backupplanwidget.cpp b/kcm/backupplanwidget.cpp index 72a847d..1f014a3 100644 --- a/kcm/backupplanwidget.cpp +++ b/kcm/backupplanwidget.cpp @@ -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) { @@ -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(); + } } } }