From d8fcff1a2d6eb61c97c44790dbdb920ba9f52980 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 4 Apr 2013 15:49:31 +0200 Subject: add showing unread posts --- topicmodel.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'topicmodel.h') diff --git a/topicmodel.h b/topicmodel.h index 0151242..67e48c4 100644 --- a/topicmodel.h +++ b/topicmodel.h @@ -12,6 +12,7 @@ class TopicModel : public QAbstractListModel Q_OBJECT Q_PROPERTY(Board * board READ board WRITE setBoard NOTIFY boardChanged) Q_PROPERTY(int topicId READ topicId WRITE setTopicId NOTIFY topicIdChanged) + Q_PROPERTY(int firstUnreadPost READ firstUnreadPost NOTIFY firstUnreadPostChanged) public: TopicModel(QObject *parent = 0); @@ -35,6 +36,8 @@ public: int topicId() const; void setTopicId(const int id); + int firstUnreadPost() const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; @@ -47,9 +50,11 @@ public slots: signals: void boardChanged(); void topicIdChanged(); + void firstUnreadPostChanged(); protected: struct Post { + /** Set 'post_id' to -1 for "not yet fetched" */ int post_id; QString title; QString content; @@ -64,10 +69,13 @@ private: static QDateTime oldestPostUpdate(const QList& posts); QDateTime lastTopPostUpdate(); QList loadPosts(int start, int end); + void fetchPost(int position) const; // const because data() calls this + void enlargeModel(int end); void clearModel(); private slots: - void handleTopicPostsChanged(int forumId, int start, int end); + void handleTopicPostsChanged(int topicId, int start, int end); + void handleTopicPostsUnread(int topicId, int position); void update(); void reload(); @@ -76,6 +84,7 @@ private: int _topicId; QList _data; bool _eof; + int _firstUnread; }; #endif // TOPICMODEL_H -- cgit v1.2.3