diff options
Diffstat (limited to 'board.cpp')
-rw-r--r-- | board.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -15,15 +15,14 @@ const QLatin1String Board::CURRENT_DB_VERSION("testing1"); Board::Board(QObject *parent) : - QObject(parent) + QObject(parent) { } Board::Board(const QUrl& url, const QString& username, const QString& password, QObject *parent) : - QObject(parent), _url(url), _slug(createSlug(url)), - _db(QSqlDatabase::addDatabase("QSQLITE", _slug)), - _iface(new XmlRpcInterface(QUrl(_url), this)), - _markReadDelay(new QTimer(this)) + QObject(parent), _url(url), _slug(createSlug(url)), + _db(QSqlDatabase::addDatabase("QSQLITE", _slug)), + _iface(new XmlRpcInterface(QUrl(_url), this)) { _db.setDatabaseName(QDir::toNativeSeparators(getDbPathFor(_slug))); qDebug() << "Opening database file" << _db.databaseName() << "for" << _url; @@ -49,7 +48,6 @@ Board::Board(const QUrl& url, const QString& username, const QString& password, fetchForumsIfOutdated(); initializeBbCode(); // TODO This might depend on board config initializeSmilies(); - initializeMarkRead(); } Board::~Board() @@ -600,13 +598,6 @@ void Board::initializeSmilies() Q_ASSERT(_smilieRegexp.isValid()); } -void Board::initializeMarkRead() -{ - _markReadDelay->setInterval(1000); // 1 sec - _markReadDelay->setSingleShot(true); - // TODO connect -} - void Board::fetchConfigIfOutdated() { if (_iface->isAccessible()) { @@ -642,7 +633,12 @@ void Board::updateForumReadState(int forumId) qWarning() << "Could not select unread topics from forum:" << q.lastError().text(); return; } - int unread_topics = q.value(0).toInt(); + + int unread_topics = 0; + if (q.next()) { + unread_topics = q.value(0).toInt(); + } + int new_post = (unread_topics > 0) ? 1 : 0; q.prepare("UPDATE forums SET new_post = :new_post WHERE forum_id = :forum_id AND new_post != :cur_new_post"); |