summaryrefslogtreecommitdiff
path: root/fetchtopicsaction.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-01 20:46:39 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-01 20:46:39 +0200
commita6e64fbf9404b201b04fbd1ab4b959a18d8f83a9 (patch)
tree6b97b6ac14716dbe51cb105819abde3e36ffd465 /fetchtopicsaction.cpp
parent5ef8b38e55c1883224fe1f01f47aba45b7b42666 (diff)
downloadtapasboard-a6e64fbf9404b201b04fbd1ab4b959a18d8f83a9.tar.gz
tapasboard-a6e64fbf9404b201b04fbd1ab4b959a18d8f83a9.zip
add support for actually reading topics
Diffstat (limited to 'fetchtopicsaction.cpp')
-rw-r--r--fetchtopicsaction.cpp23
1 files changed, 18 insertions, 5 deletions
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<FetchTopicsAction*>(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<QVariantMap> 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";