From 11b4152301b408c7a4f02a8b202fed9f5e1ee1e7 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 4 Apr 2013 01:59:18 +0200 Subject: add topic replies counter bubbles --- forummodel.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'forummodel.cpp') diff --git a/forummodel.cpp b/forummodel.cpp index 4d59916..63fb0b8 100644 --- a/forummodel.cpp +++ b/forummodel.cpp @@ -14,7 +14,7 @@ ForumModel::ForumModel(QObject *parent) : roles[TitleRole] = QByteArray("title"); roles[IconRole] = QByteArray("icon"); roles[TopicIdRole] = QByteArray("topicId"); - roles[NumPostsRole] = QByteArray("numPosts"); + roles[NumRepliesRole] = QByteArray("numReplies"); setRoleNames(roles); } @@ -82,7 +82,7 @@ QVariant ForumModel::data(const QModelIndex &index, int role) const return _data[row].title; case TopicIdRole: return _data[row].topic_id; - case NumPostsRole: + case NumRepliesRole: return _data[row].num_replies; } @@ -190,7 +190,7 @@ QList ForumModel::loadTopics(int start, int end) const int rows = end - start + 1; QList topics; QSqlQuery query(_board->database()); - query.prepare("SELECT topic_id, topic_title, last_reply_time, last_update_time FROM topics " + query.prepare("SELECT topic_id, topic_title, reply_number, last_reply_time, last_update_time FROM topics " "WHERE forum_id = :forum_id " "ORDER by last_reply_time DESC " "LIMIT :start, :limit"); @@ -203,8 +203,9 @@ QList ForumModel::loadTopics(int start, int end) Topic topic; topic.topic_id = query.value(0).toInt(); topic.title = query.value(1).toString(); - topic.last_reply_time = parseDateTime(query.value(2)); - topic.last_update_time = parseDateTime(query.value(3)); + topic.num_replies = query.value(2).toInt(); + topic.last_reply_time = parseDateTime(query.value(3)); + topic.last_update_time = parseDateTime(query.value(4)); topics.append(topic); } } else { -- cgit v1.2.3