-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathqslistmodel.h
75 lines (45 loc) · 1.49 KB
/
qslistmodel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* QSyncable Project
Author: Ben Lau
License: Apache-2.0
Web: https://github.com/benlau/qsyncable
*/
#pragma once
#include <QAbstractItemModel>
#include <QAbstractListModel>
#include <QPointer>
#include <QSharedPointer>
#include "qspatchable.h"
#include "qsyncablefunctions.h"
class QSListModel : public QAbstractListModel, public QSPatchable
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
explicit QSListModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
int count() const;
QHash<int, QByteArray> roleNames() const;
void setRoleNames(const QVariantMap& value);
void setRoleNames(const QStringList& value);
void setStorage(const QVariantList& value);
QVariantList storage() const;
virtual void insert(int index, const QVariantList &value);
public slots:
void append(const QVariantMap&value);
void insert(int index,const QVariantMap& value);
void clear();
virtual void move(int from, int to, int count = 1);
virtual void remove(int i , int count = 1);
int indexOf(QString field,QVariant value) const;
QVariantMap get(int i) const;
void setProperty(int index,QString property ,QVariant value);
void set(int index,QVariantMap data);
signals:
void countChanged();
public slots:
private:
QHash<int, QByteArray> m_roles;
QHash<QString, int> m_rolesLookup;
QVariantList m_storage;
};