summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-18 11:48:27 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-18 11:48:28 +0100
commit6c62408bc4ca6978232ba6d3c88cc5649c2c8919 (patch)
tree40c576d8898b1830dace89f86b71ce583395de0e
parenteb554a20ec5c48643784ce7b29f97ccfb31e7f89 (diff)
parentb26bfb18616e2a4baf33f9f1a2c147e3f5512de6 (diff)
downloadqtquickcontrols-6c62408bc4ca6978232ba6d3c88cc5649c2c8919.tar.gz
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I3022d2eabeef6d387135427b553de8a6d80dff13
-rw-r--r--src/controls/TreeView.qml8
-rw-r--r--src/controls/doc/src/qtquickcontrolsstyles-index.qdoc4
-rw-r--r--tests/auto/controls/data/tst_treeview.qml25
3 files changed, 34 insertions, 3 deletions
diff --git a/src/controls/TreeView.qml b/src/controls/TreeView.qml
index 6a38acff..2bedb9e6 100644
--- a/src/controls/TreeView.qml
+++ b/src/controls/TreeView.qml
@@ -49,7 +49,7 @@ BasicTableView {
property var model: null
property alias rootIndex: modelAdaptor.rootIndex
- readonly property var currentIndex: modelAdaptor.mapRowToModelIndex(__currentRow)
+ readonly property var currentIndex: modelAdaptor.updateCount, modelAdaptor.mapRowToModelIndex(__currentRow)
property ItemSelectionModel selection: null
signal activated(var index)
@@ -96,6 +96,12 @@ BasicTableView {
id: modelAdaptor
model: root.model
+ // Hack to force re-evaluation of the currentIndex binding
+ property int updateCount: 0
+ onModelReset: updateCount++
+ onRowsInserted: updateCount++
+ onRowsRemoved: updateCount++
+
onExpanded: root.expanded(index)
onCollapsed: root.collapsed(index)
}
diff --git a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc
index 9333ee27..c86488fa 100644
--- a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc
+++ b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc
@@ -60,7 +60,7 @@
\title Qt Quick Controls 1 Styles
\brief The Qt Quick Controls Styles submodule provides custom styles for Qt Quick Controls.
- \deprecation-warning
+ \deprecationwarning
The Qt Quick Controls Styles submodule allows custom styling for \l {Qt Quick Controls 1}.
@@ -132,7 +132,7 @@
\ingroup qmlmodules
\brief Provides QML types for Qt Quick Controls styles.
- \deprecation-warning
+ \deprecationwarning
The \l{Qt Quick Controls 1} module provides a set of QML types for handling
styles.
diff --git a/tests/auto/controls/data/tst_treeview.qml b/tests/auto/controls/data/tst_treeview.qml
index 902d2178..324d9cff 100644
--- a/tests/auto/controls/data/tst_treeview.qml
+++ b/tests/auto/controls/data/tst_treeview.qml
@@ -848,5 +848,30 @@ Item {
mouseClick(tree, semiIndent + 50, 20 + 50, Qt.LeftButton)
verify(selectionModel.isSelected(parentItem))
}
+
+ function test_QTBUG_53097_currentIndex_on_model_reset()
+ {
+ var component = Qt.createComponent("treeview/treeview_1.qml")
+ compare(component.status, Component.Ready)
+ var tree = component.createObject(container);
+ verify(tree !== null, "tree created is null")
+ tree.headerVisible = false
+ var model = tree.model
+ waitForRendering(tree)
+
+ /* Select the first row */
+ verify(!tree.currentIndex.valid)
+ mouseClick(tree, semiIndent + 50, 20, Qt.LeftButton)
+ compare(tree.currentIndex.row, 0)
+
+ spy.clear()
+ spy.target = tree
+ spy.signalName = "currentIndexChanged"
+ compare(spy.count, 0)
+
+ /* delete the row: the currentIndex must be updated */
+ model.removeRows(0, 1)
+ compare(spy.count, 1)
+ }
}
}