aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickitem.cpp12
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml37
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp17
3 files changed, 60 insertions, 6 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 3f655e84fa..b5185efd54 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -465,8 +465,8 @@ void QQuickKeyNavigationAttached::setLeft(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->leftSet && d->left == i)
return;
+ d->leftSet = d->left != i;
d->left = i;
- d->leftSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->rightSet){
@@ -487,8 +487,8 @@ void QQuickKeyNavigationAttached::setRight(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->rightSet && d->right == i)
return;
+ d->rightSet = d->right != i;
d->right = i;
- d->rightSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->leftSet){
@@ -509,8 +509,8 @@ void QQuickKeyNavigationAttached::setUp(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->upSet && d->up == i)
return;
+ d->upSet = d->up != i;
d->up = i;
- d->upSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->downSet){
@@ -531,8 +531,8 @@ void QQuickKeyNavigationAttached::setDown(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->downSet && d->down == i)
return;
+ d->downSet = d->down != i;
d->down = i;
- d->downSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->upSet) {
@@ -553,8 +553,8 @@ void QQuickKeyNavigationAttached::setTab(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->tabSet && d->tab == i)
return;
+ d->tabSet = d->tab != i;
d->tab = i;
- d->tabSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->backtabSet) {
@@ -575,8 +575,8 @@ void QQuickKeyNavigationAttached::setBacktab(QQuickItem *i)
Q_D(QQuickKeyNavigationAttached);
if (d->backtabSet && d->backtab == i)
return;
+ d->backtabSet = d->backtab != i;
d->backtab = i;
- d->backtabSet = true;
QQuickKeyNavigationAttached* other =
qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
if (other && !other->d_func()->tabSet) {
diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml
new file mode 100644
index 0000000000..12ce10e139
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+Grid {
+ property var textModel: ["1", "2", "3", "4", "5"]
+ columns: 5
+ width: 50*textModel.length
+
+ Repeater {
+ id: repeater
+ model: textModel.length
+ Rectangle {
+ width: 50
+ height: 50
+ color: focus ? "red" : "lightgrey"
+ focus: index == 2
+ Text {
+ id: t
+ text: textModel[index]
+ }
+ KeyNavigation.left: repeater.itemAt(index - 1)
+ KeyNavigation.right: repeater.itemAt(index + 1)
+ }
+ }
+
+ function verify() {
+ for (var i = 0; i < repeater.count; i++) {
+ var item = repeater.itemAt(i);
+ var prev = repeater.itemAt(i - 1);
+ var next = repeater.itemAt(i + 1);
+ if (item.KeyNavigation.left != prev || item.KeyNavigation.right != next)
+ return false;
+ }
+
+ return true;
+ }
+}
+
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index f01b3e25f1..f65650cf9c 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -92,6 +92,7 @@ private slots:
void keyNavigation_implicitDestroy();
void keyNavigation_focusReason();
void keyNavigation_loop();
+ void keyNavigation_repeater();
void layoutMirroring();
void layoutMirroringWindow();
void layoutMirroringIllegalParent();
@@ -2290,6 +2291,22 @@ void tst_QQuickItem::keyNavigation_loop()
delete window;
}
+void tst_QQuickItem::keyNavigation_repeater()
+{
+ // QTBUG-83356
+ QScopedPointer<QQuickView> window(new QQuickView());
+ window->setBaseSize(QSize(240,320));
+
+ window->setSource(testFileUrl("keynavigationtest_repeater.qml"));
+ window->show();
+ window->requestActivate();
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+}
+
void tst_QQuickItem::smooth()
{
QQmlComponent component(&engine);