summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/modelviews/listview/highlightranges.qml20
-rw-r--r--tests/auto/declarative/qmlvisual/ListView/listview.qml12
2 files changed, 19 insertions, 13 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
}
diff --git a/tests/auto/declarative/qmlvisual/ListView/listview.qml b/tests/auto/declarative/qmlvisual/ListView/listview.qml
index 43c86a0..6171c75 100644
--- a/tests/auto/declarative/qmlvisual/ListView/listview.qml
+++ b/tests/auto/declarative/qmlvisual/ListView/listview.qml
@@ -1,7 +1,8 @@
import QtQuick 1.0
Rectangle {
- property string skip: "Incorrect start: QTBUG-14794"
+ id: root
+ property int current: 0
width: 600; height: 300; color: "white"
ListModel {
@@ -57,7 +58,9 @@ Rectangle {
id: list1
width: 200; height: parent.height
model: myModel; delegate: myDelegate
- highlight: myHighlight; currentIndex: list3.currentIndex
+ highlight: myHighlight
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
focus: true
}
ListView {
@@ -67,13 +70,14 @@ Rectangle {
preferredHighlightBegin: 80
preferredHighlightEnd: 220
highlightRangeMode: "ApplyRange"
- currentIndex: list1.currentIndex
+ currentIndex: root.current
}
ListView {
id: list3
x: 400; width: 200; height: parent.height
model: myModel; delegate: myDelegate; highlight: myHighlight
- currentIndex: list1.currentIndex
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
preferredHighlightBegin: 125
preferredHighlightEnd: 125
highlightRangeMode: "StrictlyEnforceRange"