File indexing completed on 2024-05-12 05:35:38

0001 /*
0002     This file is part of the KDE Baloo project
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004     SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 
0008 */
0009 
0010 #pragma once
0011 
0012 #include <Baloo/IndexerConfig>
0013 #include <QAbstractListModel>
0014 
0015 class BalooSettings;
0016 
0017 class FilteredFolderModel : public QAbstractListModel
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit FilteredFolderModel(BalooSettings *settings, QObject *parent);
0022 
0023     enum Roles {
0024         Folder = Qt::UserRole + 1,
0025         Url,
0026         EnableIndex,
0027         Deletable,
0028     };
0029 
0030     QVariant data(const QModelIndex &idx, int role) const override;
0031     bool setData(const QModelIndex &idx, const QVariant &value, int role) override;
0032     int rowCount(const QModelIndex &parent) const override;
0033 
0034     Q_INVOKABLE void addFolder(const QString &folder, const bool included);
0035     Q_INVOKABLE void removeFolder(int row);
0036     QHash<int, QByteArray> roleNames() const override;
0037 
0038 public Q_SLOTS:
0039     void updateDirectoryList();
0040 
0041 private:
0042     BalooSettings *m_settings;
0043     Baloo::IndexerConfig m_runtimeConfig;
0044 
0045     struct FolderInfo {
0046         QString url;
0047         QString displayName;
0048         QString icon;
0049         bool enableIndex;
0050         bool isFromConfig;
0051     };
0052 
0053     QList<FolderInfo> m_folderList;
0054     QStringList m_deletedSettings; //< track deleted entries
0055 
0056     void syncFolderConfig(const FolderInfo &entry);
0057 };