-
Notifications
You must be signed in to change notification settings - Fork 4
/
model.h
60 lines (43 loc) · 1.12 KB
/
model.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
/*
* model.h and model.cpp is totally inspired from
* QAbstractitem Model subclass
* to get better and more detailed idea
* refer : http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html
*
*/
#ifndef MODEL_H
#define MODEL_H
#include <QAbstractListModel>
#include <QStringList>
class list
{
public:
list(const QString &title, const QString &id);
QString title() const;
QString id() const;
private:
QString m_title;
QString m_id;
};
class listmodel : public QAbstractListModel
{
Q_OBJECT
public:
enum listroles {
titlerole = Qt::UserRole + 1,
idrole
};
listmodel(QObject *parent = 0);
void addpages(const list &list);
Q_INVOKABLE void deletepages(int row);
Q_INVOKABLE void deletelist();
Q_INVOKABLE void new_page(QString current_title);
Q_INVOKABLE void update(QString pageid, int row);
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
protected:
QHash<int, QByteArray> roleNames() const;
private:
QList<list> m_list;
};
#endif // MODEL_H