1 /* 2 This file is part of the KDE Baloo project 3 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in> 4 SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com> 5 6 SPDX-License-Identifier: LGPL-2.1-or-later 7 8 */ 9 10 #ifndef FILTEREDFOLDERMODEL_H 11 #define FILTEREDFOLDERMODEL_H 12 13 #include <Baloo/IndexerConfig> 14 #include <QAbstractListModel> 15 16 class BalooSettings; 17 18 class FilteredFolderModel : public QAbstractListModel 19 { 20 Q_OBJECT 21 public: 22 explicit FilteredFolderModel(BalooSettings *settings, QObject *parent); 23 24 enum Roles { 25 Folder = Qt::UserRole + 1, 26 Url, 27 EnableIndex, 28 Deletable, 29 }; 30 31 QVariant data(const QModelIndex &idx, int role) const override; 32 bool setData(const QModelIndex &idx, const QVariant &value, int role) override; 33 int rowCount(const QModelIndex &parent) const override; 34 35 Q_INVOKABLE void addFolder(const QString &folder, const bool included); 36 Q_INVOKABLE void removeFolder(int row); 37 QHash<int, QByteArray> roleNames() const override; 38 39 public Q_SLOTS: 40 void updateDirectoryList(); 41 42 private: 43 BalooSettings *m_settings; 44 Baloo::IndexerConfig m_runtimeConfig; 45 46 struct FolderInfo { 47 QString url; 48 QString displayName; 49 QString icon; 50 bool enableIndex; 51 bool isFromConfig; 52 }; 53 54 QVector<FolderInfo> m_folderList; 55 QStringList m_deletedSettings; //< track deleted entries 56 57 void syncFolderConfig(const FolderInfo &entry); 58 }; 59 60 #endif // FILTEREDFOLDERMODEL_H 61