summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-08-11 13:58:04 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-08-11 19:14:57 -0300
commitf40f69f6e1a65f3b025a3035d4de0a4eaf23b05f (patch)
treee24d8117af4493b29c77ed7cde8ae6d4d91eff47
parent9d4b14d31b9b24dd96a31079b7d28f63b2d941b7 (diff)
downloadpyside-f40f69f6e1a65f3b025a3035d4de0a4eaf23b05f.tar.gz
pyside-f40f69f6e1a65f3b025a3035d4de0a4eaf23b05f.tar.xz
pyside-f40f69f6e1a65f3b025a3035d4de0a4eaf23b05f.zip
Updated qmlRegisterType to register.
qmlRegisterType uses QDeclarativeItem in template args, when the class is derived from QDeclarativeItem, otherwise uses QObject. Fixes bug #951. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/QtDeclarative/pysideqmlregistertype.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp
index f769fa0..34fd3dd 100644
--- a/PySide/QtDeclarative/pysideqmlregistertype.cpp
+++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp
@@ -94,6 +94,7 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
using namespace Shiboken;
static PyTypeObject* qobjectType = TypeResolver::get("QObject*")->pythonType();
+ static PyTypeObject* qdeclarativeType = TypeResolver::get("QDeclarativeItem*")->pythonType();
assert(qobjectType);
static int nextType = 0;
@@ -107,6 +108,8 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
return -1;
}
+ bool isDeclarativeType = PySequence_Contains(((PyTypeObject*)pyObj)->tp_mro, (PyObject*)qdeclarativeType);
+
QMetaObject* metaObject = reinterpret_cast<QMetaObject*>(ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(pyObj)));
Q_ASSERT(metaObject);
@@ -116,8 +119,26 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
// Init proxy object static meta object
QDeclarativePrivate::RegisterType type;
type.version = 0;
- type.typeId = qMetaTypeId<QObject*>();
- type.listId = qMetaTypeId<QDeclarativeListProperty<QObject> >();
+ if (isDeclarativeType) {
+ type.typeId = qMetaTypeId<QDeclarativeItem*>();
+ type.listId = qMetaTypeId<QDeclarativeListProperty<QDeclarativeItem> >();
+
+ type.attachedPropertiesFunction = QDeclarativePrivate::attachedPropertiesFunc<QDeclarativeItem>();
+ type.attachedPropertiesMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<QDeclarativeItem>();
+
+ type.parserStatusCast = QDeclarativePrivate::StaticCastSelector<QDeclarativeItem, QDeclarativeParserStatus>::cast();
+ type.valueSourceCast = QDeclarativePrivate::StaticCastSelector<QDeclarativeItem, QDeclarativePropertyValueSource>::cast();
+ type.valueInterceptorCast = QDeclarativePrivate::StaticCastSelector<QDeclarativeItem, QDeclarativePropertyValueInterceptor>::cast();
+ } else {
+ type.typeId = qMetaTypeId<QObject*>();
+ type.listId = qMetaTypeId<QDeclarativeListProperty<QObject> >();
+ type.attachedPropertiesFunction = QDeclarativePrivate::attachedPropertiesFunc<QObject>();
+ type.attachedPropertiesMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<QObject>();
+
+ type.parserStatusCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativeParserStatus>::cast();
+ type.valueSourceCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativePropertyValueSource>::cast();
+ type.valueInterceptorCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativePropertyValueInterceptor>::cast();
+ }
type.objectSize = PySide::getSizeOfQObject(reinterpret_cast<SbkObjectType*>(pyObj));
type.create = createFuncs[nextType];
type.uri = uri;
@@ -126,13 +147,6 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
type.elementName = qmlName;
type.metaObject = metaObject;
- type.attachedPropertiesFunction = QDeclarativePrivate::attachedPropertiesFunc<QObject>();
- type.attachedPropertiesMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<QObject>();
-
- type.parserStatusCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativeParserStatus>::cast();
- type.valueSourceCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativePropertyValueSource>::cast();
- type.valueInterceptorCast = QDeclarativePrivate::StaticCastSelector<QObject, QDeclarativePropertyValueInterceptor>::cast();
-
type.extensionObjectCreate = 0;
type.extensionMetaObject = 0;
type.customParser = 0;