File indexing completed on 2024-04-28 05:34:23
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 #include <QQmlParserStatus> 0011 0012 #include <qqmlregistration.h> 0013 0014 #include <KService> 0015 0016 class QDBusInterface; 0017 0018 /** 0019 * @todo write docs 0020 */ 0021 class ToolsModel : public QAbstractListModel 0022 { 0023 Q_OBJECT 0024 QML_ELEMENT 0025 0026 public: 0027 enum Roles { 0028 IdRole = Qt::UserRole, 0029 NameRole, 0030 IconRole, 0031 ShortcutRole, 0032 }; 0033 0034 explicit ToolsModel(QObject *parent = nullptr); 0035 0036 QHash<int, QByteArray> roleNames() const override; 0037 int rowCount(const QModelIndex &parent) const override; 0038 QVariant data(const QModelIndex &index, int role) const override; 0039 0040 Q_INVOKABLE void trigger(const QString &id); 0041 0042 private: 0043 void addFromService(const QString &serviceName); 0044 0045 struct Entry { 0046 QString id; 0047 QString name; 0048 QString icon; 0049 QString shortcut; 0050 KService::Ptr service; 0051 }; 0052 QList<Entry> m_entries; 0053 };