From 758cec1a767c056aaf9da36fd411cdf4a8fba32e Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Tue, 14 Aug 2012 00:11:51 +0200 Subject: rewrite live notifications handling using models --- notificationswatchlet/metawatch-digital.qml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'notificationswatchlet') diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml index 57a6176..fcd1081 100644 --- a/notificationswatchlet/metawatch-digital.qml +++ b/notificationswatchlet/metawatch-digital.qml @@ -18,7 +18,7 @@ MWPage { anchors.right: parent.right anchors.bottom: parent.bottom clip: true - model: watch.notifications + model: notifications delegate: Rectangle { id: notifDelegate @@ -30,14 +30,14 @@ MWPage { width: parent.width MWLabel { width: parent.width - text: model.modelData.title + text: title wrapMode: Text.WrapAtWordBoundaryOrAnywhere color: notifDelegate.selected ? "white" : "black" font.pointSize: 12 } MWLabel { width: parent.width - text: model.modelData.body + text: body wrapMode: Text.WrapAtWordBoundaryOrAnywhere color: notifDelegate.selected ? "white" : "black" } @@ -56,7 +56,7 @@ MWPage { Connections { target: watch - onButtonPressed : { + onButtonPressed: { switch (button) { case 1: notifs.scrollUp(); @@ -67,4 +67,20 @@ MWPage { } } } + + Connections { + target: notifications + onRowsInserted: { + if (!watch.active) { + // Always position into the topmost notification if + // user is not looking at this list + notifs.scrollTop(); + } + } + onRowsRemoved: { + if (!watch.active) { + notifs.scrollTop(); + } + } + } } -- cgit v1.2.3