blob: d945de258cea288405c9e18d720ff5ea7655ef7c (
plain)
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
|
#ifndef BOARDMODEL_H
#define BOARDMODEL_H
#include <QtCore/QAbstractListModel>
#include <QtSql/QSqlQuery>
class Board;
class BoardModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(Board * board READ board WRITE setBoard NOTIFY boardChanged)
Q_PROPERTY(int forumId READ forumId WRITE setForumId NOTIFY forumIdChanged)
public:
BoardModel(QObject *parent = 0);
enum DataRoles {
NameRole = Qt::DisplayRole,
LogoRole = Qt::DecorationRole,
DescriptionRole = Qt::StatusTipRole,
ForumIdRole = Qt::UserRole,
SubOnlyRole,
CategoryRole,
UnreadRole
};
Board * board() const;
void setBoard(Board *board);
int forumId() const;
void setForumId(const int id);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
bool canFetchMore(const QModelIndex &parent = QModelIndex()) const;
void fetchMore(const QModelIndex &parent = QModelIndex());
public slots:
void refresh();
void markSubforumsRead();
signals:
void boardChanged();
void forumIdChanged();
private slots:
void reload();
void handleForumChanged(int forumId);
private:
Board *_board;
int _forumId;
mutable QSqlQuery _query;
int _records;
bool _eof;
};
#endif // BOARDMODEL_H
|