From a6e64fbf9404b201b04fbd1ab4b959a18d8f83a9 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 1 Apr 2013 20:46:39 +0200 Subject: add support for actually reading topics --- fetchtopicsaction.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'fetchtopicsaction.cpp') diff --git a/fetchtopicsaction.cpp b/fetchtopicsaction.cpp index 5661da8..dd59b4d 100644 --- a/fetchtopicsaction.cpp +++ b/fetchtopicsaction.cpp @@ -13,6 +13,19 @@ FetchTopicsAction::FetchTopicsAction(int forumId, int start, int end, Board *boa { } +bool FetchTopicsAction::isSupersetOf(Action *action) const +{ + FetchTopicsAction *other = qobject_cast(action); + if (other) { + if (other->_forumId == _forumId) { + if (_start <= other->_start && _end >= other->_end) { + return true; + } + } + } + return false; +} + void FetchTopicsAction::execute() { _call = _board->service()->asyncCall("get_topic", @@ -20,8 +33,6 @@ void FetchTopicsAction::execute() connect(_call, SIGNAL(finished(XmlRpcPendingCall*)), SLOT(handleFinishedCall())); } -// forum_id INTEGER, topic_id INTEGER PRIMARY KEY, topic_title TEXT, topic_author_id INTEGER, topic_author_name TEXT, is_subscribed BOOL, is_closed BOOL, icon_url TEXT, last_reply_time TEXT, new_post BOOL - void FetchTopicsAction::handleFinishedCall() { XmlRpcReply result(_call); @@ -40,12 +51,12 @@ void FetchTopicsAction::handleFinishedCall() bool ok = false; int forum_id = topic["forum_id"].toInt(&ok); if (!ok) { - qWarning() << "No forum_id in" << topic; - continue; + // Not fatal, just use the one we expected. + forum_id = _forumId; } int topic_id = topic["topic_id"].toInt(&ok); if (!ok) { - qWarning() << "No parent_id in" << topic; + qWarning() << "No topic_id in" << topic; continue; } @@ -72,6 +83,8 @@ void FetchTopicsAction::handleFinishedCall() if (topics.size() > 0) { _board->notifyForumTopicsChanged(_forumId, _start, _start + topics.size() - 1); + } else { + qWarning() << "Asked for topics, got none..."; } } else { qWarning() << "Could not fetch topics"; -- cgit v1.2.3