From 37139c96f04f781b053feefdbb5b3d28b2bcfc11 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 4 Apr 2013 23:37:52 +0200 Subject: fix timezones on real device --- topicmodel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'topicmodel.cpp') diff --git a/topicmodel.cpp b/topicmodel.cpp index d3032be..653934a 100644 --- a/topicmodel.cpp +++ b/topicmodel.cpp @@ -105,6 +105,8 @@ QVariant TopicModel::data(const QModelIndex &index, int role) const case HumanDateRole: case HumanTimeRole: return QVariant::fromValue(QString()); + case IconRole: + return QVariant::fromValue(QUrl()); case DateTimeRole: return QVariant::fromValue(QDateTime()); case UnreadRole: @@ -119,6 +121,8 @@ QVariant TopicModel::data(const QModelIndex &index, int role) const return _data[row].title; case ContentRole: return _data[row].content; + case IconRole: + return _data[row].icon; case PostIdRole: return _data[row].post_id; case UserIdRole: @@ -130,7 +134,7 @@ QVariant TopicModel::data(const QModelIndex &index, int role) const case HumanDateRole: return _board->renderHumanDate(_data[row].time); case HumanTimeRole: - return _board->renderHumanTime(_data[row].time); + return _board->renderHumanDateTime(_data[row].time); case UnreadRole: return _firstUnread >= 0 && row >= _firstUnread; } @@ -168,7 +172,7 @@ void TopicModel::fetchMore(const QModelIndex &parent) if (!posts.empty()) { QDateTime last = oldestPostUpdate(posts); // If the posts we got from DB are too old, refresh online. - if (last.secsTo(QDateTime::currentDateTime()) > TOPIC_POSTS_TLL) { + if (last.secsTo(QDateTime::currentDateTimeUtc()) > TOPIC_POSTS_TLL) { qDebug() << "Fetching posts because of old"; Q_ASSERT(new_end > 0); _board->enqueueAction(new FetchPostsAction(_topicId, @@ -211,7 +215,7 @@ QDateTime TopicModel::parseDbDateTime(const QVariant &v) QDateTime TopicModel::oldestPostUpdate(const QList &posts) { - if (posts.empty()) return QDateTime::currentDateTime(); + if (posts.empty()) return QDateTime::currentDateTimeUtc(); QDateTime min = posts.first().last_update_time; foreach (const Post& post, posts) { if (min < post.last_update_time) min = post.last_update_time; @@ -374,7 +378,7 @@ void TopicModel::update() if (!_board->service()->isAccessible()) return; QDateTime last = lastTopPostUpdate(); if (!last.isValid() || - last.secsTo(QDateTime::currentDateTime()) > TOPIC_TOP_TLL) { + last.secsTo(QDateTime::currentDateTimeUtc()) > TOPIC_TOP_TLL) { qDebug() << "Fetching posts because the top are old"; // Outdated or empty, refresh. if (_board->loggedIn() && _board->getConfig("goto_unread") == "1") { -- cgit v1.2.3