Plasma-framework

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{
52 Q_OBJECT
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 IncludeMarginsRole,
64 VisibleRole,
65 KCMRole,
66 };
67 Q_ENUM(Roles)
68
69 explicit ConfigModel(QObject *parent = nullptr);
70 ~ConfigModel() override;
71
72 /**
73 * add a new category in the model
74 * @param ConfigCategory the new category
75 **/
76 void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName);
77
78 Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible);
79 // QML Engine isn't particularly smart resolving namespaces, hence fully qualified signature
80 Q_INVOKABLE void appendCategory(PlasmaQuick::ConfigCategory *category);
81
82 Q_INVOKABLE void removeCategory(PlasmaQuick::ConfigCategory *category);
83 Q_INVOKABLE void removeCategoryAt(int index);
84
85 /**
86 * clears the model
87 **/
88 void clear();
89
90 void setApplet(Plasma::Applet *interface);
91 Plasma::Applet *applet() const;
92
93 int count()
94 {
95 return rowCount();
96 }
97 int rowCount(const QModelIndex &index = QModelIndex()) const override;
98 QVariant data(const QModelIndex &, int) const override;
99 QHash<int, QByteArray> roleNames() const override;
100
101 /**
102 * @param row the row for which the data will be returned
103 * @return the data of the specified row
104 **/
105 Q_INVOKABLE QVariant get(int row) const;
106
107 /**
108 * @return the categories of the model
109 **/
111
112Q_SIGNALS:
113 /**
114 * emitted when the count is changed
115 **/
117
118private:
119 friend class ConfigModelPrivate;
120 ConfigModelPrivate *const d;
121};
122
123}
124
125#endif // multiple inclusion guard
This model contains all the possible config categories for a dialog, such as categories of the config...
Definition configmodel.h:51
void countChanged()
emitted when the count is changed
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.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.