diff options
Diffstat (limited to 'forummodel.cpp')
-rw-r--r-- | forummodel.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
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::Topic> ForumModel::loadTopics(int start, int end) const int rows = end - start + 1; QList<Topic> 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::Topic> 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 { |