File indexing completed on 2024-06-23 04:38:07
0001 // SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com> 0002 // SPDX-FileCopyrightText: 2020 Kevin Ottens <kevin.ottens@enioka.com> 0003 // 0004 // SPDX-License-Identifier: LGPL-2.1-or-later 0005 0006 #ifndef KAPPLICATIONSCOPELISTMODEL_H 0007 #define KAPPLICATIONSCOPELISTMODEL_H 0008 0009 #include "kapplicationscope.h" 0010 #include "kapplicationscopelister.h" 0011 #include "kcgroups_export.h" 0012 #include <QAbstractListModel> 0013 0014 class KApplicationScopeListModelPrivate; 0015 0016 /** 0017 * @brief A ListModel for use in QML to interact with an updated list of KApplicationScope's. 0018 * Implements QAbstractListModel 0019 * @implements QAbstractListModel 0020 */ 0021 class KCGROUPS_EXPORT KApplicationScopeListModel : public QAbstractListModel 0022 { 0023 Q_OBJECT 0024 public: 0025 /** 0026 * @brief The exposed data roles 0027 */ 0028 enum KApplicationScopeRoles { 0029 /** 0030 * Corresponds to KApplicationScope object 0031 */ 0032 ObjectRole = Qt::UserRole + 1, 0033 }; 0034 Q_ENUM(KApplicationScopeRoles) 0035 0036 explicit KApplicationScopeListModel(QObject *parent = nullptr); 0037 0038 /** 0039 * @brief Used when a KApplicationScopeLister is already on hand 0040 * @param lister 0041 * @param parent 0042 */ 0043 explicit KApplicationScopeListModel(KApplicationScopeLister *lister, QObject *parent = nullptr); 0044 ~KApplicationScopeListModel() override; 0045 0046 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0047 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0048 QHash<int, QByteArray> roleNames() const override; 0049 0050 private: 0051 KApplicationScopeListModelPrivate *const d_ptr; 0052 Q_DECLARE_PRIVATE(KApplicationScopeListModel) 0053 }; 0054 0055 #endif // KAPPLICATIONSCOPELISTMODEL_H