diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-06-15 11:41:19 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-06-15 11:41:19 +0200 |
commit | b669a429d0b2d4c58d47a6b3513d12ca57cf8fb6 (patch) | |
tree | 0316635d6ebebb2f0fe3667016828d291af0c419 /src | |
parent | a8dd4f7d5b8f61b52a5aea7b8418a6a3961cae1e (diff) | |
parent | 513363e940e0978931083544374bfe092107b9fb (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/imports/controls/ButtonGroup.qml
tests/auto/controls/data/tst_container.qml
tests/auto/menu/tst_menu.cpp
Change-Id: Ie8ee7e4f83f3fda6a09507b060576ebda929a7cd
Diffstat (limited to 'src')
-rw-r--r-- | src/quickcontrols2/qquicktumblerview.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontainer.cpp | 6 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu.cpp | 42 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu_p_p.h | 3 |
5 files changed, 45 insertions, 12 deletions
diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index 59f443d5..817ec370 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -170,7 +170,7 @@ void QQuickTumblerView::createView() } } -// Called whever the size or visibleItemCount changes. +// Called whenever the size or visibleItemCount changes. void QQuickTumblerView::updateView() { QQuickItem *theView = view(); diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index a6f9f6ca..dceda7d7 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -204,6 +204,10 @@ QString QQuickComboBoxDelegateModel::stringValue(int index, const QString &role) if (data.count() == 1 && role == QLatin1String("modelData")) return data.first().toString(); return data.value(role).toString(); + } else if (object.userType() == QMetaType::QObjectStar) { + const QObject *data = object.value<QObject *>(); + if (data && role != QLatin1String("modelData")) + return data->property(role.toUtf8()).toString(); } } return QQmlDelegateModel::stringValue(index, role); diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index 9b8298c2..eaf18714 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -350,10 +350,14 @@ void QQuickContainerPrivate::itemSiblingOrderChanged(QQuickItem *) // reorder the restacked items (eg. by a Repeater) Q_Q(QQuickContainer); QList<QQuickItem *> siblings = effectiveContentItem(contentItem)->childItems(); + + int to = 0; for (int i = 0; i < siblings.count(); ++i) { QQuickItem* sibling = siblings.at(i); + if (QQuickItemPrivate::get(sibling)->isTransparentForPositioner()) + continue; int index = contentModel->indexOf(sibling, nullptr); - q->moveItem(index, i); + q->moveItem(index, to++); } } diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 5a2ad066..8639e504 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -330,10 +330,14 @@ void QQuickMenuPrivate::itemSiblingOrderChanged(QQuickItem *) // reorder the restacked items (eg. by a Repeater) Q_Q(QQuickMenu); QList<QQuickItem *> siblings = contentItem->childItems(); + + int to = 0; for (int i = 0; i < siblings.count(); ++i) { QQuickItem* sibling = siblings.at(i); + if (QQuickItemPrivate::get(sibling)->isTransparentForPositioner()) + continue; int index = contentModel->indexOf(sibling, nullptr); - q->moveItem(index, i); + q->moveItem(index, to++); } } @@ -513,6 +517,31 @@ void QQuickMenuPrivate::setCurrentIndex(int index) } } +void QQuickMenuPrivate::activateNextItem() +{ + int index = currentIndex(); + int count = contentModel->count(); + while (++index < count) { + QQuickItem *item = itemAt(index); + if (!item || !item->activeFocusOnTab()) + continue; + item->forceActiveFocus(Qt::TabFocusReason); + break; + } +} + +void QQuickMenuPrivate::activatePreviousItem() +{ + int index = currentIndex(); + while (--index >= 0) { + QQuickItem *item = itemAt(index); + if (!item || !item->activeFocusOnTab()) + continue; + item->forceActiveFocus(Qt::BacktabFocusReason); + break; + } +} + void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj) { QQuickMenu *q = qobject_cast<QQuickMenu *>(prop->object); @@ -1158,13 +1187,11 @@ void QQuickMenu::keyReleaseEvent(QKeyEvent *event) // shown at once. switch (event->key()) { case Qt::Key_Up: - if (d->contentItem->metaObject()->indexOfMethod("decrementCurrentIndex()") != -1) - QMetaObject::invokeMethod(d->contentItem, "decrementCurrentIndex"); + d->activatePreviousItem(); break; case Qt::Key_Down: - if (d->contentItem->metaObject()->indexOfMethod("incrementCurrentIndex()") != -1) - QMetaObject::invokeMethod(d->contentItem, "incrementCurrentIndex"); + d->activateNextItem(); break; case Qt::Key_Left: @@ -1180,11 +1207,6 @@ void QQuickMenu::keyReleaseEvent(QKeyEvent *event) default: break; } - - int index = d->currentIndex(); - QQuickItem *item = itemAt(index); - if (item) - item->forceActiveFocus(); } void QQuickMenu::timerEvent(QTimerEvent *event) diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h index 5887d4e5..a81c87c2 100644 --- a/src/quicktemplates2/qquickmenu_p_p.h +++ b/src/quicktemplates2/qquickmenu_p_p.h @@ -108,6 +108,9 @@ public: int currentIndex() const; void setCurrentIndex(int index); + void activateNextItem(); + void activatePreviousItem(); + static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj); static int contentData_count(QQmlListProperty<QObject> *prop); static QObject *contentData_at(QQmlListProperty<QObject> *prop, int index); |