Changeset View
Changeset View
Standalone View
Standalone View
kcms/baloo/filteredfoldermodel.h
Show All 17 Lines | |||||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef FILTEREDFOLDERMODEL_H | 22 | #ifndef FILTEREDFOLDERMODEL_H | ||
23 | #define FILTEREDFOLDERMODEL_H | 23 | #define FILTEREDFOLDERMODEL_H | ||
24 | 24 | | |||
25 | #include <QAbstractListModel> | 25 | #include <QAbstractListModel> | ||
26 | #include <Baloo/IndexerConfig> | ||||
26 | 27 | | |||
27 | class BalooSettings; | 28 | class BalooSettings; | ||
28 | 29 | | |||
29 | class FilteredFolderModel : public QAbstractListModel | 30 | class FilteredFolderModel : public QAbstractListModel | ||
30 | { | 31 | { | ||
31 | Q_OBJECT | 32 | Q_OBJECT | ||
32 | public: | 33 | public: | ||
33 | explicit FilteredFolderModel(BalooSettings *settings, QObject *parent); | 34 | explicit FilteredFolderModel(BalooSettings *settings, QObject *parent); | ||
34 | 35 | | |||
35 | enum Roles { | 36 | enum Roles { | ||
36 | Folder = Qt::UserRole + 1, | 37 | Folder = Qt::UserRole + 1, | ||
37 | Url | 38 | Url, | ||
39 | EnableIndex, | ||||
40 | Deletable, | ||||
38 | }; | 41 | }; | ||
39 | 42 | | |||
40 | QVariant data(const QModelIndex& idx, int role) const override; | 43 | QVariant data(const QModelIndex& idx, int role) const override; | ||
44 | bool setData(const QModelIndex& idx, const QVariant& value, int role) override; | ||||
41 | int rowCount(const QModelIndex& parent) const override; | 45 | int rowCount(const QModelIndex& parent) const override; | ||
42 | 46 | | |||
43 | Q_INVOKABLE void addFolder(const QString& folder); | 47 | Q_INVOKABLE void addFolder(const QString& folder); | ||
44 | Q_INVOKABLE void removeFolder(int row); | 48 | Q_INVOKABLE void removeFolder(int row); | ||
45 | QHash<int, QByteArray> roleNames() const override; | 49 | QHash<int, QByteArray> roleNames() const override; | ||
46 | 50 | | |||
47 | public slots: | 51 | public slots: | ||
48 | void updateDirectoryList(); | 52 | void updateDirectoryList(); | ||
49 | 53 | | |||
50 | private: | 54 | private: | ||
51 | QString folderDisplayName(const QString& url) const; | 55 | BalooSettings *m_settings; | ||
56 | Baloo::IndexerConfig m_runtimeConfig; | ||||
52 | 57 | | |||
53 | /** | 58 | struct FolderInfo { | ||
54 | * @brief Get the theme valid icon name for \p path. | 59 | QString url; | ||
55 | * | 60 | QString displayName; | ||
56 | * @param path Path to be analysed. | 61 | QString icon; | ||
57 | * @return One of: "user-home", "drive-harddisk" or "folder" | 62 | bool enableIndex; | ||
58 | */ | 63 | bool isFromConfig; | ||
59 | QString iconName(QString path) const; | 64 | }; | ||
60 | 65 | | |||
61 | BalooSettings *m_settings; | 66 | QVector<FolderInfo> m_folderList; | ||
62 | QStringList m_mountPoints; | 67 | QStringList m_deletedSettings; //< track deleted entries | ||
63 | QStringList m_excludeList; | 68 | | ||
69 | void syncFolderConfig(const FolderInfo& entry); | ||||
64 | }; | 70 | }; | ||
65 | 71 | | |||
66 | #endif // FILTEREDFOLDERMODEL_H | 72 | #endif // FILTEREDFOLDERMODEL_H |