summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-05 00:19:21 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-05 00:19:21 +0200
commita4626f5306ed3c5e52c28bb49d61ec50c7c2f329 (patch)
tree471a48e17021cb969a9b76bce2010c83e90e7620
parent37139c96f04f781b053feefdbb5b3d28b2bcfc11 (diff)
downloadtapasboard-a4626f5306ed3c5e52c28bb49d61ec50c7c2f329.tar.gz
tapasboard-a4626f5306ed3c5e52c28bb49d61ec50c7c2f329.zip
add avatars to topic view
-rw-r--r--qml/TopicPage.qml32
-rw-r--r--topicmodel.cpp11
2 files changed, 36 insertions, 7 deletions
diff --git a/qml/TopicPage.qml b/qml/TopicPage.qml
index 9835a06..ebaa2c6 100644
--- a/qml/TopicPage.qml
+++ b/qml/TopicPage.qml
@@ -77,23 +77,51 @@ Page {
spacing: 2
Item {
+ id: authorInfo
+
width: parent.width
height: childrenRect.height
+ Image {
+ id: authorIcon
+ height: 48
+ width: 48
+ fillMode: Image.PreserveAspectFit
+ source: model.icon
+ sourceSize.height: 48
+ }
+
Text {
- anchors.top: parent.top
- anchors.left: parent.left
+ id: authorName
text: model.userName
font: UiConstants.SmallTitleFont
textFormat: Text.PlainText
}
+
Text {
+ id: authorTime
anchors.top: parent.top
anchors.right: parent.right
text: model.humanTime
font: UiConstants.SubtitleFont
textFormat: Text.PlainText
}
+
+ states: State {
+ name: "with-image"
+ when: authorIcon.status === Image.Ready
+
+ AnchorChanges {
+ target: authorName
+ anchors.bottom: authorIcon.bottom
+ anchors.left: authorIcon.right
+ }
+
+ PropertyChanges {
+ target: authorName
+ anchors.leftMargin: UiConstants.ButtonSpacing
+ }
+ }
}
Text {
diff --git a/topicmodel.cpp b/topicmodel.cpp
index 653934a..65d3e4b 100644
--- a/topicmodel.cpp
+++ b/topicmodel.cpp
@@ -248,7 +248,7 @@ QList<TopicModel::Post> TopicModel::loadPosts(int start, int end)
Q_ASSERT(_board);
QList<Post> posts;
QSqlQuery query(_board->database());
- query.prepare("SELECT post_id, post_title, post_content, post_author_id, post_author_name, post_time, last_update_time FROM posts "
+ query.prepare("SELECT post_id, post_title, post_content, icon_url, post_author_id, post_author_name, post_time, last_update_time FROM posts "
"WHERE topic_id = :topic_id AND position BETWEEN :start AND :end "
"ORDER by position ASC ");
query.bindValue(":topic_id", _topicId);
@@ -262,10 +262,11 @@ QList<TopicModel::Post> TopicModel::loadPosts(int start, int end)
post.post_id = query.value(0).toInt();
post.title = query.value(1).toString();
post.content = query.value(2).toString();
- post.user_id = query.value(3).toInt();
- post.user_name = query.value(4).toString();
- post.time = parseDbDateTime(query.value(5));
- post.last_update_time = parseDbDateTime(query.value(6));
+ post.icon = query.value(3).toUrl();
+ post.user_id = query.value(4).toInt();
+ post.user_name = query.value(5).toString();
+ post.time = parseDbDateTime(query.value(6));
+ post.last_update_time = parseDbDateTime(query.value(7));
posts.append(post);
loaded++;
}