Changeset View
Changeset View
Standalone View
Standalone View
processui/ProcessModel.h
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | #endif | 44 | #endif | ||
45 | 45 | | |||
46 | class KSYSGUARD_EXPORT ProcessModel : public QAbstractItemModel | 46 | class KSYSGUARD_EXPORT ProcessModel : public QAbstractItemModel | ||
47 | { | 47 | { | ||
48 | Q_OBJECT | 48 | Q_OBJECT | ||
49 | Q_ENUMS(Units) | 49 | Q_ENUMS(Units) | ||
50 | 50 | | |||
51 | public: | 51 | public: | ||
52 | /** Storage for history values. PercentageHistoryRole returns a QVector of this. */ | ||||
53 | struct PercentageHistoryEntry { | ||||
54 | unsigned long timestamp; // in ms, origin undefined as only the delta matters | ||||
55 | float value; | ||||
56 | }; | ||||
57 | | ||||
52 | ProcessModel(QObject* parent = 0, const QString &host = QString() ); | 58 | ProcessModel(QObject* parent = 0, const QString &host = QString() ); | ||
53 | virtual ~ProcessModel(); | 59 | virtual ~ProcessModel(); | ||
54 | 60 | | |||
55 | /* Functions for our Model for QAbstractItemModel*/ | 61 | /* Functions for our Model for QAbstractItemModel*/ | ||
56 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | 62 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
57 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | 63 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | ||
58 | QVariant data(const QModelIndex &index, int role) const; | 64 | QVariant data(const QModelIndex &index, int role) const; | ||
59 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | 65 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 142 | enum { HeadingName=0, | |||
146 | HeadingMemory, | 152 | HeadingMemory, | ||
147 | HeadingSharedMemory, | 153 | HeadingSharedMemory, | ||
148 | HeadingStartTime, | 154 | HeadingStartTime, | ||
149 | HeadingCommand, | 155 | HeadingCommand, | ||
150 | HeadingXMemory, | 156 | HeadingXMemory, | ||
151 | HeadingXTitle | 157 | HeadingXTitle | ||
152 | }; | 158 | }; | ||
153 | 159 | | |||
154 | enum { UidRole = Qt::UserRole, SortingValueRole, WindowIdRole, PlainValueRole, PercentageRole }; | 160 | enum { UidRole = Qt::UserRole, SortingValueRole, WindowIdRole, PlainValueRole, PercentageRole, PercentageHistoryRole }; | ||
155 | 161 | | |||
156 | bool showTotals() const; | 162 | bool showTotals() const; | ||
157 | 163 | | |||
158 | /** When displaying memory sizes, this is the units it should be displayed in */ | 164 | /** When displaying memory sizes, this is the units it should be displayed in */ | ||
159 | enum Units { UnitsAuto, UnitsKB, UnitsMB, UnitsGB, UnitsTB, UnitsPB, UnitsPercentage }; | 165 | enum Units { UnitsAuto, UnitsKB, UnitsMB, UnitsGB, UnitsTB, UnitsPB, UnitsPercentage }; | ||
160 | /** Set the units memory sizes etc should be displayed in */ | 166 | /** Set the units memory sizes etc should be displayed in */ | ||
161 | void setUnits(Units units); | 167 | void setUnits(Units units); | ||
162 | /** The units memory sizes etc should be displayed in */ | 168 | /** The units memory sizes etc should be displayed in */ | ||
Show All 32 Lines | 200 | public Q_SLOTS: | |||
195 | /** Whether to show the total cpu for the process plus all of its children */ | 201 | /** Whether to show the total cpu for the process plus all of its children */ | ||
196 | void setShowTotals(bool showTotals); | 202 | void setShowTotals(bool showTotals); | ||
197 | 203 | | |||
198 | private: | 204 | private: | ||
199 | ProcessModelPrivate* const d; | 205 | ProcessModelPrivate* const d; | ||
200 | friend class ProcessModelPrivate; | 206 | friend class ProcessModelPrivate; | ||
201 | }; | 207 | }; | ||
202 | 208 | | |||
209 | Q_DECLARE_METATYPE(QVector<ProcessModel::PercentageHistoryEntry>); | ||||
210 | | ||||
kossebau: You could also add ` Q_DECLARE_TYPEINFO(ProcessModel::PercentageHistoryEntry, Q_PRIMITIVE_TYPE)… | |||||
203 | #endif | 211 | #endif | ||
204 | 212 | | |||
205 | 213 | |
You could also add Q_DECLARE_TYPEINFO(ProcessModel::PercentageHistoryEntry, Q_PRIMITIVE_TYPE); for some mini-opt, given the vector is changing size now and then (and needs its data copied to the new array).