diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-12-04 13:07:06 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-12-09 14:16:07 +0100 |
commit | 6bc4d55fe196a6310cadb239c6069ad2ea044d05 (patch) | |
tree | 58e466a5517e53c8f59bdb9024c724567807ada1 /tests | |
parent | 3770696ce5dffa7a510a577ddf7cf44abbfef351 (diff) |
QQuickTableView: support assigning a DelegateModel
Normally you either assign a model to TableView that
already has a delegate (or don't need one), like
DelegateModel or ObjectModel. Or instead you assign
a QAIM model and a delegate directly. But if you
assign both a delegate and an ObjectModel, TableView
would be confused, and ignore the assigned model
and instead create an internal wrapper model that
ends up empty.
This patch will ensure that we don't create a wrapper
model in such cases, but instead forward the
delegate to whichever model is assigned, even
if it ends up as a no-op for models that don't
use one.
Task-number: QTBUG-80534
Change-Id: Idd220df08617c379dc7808ee1f41c862b78cc201
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquicktableview/data/replaceModelTableView.qml | 10 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml b/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml index 2b17e055a7..1b6074f5d5 100644 --- a/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml +++ b/tests/auto/quick/qquicktableview/data/replaceModelTableView.qml @@ -11,9 +11,9 @@ Item { ObjectModel { id: om - Rectangle { height: 30; width: 80; color: "red" } - Rectangle { height: 30; width: 80; color: "green" } - Rectangle { height: 30; width: 80; color: "blue" } + Rectangle { implicitHeight: 30; implicitWidth: 80; color: "red" } + Rectangle { implicitHeight: 30; implicitWidth: 80; color: "green" } + Rectangle { implicitHeight: 30; implicitWidth: 80; color: "blue" } } ListModel { @@ -29,8 +29,8 @@ Item { ListElement { name: "Orange" } } delegate: Rectangle { - height: 25 - width: 100 + implicitHeight: 25 + implicitWidth: 100 Text { text: "Name: " + name} } } diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index d6468f4652..09d1b8ca7c 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -2708,9 +2708,9 @@ void tst_QQuickTableView::replaceModel() tableView->setProperty("modelId", 0); QTRY_COMPARE(tableView->rows(), 2); tableView->setProperty("modelId", 1); - QTRY_COMPARE(tableView->rows(), 0); + QTRY_COMPARE(tableView->rows(), 3); tableView->setProperty("modelId", 2); - QTRY_COMPARE(tableView->rows(), 0); + QTRY_COMPARE(tableView->rows(), 2); tableView->setProperty("modelId", 0); QTRY_COMPARE(tableView->rows(), 2); } |