diff options
-rw-r--r-- | board.cpp | 10 | ||||
-rw-r--r-- | forummodel.cpp | 11 | ||||
-rw-r--r-- | forummodel.h | 2 | ||||
-rw-r--r-- | qml/tapasboard/ForumPage.qml | 10 | ||||
-rw-r--r-- | qml/tapasboard/MainPage.qml | 5 |
5 files changed, 29 insertions, 9 deletions
@@ -11,7 +11,7 @@ #include "xmlrpcinterface.h" #include "board.h" -const QLatin1String Board::CURRENT_DB_VERSION("testing2"); +const QLatin1String Board::CURRENT_DB_VERSION("testing1"); Board::Board(QObject *parent) : QObject(parent) @@ -284,8 +284,15 @@ void Board::notifyLogout() QString Board::createSlug(const QUrl& url) { static const QRegExp regexp("[^a-z0-9]+"); + static const QString mobiquo_default_endpoint("/mobiquo.php"); QString slug = url.toString(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash); slug = slug.toLower(); + if (slug.startsWith("//")) { + slug.remove(0, 2); + } + if (slug.endsWith(mobiquo_default_endpoint)) { + slug.chop(mobiquo_default_endpoint.size()); + } slug.replace(regexp, "_"); return slug; } @@ -479,7 +486,6 @@ void Board::initializeSmilies() regexp += QRegExp::escape(i.key()); } regexp += ")[^A-Za-z]"; - qDebug() << "Smilie regexp: " << regexp; _smilieRegexp = QRegExp(regexp); Q_ASSERT(_smilieRegexp.isValid()); } diff --git a/forummodel.cpp b/forummodel.cpp index 4d59916..63fb0b8 100644 --- a/forummodel.cpp +++ b/forummodel.cpp @@ -14,7 +14,7 @@ ForumModel::ForumModel(QObject *parent) : roles[TitleRole] = QByteArray("title"); roles[IconRole] = QByteArray("icon"); roles[TopicIdRole] = QByteArray("topicId"); - roles[NumPostsRole] = QByteArray("numPosts"); + roles[NumRepliesRole] = QByteArray("numReplies"); setRoleNames(roles); } @@ -82,7 +82,7 @@ QVariant ForumModel::data(const QModelIndex &index, int role) const return _data[row].title; case TopicIdRole: return _data[row].topic_id; - case NumPostsRole: + case NumRepliesRole: return _data[row].num_replies; } @@ -190,7 +190,7 @@ QList<ForumModel::Topic> ForumModel::loadTopics(int start, int end) const int rows = end - start + 1; QList<Topic> topics; QSqlQuery query(_board->database()); - query.prepare("SELECT topic_id, topic_title, last_reply_time, last_update_time FROM topics " + query.prepare("SELECT topic_id, topic_title, reply_number, last_reply_time, last_update_time FROM topics " "WHERE forum_id = :forum_id " "ORDER by last_reply_time DESC " "LIMIT :start, :limit"); @@ -203,8 +203,9 @@ QList<ForumModel::Topic> ForumModel::loadTopics(int start, int end) Topic topic; topic.topic_id = query.value(0).toInt(); topic.title = query.value(1).toString(); - topic.last_reply_time = parseDateTime(query.value(2)); - topic.last_update_time = parseDateTime(query.value(3)); + topic.num_replies = query.value(2).toInt(); + topic.last_reply_time = parseDateTime(query.value(3)); + topic.last_update_time = parseDateTime(query.value(4)); topics.append(topic); } } else { diff --git a/forummodel.h b/forummodel.h index 0458cfd..4c00692 100644 --- a/forummodel.h +++ b/forummodel.h @@ -22,7 +22,7 @@ public: TopicIdRole = Qt::UserRole, TopicTypeRole, - NumPostsRole + NumRepliesRole }; Board * board() const; diff --git a/qml/tapasboard/ForumPage.qml b/qml/tapasboard/ForumPage.qml index aed65a0..96b8082 100644 --- a/qml/tapasboard/ForumPage.qml +++ b/qml/tapasboard/ForumPage.qml @@ -45,7 +45,7 @@ Page { Column { id: topicItemColumn anchors.left: parent.left - anchors.right: topicItemImage.left + anchors.right: topicRepliesCount.left anchors.verticalCenter: parent.verticalCenter Text { @@ -56,6 +56,14 @@ Page { } } + CountBubble { + id: topicRepliesCount + anchors.right: topicItemImage.left + anchors.verticalCenter: parent.verticalCenter + value: model.numReplies + visible: value > 0 + } + Image { id: topicItemImage source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "") diff --git a/qml/tapasboard/MainPage.qml b/qml/tapasboard/MainPage.qml index f94b505..e0e8fb8 100644 --- a/qml/tapasboard/MainPage.qml +++ b/qml/tapasboard/MainPage.qml @@ -4,6 +4,11 @@ import com.nokia.extras 1.1 import com.javispedro.tapasboard 1.0 Page { + id: mainPage + + anchors.leftMargin: UiConstants.DefaultMargin + anchors.rightMargin: UiConstants.DefaultMargin + ListView { id: favoritesView anchors.fill: parent |