-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpumodel.h
34 lines (25 loc) · 864 Bytes
/
cpumodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef CPUMODEL_H
#define CPUMODEL_H
#include <QAbstractListModel>
// Model that holds CPU info
class CpuModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit CpuModel(QObject *parent = 0);
// populates model from cpuinfo file
Q_INVOKABLE void populateModel();
// returns a complete string for a given index as key:value pairs
Q_INVOKABLE QString prettyFormat(int index) const;
private:
// from QAbstractListModel
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
QHash<int, QByteArray> roleNames() const;
private:
// stores data as key:value map for each logical CPU core
QList<QMap<QString, QString> > m_data;
// role names for the model
QHash<int, QByteArray> m_roleNames;
};
#endif // CPUMODEL_H