aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/platform/android/qandroidquickviewembedding.cpp
diff options
context:
space:
mode:
authorSoheil Armin <soheil.armin@qt.io>2024-05-03 01:07:34 +0300
committerSoheil Armin <soheil.armin@qt.io>2024-05-29 00:35:37 +0300
commit333dd9e276985eaa99cb4e24651f4edd1e685c53 (patch)
treea716528c99438db1f2fe47c898fc8cf9b8b12eff /src/quick/platform/android/qandroidquickviewembedding.cpp
parent22a96d42354a317b649bdf02d3a5a95bbf1bff6e (diff)
Android: Add Java QtAbstractItemModel as a QAIM wrapper
QtAbstractItemModel is a Java wrapper of QAbstractItemModel. QtModelIndex is a Java wrapper of QModelIndex. QtAbstractItemModel is an abstract Java class that wraps commonly used public and protected functions of QAIM. A QAndroidItemModelProxy instance can be created as a proxy between the Java implementation and C++. The instance can be used as a *QAbstractItemModel, for instance to be passed as a QML property to the QQuickView instance, through QtQuickView. The implementation also has a private QtAbstractItemModelProxy Java class that exposes QAbstractItemModel* to the Java QtAbstractItemModel instance. QtModelIndex wraps a subset of QModelIndex APIs. As the ctor of QModelIndex is private, we use row + column + internalId to create new Java QtModelIndex instance when proxying from a QtAbstractItemModel using the internal QtAndroidItemModelProxy. When the proxying happens from *QAbstractItemModel to Java, we use row + column + parent, as QAIM::index() should be used instead of QAIM::createIndex(). This change also add required type conversions between C++ types and Java types. [ChangeLog][Android] Added new public Java classes, QtAbstractItemModel and QtModelIndex to wrap a subset of their C++ counterpart functionalities, through internal proxies. Task-number: QTBUG-124803 Change-Id: I2464d3d30592aeec8b678445c946e4d167dc4886 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/quick/platform/android/qandroidquickviewembedding.cpp')
-rw-r--r--src/quick/platform/android/qandroidquickviewembedding.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/platform/android/qandroidquickviewembedding.cpp b/src/quick/platform/android/qandroidquickviewembedding.cpp
index 6308fc02f0..bf68e4d345 100644
--- a/src/quick/platform/android/qandroidquickviewembedding.cpp
+++ b/src/quick/platform/android/qandroidquickviewembedding.cpp
@@ -5,6 +5,8 @@
#include <QtQuick/private/qandroidtypes_p.h>
#include <QtQuick/private/qandroidtypeconverter_p.h>
#include <QtQuick/private/qandroidviewsignalmanager_p.h>
+#include <QtQuick/private/qandroiditemmodelproxy_p.h>
+#include <QtQuick/private/qandroidmodelindexproxy_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qjnienvironment.h>
@@ -318,6 +320,12 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_ERR;
if (!QtAndroidQuickViewEmbedding::registerNatives(env))
return JNI_ERR;
+ if (!QAndroidItemModelProxy::registerAbstractNatives(env))
+ return JNI_ERR;
+ if (!QAndroidItemModelProxy::registerProxyNatives(env))
+ return JNI_ERR;
+ if (!QAndroidModelIndexProxy::registerNatives(env))
+ return JNI_ERR;
return JNI_VERSION_1_6;
}