[Kde-bindings] playground/bindings/kimono
Arno Rehn
kde at arnorehn.de
Mon Apr 2 16:32:54 UTC 2007
SVN commit 649427 by arnorehn:
* Added a subclass of QAbstractItemModel called QItemModel which implements
the abstract methods of its super class by calling the original methods of
its C++ base class.
* Added workaround in resolve_classname to return "QItemModel" instead of "QAbstractItemModel"
so instances of this class can be constructed. Makes calls which return a QAbstractItemModel
work.
CCMAIL: kde-bindings at kde.org
M +9 -0 ChangeLog
M +2 -0 handlers.cpp
M +106 -0 qyoto.cpp
--- trunk/playground/bindings/kimono/ChangeLog #649426:649427
@@ -1,3 +1,12 @@
+2007-04-02 Arno Rehn <arno at arnorehn.de>
+
+ * Added a subclass of QAbstractItemModel called QItemModel which implements
+ the abstract methods of its super class by calling the original methods of
+ its C++ base class.
+ * Added workaround in resolve_classname to return "QItemModel" instead of "QAbstractItemModel"
+ so instances of this class can be constructed. Makes calls which return a QAbstractItemModel
+ work.
+
2007-04-01 Richard Dale <rdale at foton.es>
* Replace transparent proxies to invoke methods, with a direct call to
--- trunk/playground/bindings/kimono/handlers.cpp #649426:649427
@@ -430,6 +430,8 @@
QObject * qobject = (QObject *) smoke->cast(ptr, classId, smoke->idClass("QObject"));
const QMetaObject * meta = qobject->metaObject();
+ if (strcmp(smoke->classes[classId].className, "QAbstractItemModel") == 0)
+ return "Qyoto.QItemModel";
while (meta != 0) {
Smoke::Index classId = smoke->idClass(meta->className());
if (classId != 0) {
--- trunk/playground/bindings/kimono/qyoto.cpp #649426:649427
@@ -1313,6 +1313,112 @@
return result;
}
+int
+QAbstractItemModelRowCount(void* obj, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ int result = ((QAbstractItemModel*) o->ptr)->rowCount(*(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}
+
+void*
+QAbstractItemModelData(void* obj, void * modelIndex, int role)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ QVariant result = ((QAbstractItemModel*) o->ptr)->data(*(((QModelIndex*) i->ptr)), role);
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ smokeqyoto_object * ret = alloc_smokeqyoto_object(true, o->smoke, o->smoke->idClass("QVariant"), &result);
+ return (*CreateInstance)("Qyoto.QVariant", ret);
+}
+
+// These are virtual and not pure virtual, so callable methods are generated in C#.
+// Do we still need to override them in our QItemModel class?
+// commented out for now
+/*bool
+QAbstractItemModelSetData(void* obj, void * modelIndex, void * value, int role)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ smokeqyoto_object *v = (smokeqyoto_object*) (*GetSmokeObject)(value);
+ bool result = ((QAbstractItemModel*) o->ptr)->setData(*(((QModelIndex*) i->ptr)), *((QVariant*) v->ptr), role);
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ (*FreeGCHandle)(value);
+ return result;
+}
+
+int
+QAbstractItemModelFlags(void* obj, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ int result = ((QAbstractItemModel*) o->ptr)->flags(*(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}
+
+bool
+QAbstractItemModelInsertRows(void* obj, int row, int count, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ bool result = ((QAbstractItemModel*) o->ptr)->insertRows(row, count, *(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}
+
+bool
+QAbstractItemModelInsertColumns(void* obj, int column, int count, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ bool result = ((QAbstractItemModel*) o->ptr)->insertColumns(column, count, *(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}
+
+bool
+QAbstractItemModelRemoveRows(void* obj, int row, int count, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ bool result = ((QAbstractItemModel*) o->ptr)->removeRows(row, count, *(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}
+
+bool
+QAbstractItemModelRemoveColumns(void* obj, int column, int count, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ bool result = ((QAbstractItemModel*) o->ptr)->removeColumns(column, count, *(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ return result;
+}*/
+
+void*
+QAbstractItemModelIndex(void* obj, int row, int column, void * modelIndex)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ smokeqyoto_object *i = (smokeqyoto_object*) (*GetSmokeObject)(modelIndex);
+ QModelIndex result = ((QAbstractItemModel*) o->ptr)->index(row, column, *(((QModelIndex*) i->ptr)));
+ (*FreeGCHandle)(obj);
+ (*FreeGCHandle)(modelIndex);
+ smokeqyoto_object *ret = alloc_smokeqyoto_object(true, o->smoke, o->smoke->idClass("QModelIndex"), &result);
+ return ret;
+}
+
bool QyotoRegisterResourceData(int flag, const unsigned char * s, const unsigned char *n, const unsigned char *d)
{
qRegisterResourceData(flag, s, n, d);
More information about the Kde-bindings
mailing list