MauiKit Controls

pluginmanager.h
1#ifndef PLUGINMANAGER_H
2#define PLUGINMANAGER_H
3
4#include "fmh.h"
5#include "mauilist.h"
6#include <QObject>
7#include <QQmlEngine>
8
9namespace MauiKitPlugin
10{
11class Plugin : public QObject
12{
14};
15
16class Interface : public QObject
17{
19public:
20 Interface(const QString &id, QObject *interface, QObject *parent = nullptr)
22 , m_id(id)
23 , m_interface(interface)
24 {
25 }
26
27private:
28 QString m_id;
29 QObject *m_interface;
30};
31
32class PluginInterfacesModel : public QAbstractListModel
33{
35public:
36 PluginInterfacesModel(QObject *parent = nullptr);
37 void append(Interface *interface);
38 bool contains(const QString &id);
39 int rowCount(const QModelIndex &parent) const override;
40 QVariant data(const QModelIndex &index, int role) const override;
41 QHash<int, QByteArray> roleNames() const override;
42
43private:
44 QVector<Interface *> m_interfaces; // id
45};
46
47class PluginsModel : public MauiList
48{
50public:
51 PluginsModel(QObject *parent = nullptr);
52 FMH::MODEL_LIST items() const final override;
53 void append(Plugin *plugin);
54
55private:
56 FMH::MODEL_LIST m_plugins;
57signals:
58};
59
60class PluginInterface : public QObject
61{
63 Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
64 Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
65 Q_PROPERTY(int target READ target WRITE setTarget NOTIFY targetChanged)
66
67public:
68 static PluginInterface *qmlAttachedProperties(QObject *object)
69 {
70 return new PluginInterface(object);
71 }
72 void setOrientation(const uint &value);
73 uint orintation() const
74 {
75 return m_orientation;
76 }
77
78 void setType(const uint &value);
79 uint type() const
80 {
81 return m_orientation;
82 }
83
84 void setTarget(const uint &value);
85 uint target() const
86 {
87 return m_orientation;
88 }
89
90private:
91 using QObject::QObject;
92 QObject m_interface;
93 uint m_orientation;
94 uint m_type;
95 uint m_target;
96
97signals:
98 void orientationChanged();
99 void typeChanged();
100 void targetChanged();
101};
102
103class PluginManager : public QObject
104{
105 Q_OBJECT
106 Q_PROPERTY(PluginsModel *plugins READ plugins FINAL CONSTANT)
107 Q_PROPERTY(PluginInterfacesModel *interfaces READ interfaces FINAL CONSTANT)
108public:
109 static PluginManager *instance()
110 {
111 static PluginManager manager;
112 return &manager;
113 }
114
115 PluginManager(const PluginManager &) = delete;
116 PluginManager &operator=(const PluginManager &) = delete;
117 PluginManager(PluginManager &&) = delete;
118 PluginManager &operator=(PluginManager &&) = delete;
119
120 void registerInterface(QObject *interface, const QString &id);
121 PluginsModel *plugins() const
122 {
123 return m_plugins;
124 }
125 PluginInterfacesModel *interfaces() const
126 {
127 return m_interfaces;
128 }
129
130private:
131 PluginManager(QObject *parent = nullptr);
132 QObject m_interface;
133 PluginsModel *m_plugins;
134 PluginInterfacesModel *m_interfaces;
135
136signals:
137 void interfacesChanged();
138};
139}
140
141#endif // PLUGINMANAGER_H
MauiList class.
Definition mauilist.h:180
void setTarget(const SkyPoint &targetCoord)
Type type(const QSqlDatabase &db)
A set of helpers for managing the key-value model data type.
Definition fmh.cpp:7
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.