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>
This commit is contained in:
parent
9d4b14d31b
commit
f40f69f6e1
1 changed files with 23 additions and 9 deletions
|
|
@ -94,6 +94,7 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
|
||||||
using namespace Shiboken;
|
using namespace Shiboken;
|
||||||
|
|
||||||
static PyTypeObject* qobjectType = TypeResolver::get("QObject*")->pythonType();
|
static PyTypeObject* qobjectType = TypeResolver::get("QObject*")->pythonType();
|
||||||
|
static PyTypeObject* qdeclarativeType = TypeResolver::get("QDeclarativeItem*")->pythonType();
|
||||||
assert(qobjectType);
|
assert(qobjectType);
|
||||||
static int nextType = 0;
|
static int nextType = 0;
|
||||||
|
|
||||||
|
|
@ -107,6 +108,8 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDeclarativeType = PySequence_Contains(((PyTypeObject*)pyObj)->tp_mro, (PyObject*)qdeclarativeType);
|
||||||
|
|
||||||
QMetaObject* metaObject = reinterpret_cast<QMetaObject*>(ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(pyObj)));
|
QMetaObject* metaObject = reinterpret_cast<QMetaObject*>(ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(pyObj)));
|
||||||
Q_ASSERT(metaObject);
|
Q_ASSERT(metaObject);
|
||||||
|
|
||||||
|
|
@ -116,8 +119,26 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
|
||||||
// Init proxy object static meta object
|
// Init proxy object static meta object
|
||||||
QDeclarativePrivate::RegisterType type;
|
QDeclarativePrivate::RegisterType type;
|
||||||
type.version = 0;
|
type.version = 0;
|
||||||
type.typeId = qMetaTypeId<QObject*>();
|
if (isDeclarativeType) {
|
||||||
type.listId = qMetaTypeId<QDeclarativeListProperty<QObject> >();
|
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.objectSize = PySide::getSizeOfQObject(reinterpret_cast<SbkObjectType*>(pyObj));
|
||||||
type.create = createFuncs[nextType];
|
type.create = createFuncs[nextType];
|
||||||
type.uri = uri;
|
type.uri = uri;
|
||||||
|
|
@ -126,13 +147,6 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor,
|
||||||
type.elementName = qmlName;
|
type.elementName = qmlName;
|
||||||
type.metaObject = metaObject;
|
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.extensionObjectCreate = 0;
|
||||||
type.extensionMetaObject = 0;
|
type.extensionMetaObject = 0;
|
||||||
type.customParser = 0;
|
type.customParser = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue