summaryrefslogtreecommitdiff
path: root/topicmodel.h
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-04 15:49:31 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-04 15:49:31 +0200
commitd8fcff1a2d6eb61c97c44790dbdb920ba9f52980 (patch)
tree49df7f1e07e34061301ad5944a1807feba24b526 /topicmodel.h
parent11b4152301b408c7a4f02a8b202fed9f5e1ee1e7 (diff)
downloadtapasboard-d8fcff1a2d6eb61c97c44790dbdb920ba9f52980.tar.gz
tapasboard-d8fcff1a2d6eb61c97c44790dbdb920ba9f52980.zip
add showing unread posts
Diffstat (limited to 'topicmodel.h')
-rw-r--r--topicmodel.h11
1 files changed, 10 insertions, 1 deletions
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<Post>& posts);
QDateTime lastTopPostUpdate();
QList<Post> 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<Post> _data;
bool _eof;
+ int _firstUnread;
};
#endif // TOPICMODEL_H