]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/servicemodel.h
Q_DECL_OVERRIDE
[dolphin.git] / src / settings / servicemodel.h
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef SERVICEMODEL_H
21 #define SERVICEMODEL_H
22
23 #include <QAbstractListModel>
24 #include <QList>
25
26 /**
27 * @brief Provides a simple model for enabling/disabling services
28 *
29 * The following roles are supported:
30 * - Qt::DisplayRole: Name of the service
31 * - Qt::DecorationRole: Icon name of the service
32 * - Qt::CheckStateRole: Specifies whether the service is enabled
33 * - ServiceModel::DesktopEntryNameRole: Name of the desktop-entry of the service
34 * - ServiceModel::Configurable: Specifies whether the service is configurable by the user
35 */
36 class ServiceModel : public QAbstractListModel
37 {
38 Q_OBJECT
39
40 public:
41 enum Role
42 {
43 DesktopEntryNameRole = Qt::UserRole,
44 ConfigurableRole
45 };
46
47 explicit ServiceModel(QObject* parent = 0);
48 virtual ~ServiceModel();
49
50 virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) Q_DECL_OVERRIDE;
51 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) Q_DECL_OVERRIDE;
52 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
53 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
54
55 private:
56 struct ServiceItem
57 {
58 bool checked;
59 bool configurable;
60 QString icon;
61 QString text;
62 QString desktopEntryName;
63 };
64
65 QList<ServiceItem> m_items;
66 };
67
68 #endif