diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-06-21 10:28:02 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-06-21 13:55:30 +0000 |
commit | aeb521054fdc070e3480f30c6595155075c10136 (patch) | |
tree | 37311367eb1cd67f78f13d73bf82f69a335523a0 /tests/auto/quick/shared | |
parent | 77cb60e0c071f9762f565f1f38859421c928dd4a (diff) |
QQmlDelegateModel: even for QAIM, only use first column by default
In 2f9afadd5d9b4899397dca, we introduced a change in QQmlAdaptorModel
so that a QAIM model report that it contains "rows * cols" number of
model items, and not just "rows". This was needed, otherwise TableView
would only display the first column of such models.
It turns out, however, that also ListView will now detect that a
QAIM contain more items than just the items in the first column.
The result will be that it ends up adding all the other columns
underneath the first column in the view.
To avoid this unforseen change, this patch will revert this logic, and
instead add a private variable that can be set if the new behavior
is wanted (e.g by TableView).
Change-Id: I8c13da99f05e2f922362e498d1fa1779cdbd0d72
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/shared')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 8 | ||||
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index dc813b9d59..3bfa23173e 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -153,6 +153,12 @@ int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const return list.count(); } +int QQuickViewTestUtil::QaimModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns; +} + QHash<int,QByteArray> QQuickViewTestUtil::QaimModel::roleNames() const { QHash<int,QByteArray> roles = QAbstractListModel::roleNames(); @@ -174,7 +180,7 @@ QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) int QQuickViewTestUtil::QaimModel::count() const { - return rowCount(); + return rowCount() * columnCount(); } QString QQuickViewTestUtil::QaimModel::name(int index) const diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index b11d5e4859..04e1771ef8 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -76,6 +76,7 @@ namespace QQuickViewTestUtil QaimModel(QObject *parent=0); int rowCount(const QModelIndex &parent=QModelIndex()) const; + int columnCount(const QModelIndex &parent=QModelIndex()) const; QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const; QHash<int,QByteArray> roleNames() const; @@ -104,6 +105,8 @@ namespace QQuickViewTestUtil using QAbstractListModel::dataChanged; + int columns = 1; + private: QList<QPair<QString,QString> > list; }; |