diff options
author | Olivier Tilloy <olivier.tilloy@canonical.com> | 2012-10-09 18:29:28 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier.tilloy@canonical.com> | 2012-10-09 18:29:28 +0200 |
commit | f5e0285a2027fc50ae7f47b56ed2d2b2738fe6b2 (patch) | |
tree | 8ac6c15e52de26463d0c361513f9e261bee5324c | |
parent | a03e7e775a9751f87efb8fd7acf226b5eb25f4e3 (diff) | |
download | qmenumodel-f5e0285a2027fc50ae7f47b56ed2d2b2738fe6b2.tar.gz qmenumodel-f5e0285a2027fc50ae7f47b56ed2d2b2738fe6b2.tar.bz2 qmenumodel-f5e0285a2027fc50ae7f47b56ed2d2b2738fe6b2.zip |
Reset the navigation history when the connection to the model is lost.
-rw-r--r-- | examples/render-menumodel.qml | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/render-menumodel.qml b/examples/render-menumodel.qml index 1ad41c5..d7c650e 100644 --- a/examples/render-menumodel.qml +++ b/examples/render-menumodel.qml @@ -15,7 +15,11 @@ Item { busType: DBus.SessionBus busName: "com.canonical.testmenu" objectPath: "/com/canonical/testmenu" - onStatusChanged: console.log("status of menu model changed to", status) + onStatusChanged: { + if (status == DBus.Connecting) { + view.reset() + } + } } ListView { @@ -28,7 +32,6 @@ Item { anchors.margins: 10 spacing: 3 model: menuModel - Component.onCompleted: menuModel.start() delegate: Rectangle { width: parent.width height: 30 @@ -85,6 +88,11 @@ Item { newback.pop() view.__back = newback } + function reset() { + while (view.__back.length > 0) { + goback() + } + } } Rectangle { @@ -132,5 +140,7 @@ Item { font.pixelSize: 11 } } + + Component.onCompleted: menuModel.start() } |