diff --git a/kdevplatform/KDevPlatformConfig.cmake.in b/kdevplatform/KDevPlatformConfig.cmake.in --- a/kdevplatform/KDevPlatformConfig.cmake.in +++ b/kdevplatform/KDevPlatformConfig.cmake.in @@ -18,7 +18,6 @@ find_dependency(KF5GuiAddons "@KF5_DEP_VERSION@") find_dependency(KF5I18n "@KF5_DEP_VERSION@") find_dependency(KF5IconThemes "@KF5_DEP_VERSION@") -find_dependency(KF5ItemModels "@KF5_DEP_VERSION@") find_dependency(KF5ItemViews "@KF5_DEP_VERSION@") find_dependency(KF5JobWidgets "@KF5_DEP_VERSION@") find_dependency(KF5KCMUtils "@KF5_DEP_VERSION@") diff --git a/kdevplatform/util/CMakeLists.txt b/kdevplatform/util/CMakeLists.txt --- a/kdevplatform/util/CMakeLists.txt +++ b/kdevplatform/util/CMakeLists.txt @@ -55,8 +55,8 @@ target_link_libraries(KDevPlatformUtil LINK_PUBLIC KDev::Interfaces - KF5::ItemModels LINK_PRIVATE + KF5::ItemModels KF5::ConfigWidgets KF5::TextEditor KF5::GuiAddons diff --git a/kdevplatform/util/multilevellistview.h b/kdevplatform/util/multilevellistview.h --- a/kdevplatform/util/multilevellistview.h +++ b/kdevplatform/util/multilevellistview.h @@ -21,7 +21,6 @@ #define KDEVPLATFORM_MULTILEVELLISTVIEW_H #include -#include #include "utilexport.h" class QTreeView; @@ -44,6 +43,12 @@ { Q_OBJECT public: + enum LastLevelViewModus { + SubTrees, ///< Shows complete subtree for each child. Only leafs are selectable. + DirectChildren ///< Shows only the direct childs. + }; + Q_ENUM(LastLevelViewModus) + /** * Creates a new MultiLevelListView with parent @p parent. * @@ -109,10 +114,11 @@ void setHeaderLabels(const QStringList& labels); /** - * Set the filter behavior of the last model. By default, SubTreesWithoutRoots - * is used and only leafs are selectable in the view for that model. + * Set the view modus of the view for the last level. + * Default is @c SubTrees. */ - void setLastModelsFilterBehavior(KSelectionProxyModel::FilterBehavior filter); + void setLastLevelViewModus(LastLevelViewModus modus); + Q_SIGNALS: /** * Notified that the current index has changed from @p previous to @p current diff --git a/kdevplatform/util/multilevellistview.cpp b/kdevplatform/util/multilevellistview.cpp --- a/kdevplatform/util/multilevellistview.cpp +++ b/kdevplatform/util/multilevellistview.cpp @@ -437,12 +437,28 @@ } } -void MultiLevelListView::setLastModelsFilterBehavior(KSelectionProxyModel::FilterBehavior filter) +static +KSelectionProxyModel::FilterBehavior toSelectionProxyModelFilterBehavior(MultiLevelListView::LastLevelViewModus modus) +{ + switch (modus) { + case MultiLevelListView::SubTrees: + return KSelectionProxyModel::SubTreesWithoutRoots; + case MultiLevelListView::DirectChildren: + return KSelectionProxyModel::ChildrenOfExactSelection; + default: + // someone added a new enum value? adapt + Q_ASSERT(false); + return KSelectionProxyModel::SubTreesWithoutRoots; + } +}; + +void MultiLevelListView::setLastLevelViewModus(LastLevelViewModus modus) { if (d->proxies.isEmpty()) { return; } - dynamic_cast(d->proxies.last())->setFilterBehavior(filter); + const auto filterBehavior = toSelectionProxyModelFilterBehavior(modus); + dynamic_cast(d->proxies.last())->setFilterBehavior(filterBehavior); } diff --git a/plugins/appwizard/projectselectionpage.cpp b/plugins/appwizard/projectselectionpage.cpp --- a/plugins/appwizard/projectselectionpage.cpp +++ b/plugins/appwizard/projectselectionpage.cpp @@ -58,7 +58,7 @@ ui->listView->setLevels(2); ui->listView->setHeaderLabels(QStringList() << i18n("Category") << i18n("Project Type")); ui->listView->setModel(templatesModel); - ui->listView->setLastModelsFilterBehavior(KSelectionProxyModel::ChildrenOfExactSelection); + ui->listView->setLastLevelViewModus(MultiLevelListView::DirectChildren); connect (ui->listView, &MultiLevelListView::currentIndexChanged, this, &ProjectSelectionPage::typeChanged); typeChanged(ui->listView->currentIndex());