File indexing completed on 2025-01-26 05:06:22
0001 /* 0002 SPDX-FileCopyrightText: 2008 Fredrik Höglund <fredrik@kde.org> 0003 SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <KPluginMetaData> 0011 #include <QAbstractListModel> 0012 #include <QStringList> 0013 0014 class PreviewPluginsModel : public QAbstractListModel 0015 { 0016 Q_OBJECT 0017 0018 Q_PROPERTY(QStringList checkedPlugins READ checkedPlugins WRITE setCheckedPlugins NOTIFY checkedPluginsChanged) 0019 0020 public: 0021 explicit PreviewPluginsModel(QObject *parent = nullptr); 0022 ~PreviewPluginsModel() override; 0023 0024 QHash<int, QByteArray> roleNames() const override; 0025 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0026 bool setData(const QModelIndex &index, const QVariant &value, int role) override; 0027 0028 int rowCount(const QModelIndex &parent = QModelIndex()) const override 0029 { 0030 Q_UNUSED(parent) 0031 return m_plugins.size(); 0032 } 0033 0034 QStringList checkedPlugins() const; 0035 void setCheckedPlugins(const QStringList &list); 0036 0037 Q_SIGNALS: 0038 void checkedPluginsChanged() const; 0039 0040 private: 0041 int indexOfPlugin(const QString &pluginId) const; 0042 0043 QList<KPluginMetaData> m_plugins; 0044 QList<bool> m_checkedRows; 0045 };