summaryrefslogtreecommitdiff
path: root/board.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-06 20:34:56 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-06 20:34:56 +0200
commitcb820fa02315cbf5ecc7f87435bc724460104f19 (patch)
tree19d089a0506c7da82f4e91af8e7df928d813a479 /board.cpp
parentb04a2a981a91ed58e55a275402cb2f9f73bd85a2 (diff)
downloadtapasboard-cb820fa02315cbf5ecc7f87435bc724460104f19.tar.gz
tapasboard-cb820fa02315cbf5ecc7f87435bc724460104f19.zip
support replying to posts
Diffstat (limited to 'board.cpp')
-rw-r--r--board.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/board.cpp b/board.cpp
index 5878475..7e734cb 100644
--- a/board.cpp
+++ b/board.cpp
@@ -9,6 +9,7 @@
#include "fetchconfigaction.h"
#include "fetchforumsaction.h"
#include "loginaction.h"
+#include "newpostaction.h"
#include "xmlrpcinterface.h"
#include "board.h"
@@ -150,6 +151,29 @@ void Board::logout()
// TODO
}
+int Board::getTopicForumId(int topicId)
+{
+ QSqlQuery q(_db);
+ q.prepare("SELECT forum_id FROM topics WHERE topic_id = ?");
+ q.bindValue(0, topicId);
+ if (q.exec()) {
+ if (q.next()) {
+ return q.value(0).toInt();
+ } else {
+ qWarning() << "Could not get forum of topic";
+ }
+ } else {
+ qWarning() << "Could not get forum of topic:" << q.lastError().text();
+ }
+
+ return -1;
+}
+
+void Board::replyToTopic(int topicId, const QString &text)
+{
+ enqueueAction(new NewPostAction(topicId, text, this));
+}
+
QString Board::removeHtml(QString text) const
{
static const QRegExp regexp("<[a-zA-Z\\/][^>]*>");
@@ -322,18 +346,10 @@ void Board::markTopicAsRead(int topicId)
q.bindValue(0, topicId);
if (q.exec()) {
if (q.numRowsAffected() > 0) {
- q.prepare("SELECT forum_id FROM topics WHERE topic_id = ?");
- q.bindValue(0, topicId);
- if (q.exec()) {
- if (q.next()) {
- int forum_id = q.value(0).toInt();
- notifyForumTopicChanged(forum_id, topicId);
- updateForumReadState(forum_id);
- } else {
- qWarning() << "Could not get forum of topic";
- }
- } else {
- qWarning() << "Could not get forum of topic:" << q.lastError().text();
+ int forum_id = getTopicForumId(topicId);
+ if (forum_id >= 0) {
+ notifyForumTopicChanged(forum_id, topicId);
+ updateForumReadState(forum_id);
}
}
} else {