From 1a66f6ee4f3806e2a18af718654e7281c7dd1066 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 7 Apr 2013 00:59:24 +0200 Subject: fix some issues --- board.cpp | 1 + fetchtopicsaction.cpp | 14 ++++++-------- forummodel.cpp | 8 +++++--- global.h | 2 +- topicmodel.cpp | 4 +++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/board.cpp b/board.cpp index 5a755c7..da469dc 100644 --- a/board.cpp +++ b/board.cpp @@ -603,6 +603,7 @@ void Board::initializeSmilies() _smilies[":O"] = "image://theme/icon-s-messaging-smiley-surprised"; _smilies["O_O"] = "image://theme/icon-s-messaging-smiley-surprised"; _smilies["O_o"] = "image://theme/icon-s-messaging-smiley-surprised"; + _smilies[":shock:"] = "image://theme/icon-s-messaging-smiley-surprised"; _smilies[":evil:"] = "image://theme/icon-s-messaging-smiley-evil"; // Let's construct a single regular expression that will cover all smilies diff --git a/fetchtopicsaction.cpp b/fetchtopicsaction.cpp index d8ea173..4617280 100644 --- a/fetchtopicsaction.cpp +++ b/fetchtopicsaction.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -43,7 +44,7 @@ void FetchTopicsAction::execute() int end = _end; if (end == FetchAllTopics) { // Fetch topics in blocks of size 50. - end = _start + MAX_FORUM_PAGE_SIZE; + end = _start + MAX_FORUM_PAGE_SIZE - 1; // After finishing this action, a new one will be enqueued with the next 50. } @@ -63,9 +64,9 @@ void FetchTopicsAction::handleFinishedCall() db.transaction(); const int total_topic_num = map["total_topic_num"].toInt(); - int expected_end = _end == FetchAllTopics ? _start + MAX_FORUM_PAGE_SIZE : _end; - QList current_topics = getCurrentDbTopics(_start, expected_end); - QList unchanged_topics = current_topics; + int expected_end = _end == FetchAllTopics ? _start + MAX_FORUM_PAGE_SIZE - 1 : _end; + QSet current_topics = QSet::fromList(getCurrentDbTopics(_start, expected_end)); + QSet unchanged_topics = current_topics; if (_start >= total_topic_num) { // Workaround an issue where the service always returns one post. @@ -119,12 +120,9 @@ void FetchTopicsAction::handleFinishedCall() goto finish; } - unchanged_topics.removeOne(topic_id); + unchanged_topics.remove(topic_id); } - // "position" would now point to "_end + 1", if we had gotten as - // many topics as we requested. - int fetched_end = position - 1; bool eof = fetched_end < expected_end; if (eof) { diff --git a/forummodel.cpp b/forummodel.cpp index 7408f32..ea54f8e 100644 --- a/forummodel.cpp +++ b/forummodel.cpp @@ -158,7 +158,9 @@ void ForumModel::refresh() QDateTime ForumModel::parseDateTime(const QVariant &v) { QString s = v.toString(); - return QDateTime::fromString(s, Qt::ISODate); + QDateTime dt = QDateTime::fromString(s, Qt::ISODate); + dt.setTimeSpec(Qt::UTC); + return dt; } QDateTime ForumModel::oldestPostUpdate(const QList &topics) @@ -282,10 +284,10 @@ void ForumModel::handleForumTopicsChanged(int forumId, int start, int end) void ForumModel::handleForumTopicChanged(int forumId, int topicId) { - if (forumId == _forumId) {qDebug() << "Me topic cha"; + if (forumId == _forumId) { for (int i = 0; i < _data.size(); i++) { Topic& topic = _data[i]; - if (topic.topic_id == topicId) {qDebug() << "Me topic cha cha"; + if (topic.topic_id == topicId) { // Need to refresh this topic QList topics = loadTopics(i, i); if (topics.size() == 1) { diff --git a/global.h b/global.h index 74f972e..6dab018 100644 --- a/global.h +++ b/global.h @@ -10,7 +10,7 @@ #define BOARD_LIST_TTL 2 /** Time we should consider the most recent topics in a forum up to date, in seconds. */ -#define FORUM_TOP_TLL 5 * 60 +#define FORUM_TOP_TLL 15 * 60 /** Time we should consider other topics in a forum up to date, in seconds. */ #define FORUM_TOPICS_TLL 15 * 60 diff --git a/topicmodel.cpp b/topicmodel.cpp index c7932aa..4188784 100644 --- a/topicmodel.cpp +++ b/topicmodel.cpp @@ -210,7 +210,9 @@ void TopicModel::markAsRead() QDateTime TopicModel::parseDbDateTime(const QVariant &v) { QString s = v.toString(); - return QDateTime::fromString(s, Qt::ISODate); + QDateTime dt = QDateTime::fromString(s, Qt::ISODate); + dt.setTimeSpec(Qt::UTC); + return dt; } QDateTime TopicModel::oldestPostUpdate(const QList &posts) -- cgit v1.2.3