forked from tiiuae/vmmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmdatamodel.h
60 lines (45 loc) · 1.4 KB
/
vmdatamodel.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef VMDATAMODEL_H
#define VMDATAMODEL_H
#include <QObject>
#include <QAbstractListModel>
#include <QModelIndex>
#include <QList>
class Parameter
{
public:
Parameter(const QString &id, const QString &name, const QString &value)
: m_id(id), m_name(name), m_status(value) {};
QString id() const { return m_id; }
QString name() const { return m_name; };
QString status() const { return m_status; };
void setName(const QString &newName) { m_name = newName; }
void setStatus(const QString &newValue) { m_status = newValue; }//add validation!
friend bool operator==(const Parameter &lhs, const Parameter &rhs);
private:
QString m_id;
QString m_name;
QString m_status;
};
class VMDataModel : public QAbstractListModel
{
Q_OBJECT
public:
enum DataRoles {
NameRole = Qt::UserRole + 1,
StatusRole,
CPURole,
MemoryRole,
NetworkRole
};
VMDataModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const;
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
void addData(const Parameter &Parameter);
void clear();
private:
QList<Parameter> parameters;
};
#endif // VMDATAMODEL_H