aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-10-16 10:55:26 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-10-17 10:59:31 +0000
commitb09bc0c0ebd8ff35ab5e77b21bd1fdd590347488 (patch)
tree59c058a6396b74583ce339946375d5fcddc13af8
parentaf4c0ee6c07f020e733574b1af99ab524bc41a9a (diff)
QQmlAdaptorModel: return correct column count from the model
There is no reason for QQmlAdaptorModel to return the wrong column count to the view. For models that are not QAIM, the accessor that wraps the model will report the column count to be 1 anyway. The same is also true for QAbstractListModel. Change-Id: Ia259b044201d76743e5f43d9f0999d3848912075 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--src/qml/util/qqmladaptormodel.cpp2
-rw-r--r--tests/auto/quick/qquicktableview/testmodel.h1
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp1
3 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 2b50a0867c..831663fb7b 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -990,7 +990,7 @@ int QQmlAdaptorModel::rowCount() const
int QQmlAdaptorModel::columnCount() const
{
- return qMax(isValid() ? 1 : 0, accessors->columnCount(*this));
+ return qMax(0, accessors->columnCount(*this));
}
int QQmlAdaptorModel::rowAt(int index) const
diff --git a/tests/auto/quick/qquicktableview/testmodel.h b/tests/auto/quick/qquicktableview/testmodel.h
index 28ea466b82..b1bb7a41b8 100644
--- a/tests/auto/quick/qquicktableview/testmodel.h
+++ b/tests/auto/quick/qquicktableview/testmodel.h
@@ -133,6 +133,7 @@ public:
beginResetModel();
m_rows = 0;
m_columns = 0;
+ modelData.clear();
endResetModel();
}
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 60b938d127..38789fd7bf 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -1466,6 +1466,7 @@ void tst_QQuickTableView::modelSignals()
QCOMPARE(tableView->columns(), 10);
model.clear();
+ model.setColumnCount(1);
WAIT_UNTIL_POLISHED;
QCOMPARE(tableView->rows(), 0);
QCOMPARE(tableView->columns(), 1);