diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-10 08:58:00 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-10 08:58:00 (GMT) |
commit | 9a05223ea9a6ee0dbaac256607be201ea08e6fb6 (patch) | |
tree | 54e5407758a18954bdaf64146b8d3ad8532b9297 /src/imports/widgets/widgets.cpp | |
parent | ac27c8ad39a9646a9e509ba7a58f75eeae10bb6e (diff) | |
parent | bfc6a32c2a203766a6debdf19a265a4f0e198403 (diff) | |
download | Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.zip Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.tar.gz Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (119 commits)
Add Mac OS X bundle description for qml runtime
Cleanup
Disallow writes to read-only value type properties
Allow undefined to be assigned to QVariant properties
Add a Qt.isQtObject() method
Fix crash in QML library imports
Remove QT_VERSION checks in QML
List properties aren't read-only
Small doc fix.
Make sure WorkerScript thread is stopped on deletion. This also fixes
Release ListModel's worker agent on deletion.
Doc fixes
Fix example
Example code style improvements
Enable other wrapping modes.
TextEdit::wrap changed to TextEdit::wrapMode enumeration
Remove use of obsolete "Script" element.
unwarn
Replace "var" with "variant" in tests
Fix test after deletion of GraphicsObjectContainer.
...
Diffstat (limited to 'src/imports/widgets/widgets.cpp')
-rw-r--r-- | src/imports/widgets/widgets.cpp | 70 |
1 files changed, 2 insertions, 68 deletions
diff --git a/src/imports/widgets/widgets.cpp b/src/imports/widgets/widgets.cpp index bc18e8a..f26969a 100644 --- a/src/imports/widgets/widgets.cpp +++ b/src/imports/widgets/widgets.cpp @@ -41,75 +41,12 @@ #include <QtDeclarative/qdeclarativeextensionplugin.h> #include <QtDeclarative/qdeclarative.h> +#include <QGraphicsWidget> #include "graphicslayouts_p.h" -#include "graphicswidgets_p.h" QT_BEGIN_NAMESPACE -class QGraphicsViewDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QGraphicsScene *scene READ scene WRITE setScene) - Q_CLASSINFO("DefaultProperty", "scene") -public: - QGraphicsViewDeclarativeUI(QObject *other) : QObject(other) {} - - QGraphicsScene *scene() const { return static_cast<QGraphicsView *>(parent())->scene(); } - void setScene(QGraphicsScene *scene) - { - static_cast<QGraphicsView *>(parent())->setScene(scene); - } -}; - -class QGraphicsSceneDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {} - - QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this->parent(), 0, children_append); } - -private: - static void children_append(QDeclarativeListProperty<QObject> *prop, QObject *o) { - if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o)) - static_cast<QGraphicsScene *>(prop->object)->addItem(go); - } -}; - -class QGraphicsWidgetDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty<QGraphicsItem> children READ children) - Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {} - - QDeclarativeListProperty<QGraphicsItem> children() { return QDeclarativeListProperty<QGraphicsItem>(this, 0, children_append); } - - QGraphicsLayout *layout() const { return static_cast<QGraphicsWidget *>(parent())->layout(); } - void setLayout(QGraphicsLayout *lo) - { - static_cast<QGraphicsWidget *>(parent())->setLayout(lo); - } - -private: - void setItemParent(QGraphicsItem *wid) - { - wid->setParentItem(static_cast<QGraphicsWidget *>(parent())); - } - - static void children_append(QDeclarativeListProperty<QGraphicsItem> *prop, QGraphicsItem *i) { - static_cast<QGraphicsWidgetDeclarativeUI*>(prop->object)->setItemParent(i); - } -}; - class QWidgetsQmlModule : public QDeclarativeExtensionPlugin { Q_OBJECT @@ -123,10 +60,7 @@ public: qmlRegisterType<QGraphicsLinearLayoutStretchItemObject>(uri,4,6,"QGraphicsLinearLayoutStretchItem"); qmlRegisterType<QGraphicsLinearLayoutObject>(uri,4,6,"QGraphicsLinearLayout"); qmlRegisterType<QGraphicsGridLayoutObject>(uri,4,6,"QGraphicsGridLayout"); - qmlRegisterExtendedType<QGraphicsView, QGraphicsViewDeclarativeUI>(uri,4,6,"QGraphicsView"); - qmlRegisterExtendedType<QGraphicsScene,QGraphicsSceneDeclarativeUI>(uri,4,6,"QGraphicsScene"); - qmlRegisterExtendedType<QGraphicsWidget,QGraphicsWidgetDeclarativeUI>(uri,4,6,"QGraphicsWidget"); - qmlRegisterInterface<QGraphicsItem>("QGraphicsItem"); + qmlRegisterType<QGraphicsWidget>(uri,4,6,"QGraphicsWidget"); } }; |