File indexing completed on 2024-04-14 04:51:44

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef PLUGINMODEL
0008 #define PLUGINMODEL
0009 
0010 #include <QAbstractListModel>
0011 
0012 #include <KPluginMetaData>
0013 #include <KSharedConfig>
0014 
0015 #include "interfaces/dbusinterfaces.h"
0016 
0017 class KDECONNECTINTERFACES_EXPORT PluginModel : public QAbstractListModel
0018 {
0019     Q_OBJECT
0020     Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId)
0021 
0022 public:
0023     enum ExtraRoles {
0024         IconRole = Qt::UserRole + 1,
0025         IdRole,
0026         ConfigSourceRole,
0027         DescriptionRole,
0028     };
0029 
0030     Q_ENUM(ExtraRoles)
0031 
0032     explicit PluginModel(QObject *parent = nullptr);
0033     ~PluginModel() override;
0034 
0035     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0036     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0037     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0038     QHash<int, QByteArray> roleNames() const override;
0039     void setDeviceId(const QString &deviceId);
0040     QString deviceId();
0041 
0042 Q_SIGNALS:
0043     void deviceIdChanged(const QString &value);
0044     void rowsChanged();
0045 
0046 private:
0047     QVector<KPluginMetaData> m_plugins;
0048     QString m_deviceId;
0049     KSharedConfigPtr m_config;
0050 };
0051 
0052 #endif // KPLUGINSELECTOR_P_H