src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp	Tue Jul 06 15:10:48 2010 +0300
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp	Wed Aug 18 10:37:55 2010 +0300
@@ -79,8 +79,25 @@
 #endif
 #include "private/qdeclarativeanchors_p.h"
 
+static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent)
+{
+    QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj);
+    if (!gobj)
+        return QDeclarativePrivate::IncompatibleObject;
+
+    QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
+    if (!gparent)
+        return QDeclarativePrivate::IncompatibleParent;
+
+    gobj->setParentItem(gparent);
+    return QDeclarativePrivate::Parented;
+}
+
 void QDeclarativeItemModule::defineModule()
 {
+    QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent };
+    QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);
+
 #ifdef QT_NO_MOVIE
     qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
         qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie"));
@@ -112,9 +129,11 @@
     qmlRegisterType<QDeclarativePathPercent>("Qt",4,7,"PathPercent");
     qmlRegisterType<QDeclarativePathQuad>("Qt",4,7,"PathQuad");
     qmlRegisterType<QDeclarativePathView>("Qt",4,7,"PathView");
+#ifndef QT_NO_VALIDATOR
     qmlRegisterType<QIntValidator>("Qt",4,7,"IntValidator");
     qmlRegisterType<QDoubleValidator>("Qt",4,7,"DoubleValidator");
     qmlRegisterType<QRegExpValidator>("Qt",4,7,"RegExpValidator");
+#endif
     qmlRegisterType<QDeclarativeRectangle>("Qt",4,7,"Rectangle");
     qmlRegisterType<QDeclarativeRepeater>("Qt",4,7,"Repeater");
     qmlRegisterType<QGraphicsRotation>("Qt",4,7,"Rotation");
@@ -138,9 +157,13 @@
     qmlRegisterType<QDeclarativePathElement>();
     qmlRegisterType<QDeclarativeCurve>();
     qmlRegisterType<QDeclarativeScaleGrid>();
+#ifndef QT_NO_VALIDATOR
     qmlRegisterType<QValidator>();
+#endif
     qmlRegisterType<QDeclarativeVisualModel>();
+#ifndef QT_NO_ACTION
     qmlRegisterType<QAction>();
+#endif
     qmlRegisterType<QDeclarativePen>();
     qmlRegisterType<QDeclarativeFlickableVisibleArea>();
 #ifndef QT_NO_GRAPHICSEFFECT