From 8be089472fafd673e3df67deda556d6b75321b54 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Mon, 16 Nov 2020 00:28:44 +0100 Subject: [PATCH] Port plugin model away from KPluginInfo --- interfaces/pluginmodel.cpp | 22 ++++++++++++---------- interfaces/pluginmodel.h | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/interfaces/pluginmodel.cpp b/interfaces/pluginmodel.cpp index fa6743c8a..ae0aa1c85 100644 --- a/interfaces/pluginmodel.cpp +++ b/interfaces/pluginmodel.cpp @@ -7,7 +7,9 @@ #include "pluginmodel.h" #include -#include + +#include +#include PluginModel::PluginModel(QObject *parent) : QAbstractListModel(parent) @@ -20,7 +22,7 @@ PluginModel::PluginModel(QObject *parent) beginResetModel(); - m_plugins = KPluginInfo::fromMetaData(KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"))); + m_plugins = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")); endResetModel(); } @@ -44,23 +46,23 @@ QVariant PluginModel::data(const QModelIndex &index, int role) const return QVariant(); } - const KPluginInfo &pluginEntry = m_plugins[index.row()]; + const KPluginMetaData &pluginEntry = m_plugins[index.row()]; switch (role) { case Qt::CheckStateRole: { - QString def = pluginEntry.isPluginEnabledByDefault() ? QStringLiteral("true") : QStringLiteral("false"); - return m_config->group("Plugins").readEntry(QStringLiteral("%1Enabled").arg(pluginEntry.pluginName()), def) == QStringLiteral("true"); + QString def = pluginEntry.isEnabledByDefault() ? QStringLiteral("true") : QStringLiteral("false"); + return m_config->group("Plugins").readEntry(QStringLiteral("%1Enabled").arg(pluginEntry.pluginId()), def) == QStringLiteral("true"); } case Qt::DisplayRole: return pluginEntry.name(); case IconRole: - return pluginEntry.icon(); + return pluginEntry.iconName(); case IdRole: - return pluginEntry.pluginName(); + return pluginEntry.pluginId(); case ConfigSourceRole: { - const QString configFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kdeconnect/%1_config.qml").arg(pluginEntry.pluginName())); + const QString configFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kdeconnect/%1_config.qml").arg(pluginEntry.pluginId())); if (configFile.isEmpty()) return QUrl(); @@ -93,8 +95,8 @@ bool PluginModel::setData(const QModelIndex &index, const QVariant &value, int r bool ret = false; if (role == Qt::CheckStateRole) { - const KPluginInfo &pluginEntry = m_plugins[index.row()]; - m_config->group("Plugins").writeEntry(QStringLiteral("%1Enabled").arg(pluginEntry.pluginName()), value); + const KPluginMetaData &pluginEntry = m_plugins[index.row()]; + m_config->group("Plugins").writeEntry(QStringLiteral("%1Enabled").arg(pluginEntry.pluginId()), value); ret = true; } diff --git a/interfaces/pluginmodel.h b/interfaces/pluginmodel.h index c8af85140..a7543c3b5 100644 --- a/interfaces/pluginmodel.h +++ b/interfaces/pluginmodel.h @@ -9,10 +9,10 @@ #include -#include +#include +#include #include "interfaces/dbusinterfaces.h" -#include class KDECONNECTINTERFACES_EXPORT PluginModel : public QAbstractListModel @@ -46,7 +46,7 @@ Q_SIGNALS: private: - QList m_plugins; + QVector m_plugins; QString m_deviceId; KSharedConfigPtr m_config;