forked from owncloud-archive/News-Qt-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemsmodel.h
59 lines (44 loc) · 1.14 KB
/
itemsmodel.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
#ifndef ITEMSMODEL_H
#define ITEMSMODEL_H
#include <QAbstractListModel>
#include <QList>
#include <QVariantMap>
#include <QSqlDatabase>
#include <QMetaType>
class ItemsModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles {
ItemId = Qt::UserRole + 1,
ItemFeedId,
ItemTitle,
ItemGUID,
ItemGUIDHash,
ItemBody,
ItemBodyHTML,
ItemLink,
ItemAuthor,
ItemPubDate,
ItemUnread,
ItemStarred
};
explicit ItemsModel(QObject *parent = 0);
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
virtual QHash<int, QByteArray> roleNames() const;
void parseItems(const QByteArray& json);
void setDatabase(QSqlDatabase *db);
void setFeed(int feedId);
void recreateTable();
void deleteOldData(int days);
signals:
void feedParseComplete();
private slots:
void slotWorkerFinished();
private:
QList<QVariantMap> m_items;
QSqlDatabase *m_db;
};
Q_DECLARE_METATYPE(ItemsModel*);
#endif // ITEMSMODEL_H