-
Notifications
You must be signed in to change notification settings - Fork 1
/
pagemodel.hpp
65 lines (48 loc) · 1.17 KB
/
pagemodel.hpp
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
#ifndef PAGEMODEL_HPP
#define PAGEMODEL_HPP
#include <QAbstractListModel>
#include <QStringList>
namespace SMSDB {
class Page;
class PageModel;
}
class SMSDB::Page
{
private:
QString m_contents;
public:
explicit Page(const QString &contents);
virtual ~Page();
public:
QString Contents() const;
void SetContents(const QString &contents);
};
class SMSDB::PageModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY( int count READ rowCount NOTIFY countChanged )
public:
enum PageRoles {
ContentsRole = Qt::UserRole + 1
};
private:
QList<Page*> m_pages;
public:
explicit PageModel(QObject *parent = 0);
virtual ~PageModel();
signals:
void countChanged(int);
public:
Q_INVOKABLE void clear();
Q_INVOKABLE QVariantMap get(int index);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE void set(int index, QVariantMap dict);
public:
void AddPage(Page *page);
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
protected:
QHash<int, QByteArray> roleNames() const;
};
#endif // PAGEMODEL_HPP