diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-05-09 17:16:59 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-17 13:17:28 +0000 |
commit | 607ced5bfd1390de4342bb44ab99e7acafd9f4e9 (patch) | |
tree | 97f7accdc0b1c439e699231aa71375213bf16f75 /src/qml/util | |
parent | 36c6b727c5f433ce3f22e18d93e2502df1c526aa (diff) |
Allow DelegateModel-based views to support multiple delegate types
This patch adds a specific abstract QQmlComponent subclass,
QQmlAbstractDelegateComponent, and a default implementation,
DelegateChooser, that, together with the type DelegateChoice
allows determining the delegate type by role and/or index.
The patch also adds QQmlAbstractDelegateComponent support
to QQmlTableInstanceModel, that is a simplified version of
the delegate model, currently only used in the new table view.
DelegateChoosers are intended to behave just like Components
in the context of the view. This means that they can be declared
outside of the view, and also in separate files, and the same
delegate component can be used at the same time in multiple views.
[ChangeLog][QtQuick][Item Views] Added a DelegateChooser Component
to host DelegateChoice instances to choose different delegates in
an Item View (e.g. TableView) depending on model roles.
Done-with: Michael Brasser <michael.brasser@live.com>
Task-number: QTBUG-26681
Change-Id: Ibe24a31daf9142c8a9ff45ef6c65da0aec8a14dc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/qml/util')
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 5 | ||||
-rw-r--r-- | src/qml/util/qqmladaptormodel_p.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index e460c376da..b5caaba727 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -1005,6 +1005,11 @@ int QQmlAdaptorModel::columnAt(int index) const return count <= 0 ? -1 : index / count; } +int QQmlAdaptorModel::indexAt(int row, int column) const +{ + return column * rowCount() + row; +} + void QQmlAdaptorModel::objectDestroyed(QObject *) { setModel(QVariant(), nullptr, nullptr); diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h index c4cfc0f466..b834704163 100644 --- a/src/qml/util/qqmladaptormodel_p.h +++ b/src/qml/util/qqmladaptormodel_p.h @@ -123,6 +123,7 @@ public: int columnCount() const; int rowAt(int index) const; int columnAt(int index) const; + int indexAt(int row, int column) const; inline bool adaptsAim() const { return qobject_cast<QAbstractItemModel *>(object()); } inline QAbstractItemModel *aim() { return static_cast<QAbstractItemModel *>(object()); } |