Commit 7498b41a authored by Stefan Brüns's avatar Stefan Brüns

[Baloo KCM] Complete overhaul of the include/exclude folder list

The current "Excluded folders" list in the KCM is quite awkward:

1. It tries to mimic baloos automatic exclusion of external drives,
   but fails doing so and adds almost any external drive even when not
   mounted below an indexable path.

2. Deleting an autogenerated entry actually **adds** it to the included
   folder list, and then hides it.

3. There is no way to show the included folder list, or add any entries
   to it.

Remove the custom "excluded mounts" heuristic from the KCM and retrieve
the additional (not explicitly configured) excluded ones from baloo.

Replace the "excluded list" with a common list for included and excluded
folders, and flag its state. This also makes it easy to add additional
properties later.

Create a new UI delegate for each config list item, allowing to enable
and disable indexing for each entry. Make the "delete" actually always
delete a config entry, and make the control inline. Move the "Add" button
to the *right* bottom of the list (in accordance with UI guidelines) and
add some text to it.

Depends on D28024

Solves the following parts of T9879:
[x] Allow adding of includeFolders in the KCM
[x] Correctly show excludeFolders below explicit (non-$HOME) includeFolders in KCM

CCBUG: 417170
CCBUG: 366521
BUG: 417763
BUG: 417762

Reviewers: #baloo, #vdg, ngraham, mart

Reviewed By: #baloo, #vdg, ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision:
parent 38a874ab
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include <QAbstractListModel>
#include <Baloo/IndexerConfig>
class BalooSettings;
......@@ -34,10 +35,13 @@ public:
enum Roles {
Folder = Qt::UserRole + 1,
QVariant data(const QModelIndex& idx, int role) const override;
bool setData(const QModelIndex& idx, const QVariant& value, int role) override;
int rowCount(const QModelIndex& parent) const override;
Q_INVOKABLE void addFolder(const QString& folder);
......@@ -48,19 +52,21 @@ public slots:
void updateDirectoryList();
QString folderDisplayName(const QString& url) const;
BalooSettings *m_settings;
Baloo::IndexerConfig m_runtimeConfig;
struct FolderInfo {
QString url;
QString displayName;
QString icon;
bool enableIndex;
bool isFromConfig;
* @brief Get the theme valid icon name for \p path.
* @param path Path to be analysed.
* @return One of: "user-home", "drive-harddisk" or "folder"
QString iconName(QString path) const;
QVector<FolderInfo> m_folderList;
QStringList m_deletedSettings; //< track deleted entries
BalooSettings *m_settings;
QStringList m_mountPoints;
QStringList m_excludeList;
void syncFolderConfig(const FolderInfo& entry);
......@@ -78,7 +78,7 @@ KCM.SimpleKCM {
Layout.preferredHeight: Kirigami.Units.gridUnit
QQC2.Label {
text: i18n("Do not search in these locations:")
text: i18n("Folder specific configuration:")
QQC2.ScrollView {
......@@ -88,33 +88,90 @@ KCM.SimpleKCM {
Layout.fillHeight: true
ListView {
id: fileExcludeList
id: directoryConfigList
clip: true
currentIndex: -1
model: kcm.filteredModel
delegate: Kirigami.BasicListItem {
icon: model.decoration
label: model.folder
onClicked: fileExcludeList.currentIndex = index
delegate: directoryConfigDelegate
RowLayout {
QQC2.Button {
id: addFolder "list-add"
onClicked: = true
QQC2.Button {
Layout.alignment: Qt.AlignRight
id: addFolder "folder-add"
text: i18n("Add folder configuration...")
onClicked: = true
Component {
id: directoryConfigDelegate
Kirigami.SwipeListItem {
id: listItem
onClicked: {
directoryConfigList.currentIndex = index
property int iconSize: Kirigami.Units.iconSizes.smallMedium
property bool selected: directoryConfigList.currentIndex === index
id: removeFolder "list-remove"
enabled: fileExcludeList.currentIndex !== -1
onClicked: {
RowLayout {
spacing: units.smallSpacing
Kirigami.Icon {
source: model.enableIndex ? "search" : "list-remove"
height: listItem.iconSize
width: listItem.iconSize
ColumnLayout {
RowLayout {
spacing: units.smallSpacing
Kirigami.Icon {
source: model.decoration
height: listItem.iconSize
width: listItem.iconSize
QQC2.Label {
text: model.folder
elide: Text.ElideRight
Layout.fillWidth: true
QQC2.Label {
text: (model.enableIndex ? i18n("%1 is included.", model.url)
: i18n("%1 is excluded.", model.url))
elide: Text.ElideRight
Layout.fillWidth: true
opacity: listItem.hovered ? 0.8 : 0.6
visible: listItem.selected
QQC2.ToolButton {
visible: listItem.hovered && listItem.actionsVisible
height: listItem.iconSize "search"
text: model.enableIndex ? i18n("Disable indexing") : i18n("Enable indexing")
onClicked: {
model.enableIndex = !model.enableIndex
actions: [
Kirigami.Action {
id: removeFolder
enabled: model.deletable "user-trash"
tooltip: i18n("Delete entry")
onTriggered: {
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment