diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-11-03 06:38:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-11-03 06:38:20 (GMT) |
commit | 3cc9c5f2541f192733436c79c4d14aa34177c3cc (patch) | |
tree | 40446a431b66278a332a42139c30d615e89d94ae /examples/declarative | |
parent | a2ecba558d4722bfae9acea84e6e33e72187756d (diff) | |
download | Qt-3cc9c5f2541f192733436c79c4d14aa34177c3cc.zip Qt-3cc9c5f2541f192733436c79c4d14aa34177c3cc.tar.gz Qt-3cc9c5f2541f192733436c79c4d14aa34177c3cc.tar.bz2 |
highlightranges.qml example and visual test contained binding loop.
Also, the currentIndex stayed -1 since the views all bound to each
others currentIndex, which starts as -1.
Task-number: QTBUG-14794
Reviewed-by: Yann Bodson
Diffstat (limited to 'examples/declarative')
-rw-r--r-- | examples/declarative/modelviews/listview/highlightranges.qml | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml index 2716ee5..58d37a3 100644 --- a/examples/declarative/modelviews/listview/highlightranges.qml +++ b/examples/declarative/modelviews/listview/highlightranges.qml @@ -42,15 +42,14 @@ import QtQuick 1.0 import "content" Rectangle { + id: root + property int current: 0 width: 600; height: 300 // This example shows the same model in three different ListView items, // with different highlight ranges. The highlight ranges are set by the // preferredHighlightBegin and preferredHighlightEnd properties in ListView. // - // The second and third ListViews set their currentIndex to be the - // same as the first. The first ListView is given keyboard focus. - // // The first ListView does not set a highlight range, so its currentItem // can move freely within the visible area. If it moves outside the // visible area, the view is automatically scrolled to keep the current @@ -66,9 +65,10 @@ Rectangle { // forces the current item to change when the view is flicked, // since the highlight is unable to move. // - // Note that the first ListView sets its currentIndex to be equal to - // the third ListView's currentIndex. By flicking the third ListView with - // the mouse, the current index of the first ListView will be changed. + // All ListViews bind their currentIndex to the root.current property. + // The first ListView sets root.current whenever its currentIndex changes + // due to keyboard interaction. + // Flicking the third ListView with the mouse also changes root.current. ListView { id: list1 @@ -77,7 +77,8 @@ Rectangle { delegate: petDelegate highlight: Rectangle { color: "lightsteelblue" } - currentIndex: list3.currentIndex + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex focus: true } @@ -89,7 +90,7 @@ Rectangle { delegate: petDelegate highlight: Rectangle { color: "yellow" } - currentIndex: list1.currentIndex + currentIndex: root.current preferredHighlightBegin: 80; preferredHighlightEnd: 220 highlightRangeMode: ListView.ApplyRange } @@ -102,7 +103,8 @@ Rectangle { delegate: petDelegate highlight: Rectangle { color: "yellow" } - currentIndex: list1.currentIndex + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex preferredHighlightBegin: 125; preferredHighlightEnd: 125 highlightRangeMode: ListView.StrictlyEnforceRange } |