aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/util
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-02-02 14:31:18 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-02-09 08:46:05 +0000
commit508dcab350521a7dd7a84bbcb7fea973f9483611 (patch)
treeb8a7407043e49cf218d6c855b7012807af6275e5 /src/qml/util
parent8e0428d219b6bb55e914a80cb2d6ca894fe6af65 (diff)
QQmlAdaptorModel::Accessors: add support for row and column
Accessors wraps the different models used by a QQmlAdaptorModel. This patch will add support for accessing row and column information from those models. Change-Id: Ie4b1870c70750444bc4f288f5f85a20dcad603ff Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/qml/util')
-rw-r--r--src/qml/util/qqmladaptormodel.cpp30
-rw-r--r--src/qml/util/qqmladaptormodel_p.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 7afafec1fe..96a18a1c3d 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -458,6 +458,16 @@ public:
return model.aim()->rowCount(model.rootIndex);
}
+ int rowCount(const QQmlAdaptorModel &model) const override
+ {
+ return model.aim()->rowCount(model.rootIndex);
+ }
+
+ int columnCount(const QQmlAdaptorModel &model) const override
+ {
+ return model.aim()->columnCount(model.rootIndex);
+ }
+
void cleanup(QQmlAdaptorModel &model, QQmlDelegateModel *vdm) const override
{
QAbstractItemModel * const aim = model.aim();
@@ -658,6 +668,16 @@ public:
return model.list.count();
}
+ int rowCount(const QQmlAdaptorModel &model) const override
+ {
+ return model.list.count();
+ }
+
+ int columnCount(const QQmlAdaptorModel &) const override
+ {
+ return 1;
+ }
+
QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override
{
return role == QLatin1String("modelData")
@@ -742,6 +762,16 @@ public:
return model.list.count();
}
+ int rowCount(const QQmlAdaptorModel &model) const override
+ {
+ return model.list.count();
+ }
+
+ int columnCount(const QQmlAdaptorModel &) const override
+ {
+ return 1;
+ }
+
QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override
{
if (QObject *object = model.list.at(index).value<QObject *>())
diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h
index 7bbddcff07..4d922c68f3 100644
--- a/src/qml/util/qqmladaptormodel_p.h
+++ b/src/qml/util/qqmladaptormodel_p.h
@@ -74,6 +74,8 @@ public:
inline Accessors() {}
virtual ~Accessors();
virtual int count(const QQmlAdaptorModel &) const { return 0; }
+ virtual int rowCount(const QQmlAdaptorModel &) const { return 0; }
+ virtual int columnCount(const QQmlAdaptorModel &) const { return 0; }
virtual void cleanup(QQmlAdaptorModel &, QQmlDelegateModel * = 0) const {}
virtual QVariant value(const QQmlAdaptorModel &, int, const QString &) const {