summaryrefslogtreecommitdiff
path: root/topicmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'topicmodel.cpp')
-rw-r--r--topicmodel.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/topicmodel.cpp b/topicmodel.cpp
index 0c7541e..965481f 100644
--- a/topicmodel.cpp
+++ b/topicmodel.cpp
@@ -8,7 +8,7 @@
#include "topicmodel.h"
TopicModel::TopicModel(QObject *parent) :
- QAbstractListModel(parent), _boardUrl(), _board(0), _topicId(-1)
+ QAbstractListModel(parent), _board(0), _topicId(-1), _eof(false)
{
QHash<int, QByteArray> roles = roleNames();
roles[TitleRole] = QByteArray("title");
@@ -23,21 +23,20 @@ TopicModel::TopicModel(QObject *parent) :
setRoleNames(roles);
}
-QString TopicModel::boardUrl() const
+Board * TopicModel::board() const
{
- return _boardUrl;
+ return _board;
}
-void TopicModel::setBoardUrl(const QString &url)
+void TopicModel::setBoard(Board *board)
{
- if (_boardUrl != url) {
+ if (_board != board) {
disconnect(this, SLOT(handleTopicPostsChanged(int,int,int)));
clearModel();
- _board = 0;
- _boardUrl = url;
- if (!_boardUrl.isEmpty()) {
- _board = board_manager->getBoard(_boardUrl);
+ _board = board;
+
+ if (_board) {
connect(_board, SIGNAL(topicPostsChanged(int,int,int)),
SLOT(handleTopicPostsChanged(int,int,int)));
if (_topicId >= 0) {
@@ -45,7 +44,7 @@ void TopicModel::setBoardUrl(const QString &url)
reload();
}
}
- emit boardUrlChanged();
+ emit boardChanged();
}
}
@@ -109,14 +108,14 @@ QVariant TopicModel::data(const QModelIndex &index, int role) const
bool TopicModel::canFetchMore(const QModelIndex &parent) const
{
- if (parent.isValid() || !_board) return false; // Invalid state
+ if (parent.isValid() || !_board || _topicId < 0) return false; // Invalid state
return !_eof;
}
void TopicModel::fetchMore(const QModelIndex &parent)
{
if (parent.isValid()) return;
- if (!_board) return;
+ if (!_board || _topicId < 0) return;
if (_eof) return;
const int start = _data.size();