aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/util/qqmladaptormodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/util/qqmladaptormodel.cpp')
-rw-r--r--src/qml/util/qqmladaptormodel.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 96a18a1c3d..f97854314e 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -985,7 +985,38 @@ void QQmlAdaptorModel::invalidateModel(QQmlDelegateModel *vdm)
bool QQmlAdaptorModel::isValid() const
{
- return accessors != &qt_vdm_null_accessors;
+ return accessors != &qt_vdm_null_accessors || rows.isValid();
+}
+
+int QQmlAdaptorModel::count() const
+{
+ return rowCount() * columnCount();
+}
+
+int QQmlAdaptorModel::rowCount() const
+{
+ if (rows.isValid())
+ return rows.value;
+ return qMax(0, accessors->rowCount(*this));
+}
+
+int QQmlAdaptorModel::columnCount() const
+{
+ if (columns.isValid())
+ return columns.value;
+ return qMax(isValid() ? 1 : 0, accessors->columnCount(*this));
+}
+
+int QQmlAdaptorModel::rowAt(int index) const
+{
+ int count = rowCount();
+ return count <= 0 ? -1 : index % count;
+}
+
+int QQmlAdaptorModel::columnAt(int index) const
+{
+ int count = rowCount();
+ return count <= 0 ? -1 : index / count;
}
void QQmlAdaptorModel::objectDestroyed(QObject *)