Changeset View
Changeset View
Standalone View
Standalone View
processcore/process_attribute_model.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2020 David Edmundson <davidedmundson@kde.org> | ||||
3 | Copyright (c) 2020 Arjen Hiemstra <ahiemstra@heimr.nl> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Library General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Library General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Library General Public License | ||||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <QAbstractListModel> | ||||
24 | | ||||
25 | namespace KSysGuard | ||||
26 | { | ||||
27 | | ||||
28 | class ExtendedProcesses; | ||||
29 | | ||||
30 | /** | ||||
31 | * Presents a list of available attributes that can be | ||||
32 | * enabled on a ProceessDataModel | ||||
33 | */ | ||||
34 | class Q_DECL_EXPORT ProcessAttributeModel : public QAbstractListModel | ||||
35 | { | ||||
36 | Q_OBJECT | ||||
37 | public: | ||||
38 | enum class Role { | ||||
39 | Name = Qt::DisplayRole, /// Human readable translated name of the attribute | ||||
40 | Id = Qt::UserRole, /// Computer readable ID of the attribute | ||||
41 | ShortName = Qt::UserRole + 1, /// A shorter human readable translated name of the attribute | ||||
42 | Description, /// A longer, sentence-based description of the attribute | ||||
43 | Unit, /// The unit, of type KSysGuard::Unit | ||||
44 | }; | ||||
45 | Q_ENUM(Role); | ||||
46 | | ||||
47 | ProcessAttributeModel(ExtendedProcesses *processes, QObject *parent = nullptr); | ||||
48 | ~ProcessAttributeModel() override; | ||||
49 | | ||||
50 | int rowCount(const QModelIndex &parent) const override; | ||||
51 | QVariant data(const QModelIndex &index, int role) const override; | ||||
52 | QHash<int, QByteArray> roleNames() const override; | ||||
53 | | ||||
54 | private: | ||||
55 | class Private; | ||||
56 | QScopedPointer<Private> d; | ||||
57 | }; | ||||
58 | | ||||
59 | } |