diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-14 23:06:12 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-14 23:06:12 (GMT) |
commit | 35cad893a9e92cf36794610a6a718f56b64f9018 (patch) | |
tree | 85b76a5a7ba9b80700b39c0462dd255b4a11a6cf /examples/declarative/listview | |
parent | 788da2e8b85f3773a525a6f2bcc535fa38ed02b2 (diff) | |
download | Qt-35cad893a9e92cf36794610a6a718f56b64f9018.zip Qt-35cad893a9e92cf36794610a6a718f56b64f9018.tar.gz Qt-35cad893a9e92cf36794610a6a718f56b64f9018.tar.bz2 |
ListView currentItemMode API replaced with highlight range API.
Diffstat (limited to 'examples/declarative/listview')
-rw-r--r-- | examples/declarative/listview/itemlist.qml | 4 | ||||
-rw-r--r-- | examples/declarative/listview/listview.qml | 43 |
2 files changed, 23 insertions, 24 deletions
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml index 061fab3..01781ec 100644 --- a/examples/declarative/listview/itemlist.qml +++ b/examples/declarative/listview/itemlist.qml @@ -29,7 +29,9 @@ Rectangle { anchors.fill: parent anchors.bottomMargin: 30 model: ItemModel - currentItemPositioning: "SnapAuto" + preferredHighlightBegin: 0 + preferredHighlightEnd: 1 + strictlyEnforceHighlightRange: true orientation: "Horizontal" } diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml index 1cca5ad..ac1cef1 100644 --- a/examples/declarative/listview/listview.qml +++ b/examples/declarative/listview/listview.qml @@ -29,21 +29,24 @@ Rectangle { Rectangle { color: "#FFFF88" } } - // Show the model in three lists, with different currentItemPositioning. - // currentItemPositioning determines how the list behaves when the - // current item changes. Note that the second and third ListView + // Show the model in three lists, with different highlight ranges. + // preferredHighlightBegin and preferredHighlightEnd set the + // range in which to attempt to maintain the highlight. + // Note that the second and third ListView // set their currentIndex to be the same as the first, and that // the first ListView is given keyboard focus. - // The default mode, Free, allows the currentItem to move freely + // The default mode allows the currentItem to move freely // within the visible area. If it would move outside the visible // area, the view is scrolled to keep it visible. - // Snap currentItemPositioning attempts to keep the current item - // aligned with the snapPosition by scrolling the view, however the - // items will not scroll beyond the beginning or end of the view. - // SnapAuto currentItemPositioning always keeps the current item on - // the snapPosition by scrolling the view. It also automatically - // sets the current item as is scrolled with the mouse. Note - // that the first ListView sets its currentIndex to be equal to + // The second list sets a highlight range which attempts to keep the + // current item within the the bounds of the range, however + // items will not scroll beyond the beginning or end of the view, + // forcing the highlight to move outside the range at the ends. + // The third list sets strictlyEnforceHighlightRange to true + // and sets a range smaller than the height of an item. This + // 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 List3 with // the mouse, the current index of List1 will be changed. ListView { @@ -57,23 +60,17 @@ Rectangle { id: List2 x: 200; width: 200; height: parent.height model: MyPetsModel; delegate: PetDelegate; highlight: PetHighlight - currentItemPositioning: "Snap"; snapPosition: 125 + preferredHighlightBegin: 80 + preferredHighlightEnd: 220 currentIndex: List1.currentIndex } ListView { id: List3 x: 400; width: 200; height: parent.height - model: MyPetsModel; delegate: PetDelegate - currentItemPositioning: "SnapAuto"; snapPosition: 125 + model: MyPetsModel; delegate: PetDelegate; highlight: PetHighlight currentIndex: List1.currentIndex - - // Position a static highlight rather than a normal highlight so that - // when the view is flicked, the highlight does not move. - // By positioning the highlight at the same position as the snapPosition - // the item under the highlight will always be the current item. - Rectangle { - y: 125; width: 200; height: 50 - color: "#FFFF88"; z: -1 - } + preferredHighlightBegin: 125 + preferredHighlightEnd: 126 + strictlyEnforceHighlightRange: true } } |