diff options
Diffstat (limited to 'board.cpp')
-rw-r--r-- | board.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
@@ -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 { |