summaryrefslogtreecommitdiff
path: root/metawatch/qml/MWListView.qml
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-12-02 20:31:12 +0100
committerJavier S. Pedro <maemo@javispedro.com>2011-12-02 20:31:12 +0100
commitcd220a213060b6211330699ec6a3830593945a24 (patch)
treeffc66db575419828da9262c9ba07e1204075767f /metawatch/qml/MWListView.qml
parent88d6c8d388bd73e1f2ee1c23df221f8d3c6208d9 (diff)
downloadsowatch-cd220a213060b6211330699ec6a3830593945a24.tar.gz
sowatch-cd220a213060b6211330699ec6a3830593945a24.zip
moving some resources to the filesystem
Diffstat (limited to 'metawatch/qml/MWListView.qml')
-rw-r--r--metawatch/qml/MWListView.qml59
1 files changed, 59 insertions, 0 deletions
diff --git a/metawatch/qml/MWListView.qml b/metawatch/qml/MWListView.qml
new file mode 100644
index 0000000..e49905b
--- /dev/null
+++ b/metawatch/qml/MWListView.qml
@@ -0,0 +1,59 @@
+import QtQuick 1.0
+
+ListView {
+ id: list
+
+ property bool selectable: true
+
+ //interactive: false
+ highlightFollowsCurrentItem: false
+ boundsBehavior: Flickable.StopAtBounds
+
+ property real currentItemTop: currentItem.y - contentY
+ property real currentItemBottom: currentItemTop + currentItem.height
+
+ function _scrollSelectable(dir) {
+ var maxy = contentHeight - height;
+ if (maxy < 0) maxy = 0;
+
+ console.log(contentHeight);
+
+ var newy = contentY;
+
+ if (dir > 0) {
+ if (currentIndex < count && currentItemBottom < height) {
+ // If the next item is visible, highlight it
+ list.incrementCurrentIndex();
+ }
+ if (currentItemBottom >= height) {
+ // If the next item now is still not visible, scroll
+ newy += 96/3;
+ }
+ } else {
+ if (currentIndex >= 0 && currentItemTop > 0) {
+ // If the previous item is visible, highlight it
+ list.decrementCurrentIndex();
+ }
+ if (currentItemTop <= 0) {
+ // If the previous item now is still not visible, scroll
+ newy -= 96/3;
+ }
+ }
+
+ //if (newy < 0) newy = 0;
+ //if (newy > maxy) newy = maxy;
+ list.contentY = newy;
+ }
+
+ function scrollDown() {
+ if (selectable) {
+ _scrollSelectable(+1);
+ }
+ }
+
+ function scrollUp() {
+ if (selectable) {
+ _scrollSelectable(-1);
+ }
+ }
+}