]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/servicemodel.h
Merge branch 'release/20.08'
[dolphin.git] / src / settings / servicemodel.h
1 /*
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef SERVICEMODEL_H
8 #define SERVICEMODEL_H
9
10 #include <QAbstractListModel>
11 #include <QList>
12
13 /**
14 * @brief Provides a simple model for enabling/disabling services
15 *
16 * The following roles are supported:
17 * - Qt::DisplayRole: Name of the service
18 * - Qt::DecorationRole: Icon name of the service
19 * - Qt::CheckStateRole: Specifies whether the service is enabled
20 * - ServiceModel::DesktopEntryNameRole: Name of the desktop-entry of the service
21 * - ServiceModel::Configurable: Specifies whether the service is configurable by the user
22 */
23 class ServiceModel : public QAbstractListModel
24 {
25 Q_OBJECT
26
27 public:
28 enum Role
29 {
30 DesktopEntryNameRole = Qt::UserRole,
31 ConfigurableRole
32 };
33
34 explicit ServiceModel(QObject* parent = nullptr);
35 ~ServiceModel() override;
36
37 bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) override;
38 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
39 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
40 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
41
42 private:
43 struct ServiceItem
44 {
45 bool checked;
46 bool configurable;
47 QString icon;
48 QString text;
49 QString desktopEntryName;
50 };
51
52 QList<ServiceItem> m_items;
53 };
54
55 #endif