]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/servicemodel.h
Add "Act as Administrator" toggle action
[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 { DesktopEntryNameRole = Qt::UserRole };
29
30 explicit ServiceModel(QObject *parent = nullptr);
31 ~ServiceModel() override;
32
33 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
34 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
35 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
36 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
37 void clear();
38 Qt::ItemFlags flags(const QModelIndex &index) const override;
39
40 private:
41 struct ServiceItem {
42 Qt::CheckState checked;
43 QString icon;
44 QString text;
45 QString desktopEntryName;
46 };
47
48 QList<ServiceItem> m_items;
49 };
50
51 #endif