Libplasma

configmodel.h
1/*
2 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
3 SPDX-FileCopyrightText: 2015 Eike Hein <hein@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef CONFIGMODEL_H
9#define CONFIGMODEL_H
10
11#include <QAbstractListModel>
12#include <QQmlListProperty>
13
14#include <plasmaquick/plasmaquick_export.h>
15
16//
17// W A R N I N G
18// -------------
19//
20// This file is not part of the public Plasma API. It exists purely as an
21// implementation detail. This header file may change from version to
22// version without notice, or even be removed.
23//
24// We mean it.
25//
26
27namespace Plasma
28{
29class Applet;
30}
31
32namespace PlasmaQuick
33{
34class ConfigPropertyMap;
35
36class ConfigCategoryPrivate;
37
38class ConfigModelPrivate;
39class ConfigCategory;
40
41/**
42 * This model contains all the possible config categories for a dialog,
43 * such as categories of the config dialog for an Applet
44 * TODO: it should probably become an import instead of a library?
45 *
46 * <b>Import Statement</b>
47 * @code import org.kde.plasma.configuration @endcode
48 * @version 2.0
49 */
50class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel
51{
53 Q_PROPERTY(QQmlListProperty<PlasmaQuick::ConfigCategory> categories READ categories CONSTANT)
54 Q_CLASSINFO("DefaultProperty", "categories")
55 Q_PROPERTY(int count READ count NOTIFY countChanged)
56
57public:
58 enum Roles {
59 NameRole = Qt::UserRole + 1,
60 IconRole,
61 SourceRole,
62 PluginNameRole,
63 VisibleRole
64 };
65 Q_ENUM(Roles)
66
67 explicit ConfigModel(QObject *parent = nullptr);
68 ~ConfigModel() override;
69
70 /**
71 * add a new category in the model
72 * @param ConfigCategory the new category
73 **/
74 void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName);
75
76 Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible);
77 // QML Engine isn't particularly smart resolving namespaces, hence fully qualified signature
78 Q_INVOKABLE void appendCategory(PlasmaQuick::ConfigCategory *category);
79
80 Q_INVOKABLE void removeCategory(PlasmaQuick::ConfigCategory *category);
81 Q_INVOKABLE void removeCategoryAt(int index);
82
83 /**
84 * clears the model
85 **/
86 void clear();
87
88 void setApplet(Plasma::Applet *interface);
89 Plasma::Applet *applet() const;
90
91 int count()
92 {
93 return rowCount();
94 }
95 int rowCount(const QModelIndex &index = QModelIndex()) const override;
96 QVariant data(const QModelIndex &, int) const override;
97 QHash<int, QByteArray> roleNames() const override;
98
99 /**
100 * @param row the row for which the data will be returned
101 * @return the data of the specified row
102 **/
103 Q_INVOKABLE QVariant get(int row) const;
104
105 /**
106 * @return the categories of the model
107 **/
109
111 /**
112 * emitted when the count is changed
113 **/
115
116private:
117 friend class ConfigModelPrivate;
118 ConfigModelPrivate *const d;
119};
120
121}
122
123#endif // multiple inclusion guard
void clear()
clears the model
void countChanged()
emitted when the count is changed
void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName)
add a new category in the model
Q_INVOKABLE QVariant get(int row) const
QQmlListProperty< ConfigCategory > categories()
The base Applet class.
Definition applet.h:64
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
Definition action.h:20
Namespace for everything in libplasma.
virtual QModelIndex parent(const QModelIndex &index) const const=0
QAbstractListModel(QObject *parent)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QObject(QObject *parent)
Q_CLASSINFO(Name, Value)
Q_ENUM(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:51:31 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.