summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-07 03:42:44 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-07 03:42:44 +0200
commit564f185e62e85fbd1662e9da06abbd853bab7266 (patch)
treeb86d32ef9d30bce584490cb74a0c50ff2852fe96
parent9e67c13e587ccf10084144fea033beda316faed5 (diff)
downloadtapasboard-564f185e62e85fbd1662e9da06abbd853bab7266.tar.gz
tapasboard-564f185e62e85fbd1662e9da06abbd853bab7266.zip
try to keep the first unread post in view while loading
-rw-r--r--qml/TopicPage.qml37
1 files changed, 37 insertions, 0 deletions
diff --git a/qml/TopicPage.qml b/qml/TopicPage.qml
index 32a86ec..8ff7127 100644
--- a/qml/TopicPage.qml
+++ b/qml/TopicPage.qml
@@ -12,6 +12,9 @@ Page {
property Board board;
property int topicId;
+ /** -1: Do not keep view; -2: Keep view on last post; >0: Keep view on a post. */
+ property int _keepView: -1;
+
tools: ToolBarLayout {
ToolIcon {
platformIconId: "toolbar-back"
@@ -42,9 +45,28 @@ Page {
}
ToolIcon {
platformIconId: "toolbar-view-menu"
+ onClicked: (topicMenu.status === DialogStatus.Closed) ? topicMenu.open() : topicMenu.close()
}
}
+ Menu {
+ id: topicMenu
+ MenuLayout {
+ MenuItem {
+ text: qsTr("Go to first post");
+ onClicked: postsView.positionViewAtIndex(0, ListView.Beginning);
+ }
+ MenuItem {
+ text: qsTr("Go to last post")
+ onClicked: {
+ _keepView = -2; // Keep on last post
+ postsView.positionViewAtEnd();
+ }
+ }
+ }
+
+ }
+
ListView {
id: postsView
anchors.fill: parent
@@ -56,6 +78,7 @@ Page {
onFirstUnreadPostChanged: {
postsView.positionViewAtIndex(firstUnreadPost, ListView.Beginning);
topicModel.markAsRead();
+ _keepView = firstUnreadPost;
}
}
section.property: "humanDate"
@@ -164,6 +187,20 @@ Page {
}
}
+ Connections {
+ target: _keepView !== -1 ? postsView : null
+ onMovementStarted: {
+ _keepView = -1; // Disable keep view
+ }
+ onContentHeightChanged: {
+ if (_keepView == -2) {
+ postsView.positionViewAtEnd();
+ } else if (_keepView >= 0) {
+ postsView.positionViewAtIndex(_keepView, ListView.Beginning);
+ }
+ }
+ }
+
ScrollDecorator {
flickableItem: postsView
}