-
Notifications
You must be signed in to change notification settings - Fork 8
/
qmlitemmodel.h
61 lines (38 loc) · 1.28 KB
/
qmlitemmodel.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
61
#ifndef QMLITEMMODEL_H
#define QMLITEMMODEL_H
#include <QAbstractListModel>
#include <QStringList>
#include <QtCore>
class CustomDevice
{
public:
CustomDevice(const int &firstRole, const int &maxCount, const QList<QVariant> &list);
QVariant roleData(int role) const;
QHash<int,QVariant> rolesData() const;
private:
QHash<int,QVariant> hashIntVar;
int firtsRole;
};
class QmlItemModel : public QAbstractListModel
{
Q_OBJECT
public:
QmlItemModel(QStringList listRoleName, int firstRole = Qt::UserRole + 1, QObject *parent = 0);
void addCustomDevice(const QList<QVariant> &list);
void prependCustomDevice(const QList<QVariant> &list);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant dataRow(const int &row, int role = Qt::DisplayRole) const;
void removeThisRow(const int &row);
void clearAllData();
void replaceData(const int &row, const int &role , const QVariant &dataVar);
QList<QVariant> dataRowInList(const int &row);
protected:
QHash<int,QByteArray> roleNames() const;
private:
QList<CustomDevice> m_device;
QHash<int,QByteArray> m_roleNames;
int firstRole;
int maxCount;
};
#endif // QMLITEMMODEL_H