diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-04 22:54:11 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-04 22:54:11 (GMT) |
commit | 7e268329fb6345d92765e2d8f531ecc5dcc51219 (patch) | |
tree | c2c48b0d3dbd6f4a8a48eebaf7075bd184e851c0 | |
parent | 28a76d03cd4f74d2619c8ab402fa97e71ce41310 (diff) | |
parent | 93e65f89fa103aa8fb243ddd174657f7fa351644 (diff) | |
download | Qt-7e268329fb6345d92765e2d8f531ecc5dcc51219.zip Qt-7e268329fb6345d92765e2d8f531ecc5dcc51219.tar.gz Qt-7e268329fb6345d92765e2d8f531ecc5dcc51219.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts:
tools/qmldebugger/canvasscene.cpp
189 files changed, 1463 insertions, 801 deletions
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index 5eb7fe1..ebb1967 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -1,62 +1,41 @@ import Qt 4.6 -Item { +Rect { property string operation property bool toggable : false property bool toggled : false + signal clicked id: Button; width: 50; height: 30 - - Script { - function buttonClicked(operation) { - if (Button.toggable == true) { - if (Button.toggled == true) { - Button.toggled = false; - Button.state = 'Toggled'; - } else { - Button.toggled = true; - Button.state = ''; - } - } - else - doOp(operation); - } - } - - Image { - id: Image - source: "pics/button.sci" - width: Button.width; height: Button.height + border.color: Palette.mid; radius: 6 + gradient: Gradient { + GradientStop { id: G1; position: 0.0; color: Palette.lighter(Palette.button) } + GradientStop { id: G2; position: 1.0; color: Palette.button } } - Image { - id: ImagePressed - source: "pics/button-pressed.sci" - width: Button.width; height: Button.height - opacity: 0 - } - - Text { - anchors.centerIn: Image - text: Button.operation - color: "white" - font.bold: true - } + Text { anchors.centerIn: parent; text: operation; color: Palette.buttonText } MouseRegion { id: MouseRegion - anchors.fill: Button - onClicked: { buttonClicked(Button.operation) } + anchors.fill: parent + onClicked: { + doOp(operation); + Button.clicked(); + if (!Button.toggable) return; + Button.toggled ? Button.toggled = false : Button.toggled = true + } } states: [ State { name: "Pressed"; when: MouseRegion.pressed == true - SetProperties { target: ImagePressed; opacity: 1 } + SetProperties { target: G1; color: Palette.dark } + SetProperties { target: G2; color: Palette.button } }, State { name: "Toggled"; when: Button.toggled == true - SetProperties { target: ImagePressed; opacity: 1 } + SetProperties { target: G1; color: Palette.dark } + SetProperties { target: G2; color: Palette.button } } ] } diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 576fea9..a4e16e4 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -2,22 +2,23 @@ import Qt 4.6 Rect { id: MainWindow; - width: 320; height: 270; color: "black" + width: 320; height: 270; color: Palette.window + Palette { id: Palette } Script { source: "calculator.js" } VerticalLayout { - spacing: 2; margin: 2 + x: 2; spacing: 10; margin: 2 Rect { id: Container - width: 316; height: 60; z: 2 - border.color: "white"; color: "#343434" + width: 316; height: 50; z: 2 + border.color: Palette.dark; color: Palette.base Text { id: CurNum font.bold: true; font.size: 16 - color: "white" + color: Palette.text anchors.right: Container.right anchors.rightMargin: 5 anchors.verticalCenter: Container.verticalCenter @@ -25,7 +26,7 @@ Rect { Text { id: CurrentOperation - color: "white" + color: Palette.text font.bold: true; font.size: 16 anchors.left: Container.left anchors.leftMargin: 5 diff --git a/demos/declarative/calculator/pics/button-pressed.png b/demos/declarative/calculator/pics/button-pressed.png Binary files differdeleted file mode 100644 index 1a24cee..0000000 --- a/demos/declarative/calculator/pics/button-pressed.png +++ /dev/null diff --git a/demos/declarative/calculator/pics/button-pressed.sci b/demos/declarative/calculator/pics/button-pressed.sci deleted file mode 100644 index f3bc860..0000000 --- a/demos/declarative/calculator/pics/button-pressed.sci +++ /dev/null @@ -1,5 +0,0 @@ -gridLeft: 5 -gridTop: 5 -gridBottom: 5 -gridRight: 5 -imageFile: button-pressed.png diff --git a/demos/declarative/calculator/pics/button.png b/demos/declarative/calculator/pics/button.png Binary files differdeleted file mode 100644 index 88c8bf8..0000000 --- a/demos/declarative/calculator/pics/button.png +++ /dev/null diff --git a/demos/declarative/calculator/pics/button.sci b/demos/declarative/calculator/pics/button.sci deleted file mode 100644 index b1c7929..0000000 --- a/demos/declarative/calculator/pics/button.sci +++ /dev/null @@ -1,5 +0,0 @@ -gridLeft: 5 -gridTop: 5 -gridBottom: 5 -gridRight: 5 -imageFile: button.png diff --git a/demos/declarative/calculator/pics/clear.png b/demos/declarative/calculator/pics/clear.png Binary files differdeleted file mode 100644 index fb07a27c..0000000 --- a/demos/declarative/calculator/pics/clear.png +++ /dev/null diff --git a/demos/declarative/contacts/contacts.qml b/demos/declarative/contacts/contacts.qml index ecafd20..353040c 100644 --- a/demos/declarative/contacts/contacts.qml +++ b/demos/declarative/contacts/contacts.qml @@ -227,7 +227,7 @@ Rect { autoHighlight: true focus: false } - FocusRealm { + FocusScope { id: newContactWrapper anchors.fill: contactListView opacity: 0 @@ -257,7 +257,7 @@ Rect { } } } - FocusRealm { + FocusScope { id: searchBarWrapper height: 30 anchors.bottom: parent.bottom diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 57fc349..c0a1a87 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -33,9 +33,10 @@ Item { id: Wrapper; width: 85; height: 85 scale: Wrapper.PathView.scale; z: Wrapper.PathView.z - transform: [ - Rotation3D { id: Rotation; origin.x: 30; axis.x: 30; axis.y: 60; angle: Wrapper.PathView.angle } - ] + transform: Rotation3D { + id: Rotation; origin.x: Wrapper.width/2; origin.y: Wrapper.height/2 + axis.y: 1; angle: Wrapper.PathView.angle + } Connection { sender: ImageDetails; signal: "closed()" @@ -112,14 +113,14 @@ Item { } } ] - + } } ] Item { id: Background - + anchors.fill: parent Image { source: "content/pics/background.png"; anchors.fill: parent } diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 63cd377..68db351 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -81,7 +81,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \list \o \l MouseRegion \o \l KeyActions -\o \l FocusRealm +\o \l FocusScope \o \l KeyProxy \endlist diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e5c181d..60311da 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -6,7 +6,7 @@ When a key is pressed or released, a key event is generated and delivered to the focused fluid UI \l Item. To facilitate the construction of reusable components and to address some of the cases unique to fluid UIs, the fluid UI atoms add a -"realm" based extension to Qt's traditional keyboard focus model. +"scope" based extension to Qt's traditional keyboard focus model. \section1 Key Handling Overview @@ -44,7 +44,7 @@ Text { } \endcode -\section1 Acquiring Focus and Focus Realms +\section1 Acquiring Focus and Focus Scopes An \l Item requests focus by setting the \c {Item::focus} property to true. @@ -135,17 +135,17 @@ of code knows everything about the other, which is exactly how it should be. To solve this problem - allowing components to care about what they know about and ignore everything else - the fluid UI atoms introduce a concept known as a -\e {focus realm}. For existing Qt users, a \e {focus realm} is like an -automatic focus proxy. A \e {focus realm} is created using the \l FocusRealm +\e {focus scope}. For existing Qt users, a \e {focus scope} is like an +automatic focus proxy. A \e {focus scope} is created using the \l FocusScope element. -In the next example, a \l FocusRealm is added to the component, and the visual +In the next example, a \l FocusScope is added to the component, and the visual result shown. \table \row \o \code -FocusRealm { +FocusScope { width: 240; height: 25 Rect { color: "lightsteelblue"; width: 240; height: 25 @@ -162,12 +162,12 @@ FocusRealm { \o \image declarative-qmlfocus2.png \endtable -Conceptually \e {focus realms} are quite simple. +Conceptually \e {focus scopes} are quite simple. \list -\o Within each \e {focus realm} one element may have \c {Item::focus} set to true. If more than one \l Item has the \c {Item::focus} property set, the first is selected and the others are unset, just like when there are no \e {focus realms}. -\o When a \e {focus realm} receives \e {active focus}, the contained element with \c {Item::focus} set (if any) also gets \e {active focus}. If this element is -also a \l FocusRealm, the proxying behaviour continues. Both the -\e {focus realm} and the sub-focused item will have \c {Item::activeFocus} set. +\o Within each \e {focus scope} one element may have \c {Item::focus} set to true. If more than one \l Item has the \c {Item::focus} property set, the first is selected and the others are unset, just like when there are no \e {focus scopes}. +\o When a \e {focus scope} receives \e {active focus}, the contained element with \c {Item::focus} set (if any) also gets \e {active focus}. If this element is +also a \l FocusScope, the proxying behaviour continues. Both the +\e {focus scope} and the sub-focused item will have \c {Item::activeFocus} set. \endlist So far the example has the second component statically selected. It is trivial @@ -185,7 +185,7 @@ Rect { } \endcode \o \code -FocusRealm { +FocusScope { id: Page; width: 240; height: 25 MyWidget { focus: true } MouseRegion { anchors.fill: parent; onClicked: { Page.focus = true } } @@ -200,14 +200,14 @@ When a fluid UI atom explicitly relinquishes focus (by setting its does not automatically select another element to receive focus. That is, it is possible for there to be no currently \e {active focus}. -\section1 Advanced uses of Focus Realms +\section1 Advanced uses of Focus Scopes -Focus realms allow focus to allocation to be easily partitioned. Several +Focus scopes allow focus to allocation to be easily partitioned. Several fluid UI atoms use it to this effect. -\l ListView, for example, is itself a focus realm. Generally this isn't +\l ListView, for example, is itself a focus scope. Generally this isn't noticable as \l ListView doesn't usually have manually added visual children. -By being a focus realm, \l ListView can focus the current list item without +By being a focus scope, \l ListView can focus the current list item without worrying about how that will effect the rest of the application. This allows the current item delegate to react to key presses. @@ -227,7 +227,7 @@ Rect { ListElement { name: "John" } ListElement { name: "Michael" } } - delegate: FocusRealm { + delegate: FocusScope { width: contents.width; height: contents.height Text { text: name } KeyActions { return: "print(name)"; focus: true } @@ -240,10 +240,10 @@ Rect { While the example is simple, there's a lot going on behind the scenes. Whenever the current item changes, the \l ListView sets the delegate's \c {Item::focus} -property. As the \l ListView is a \e {focus realm}, this doesn't effect the +property. As the \l ListView is a \e {focus scope}, this doesn't effect the rest of the application. However, if the \l ListView itself has \e {active focus} this causes the delegate itself to receive \e {active focus}. -In this example, the root element of the delegate is also a \e {focus realm}, +In this example, the root element of the delegate is also a \e {focus scope}, which in turn gives \e {active focus} to the \c {KeyActions} element that actually performs the work of handling the \e {Return} key. diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index b7a4d7d..e848dfa 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -495,7 +495,7 @@ For an item to have key focus in QML it is required that: \list - \o If there is a FocusRealm ancestor of the component that it has focus as well. + \o If there is a FocusScope ancestor of the component that it has focus as well. \o That it is the most recent component within the focus realms descendent's to receive focus \endlist @@ -505,7 +505,7 @@ the components parent, which in turn will pass keys it doesn't handle up to its own ancestors. - Some components such as ListView components are also FocusRealm components, as they + Some components such as ListView components are also FocusScope components, as they handle focus among the child list items. At this stage of the tutorial it is sufficient to use the setting of 'focus' diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml new file mode 100644 index 0000000..046321b --- /dev/null +++ b/examples/declarative/listview/itemlist.qml @@ -0,0 +1,57 @@ +// This example demonstrates placing items in a view using +// a VisualItemModel + +import Qt 4.6 + +Rect { + color: "lightgray" + width: 240 + height: 320 + + VisualItemModel { + id: ItemModel + Rect { + height: View.height; width: View.width; color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + } + Rect { + height: View.height; width: View.width; color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + } + Rect { + height: View.height; width: View.width; color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + } + } + + ListView { + id: View + anchors.fill: parent + anchors.bottomMargin: 30 + model: ItemModel + currentItemPositioning: "SnapAuto" + orientation: "Horizontal" + } + + Rect { + color: "gray" + anchors.top: View.bottom + anchors.bottom: parent.bottom + height: 30 + width: 240 + + HorizontalLayout { + anchors.centerIn: parent + spacing: 20 + Repeater { + dataSource: ItemModel.count + Rect { + width: 5; height: 5 + radius: 3 + MouseRegion { width: 20; height: 20; anchors.centerIn: parent; onClicked: View.currentIndex = index } + color: View.currentIndex == index ? "blue" : "white" + } + } + } + } +} diff --git a/examples/declarative/smooth/GradientRect.qml b/examples/declarative/smooth/GradientRect.qml new file mode 100644 index 0000000..267a487 --- /dev/null +++ b/examples/declarative/smooth/GradientRect.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +Item { + id: MyRect + property string color + property string border : "" + property int rotation + property int radius + property int borderWidth + property bool smooth: false + + width: 80; height: 80 + Item { + anchors.centerIn: parent; rotation: MyRect.rotation; + Rect { + anchors.centerIn: parent; width: 80; height: 80 + border.color: MyRect.border; border.width: MyRect.border != "" ? 2 : 0 + radius: MyRect.radius; smooth: MyRect.smooth + gradient: Gradient { + GradientStop { position: 0.0; color: MyRect.color } + GradientStop { position: 1.0; color: "white" } + } + } + } +} diff --git a/examples/declarative/smooth/MyRect.qml b/examples/declarative/smooth/MyRect.qml new file mode 100644 index 0000000..7791e27 --- /dev/null +++ b/examples/declarative/smooth/MyRect.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Item { + id: MyRect + property string color + property string border : "" + property int rotation + property int radius + property int borderWidth + property bool smooth: false + + width: 80; height: 80 + Item { + anchors.centerIn: parent; rotation: MyRect.rotation; + Rect { + anchors.centerIn: parent; width: 80; height: 80 + color: MyRect.color; border.color: MyRect.border; border.width: MyRect.border != "" ? 2 : 0 + radius: MyRect.radius; smooth: MyRect.smooth + } + } +} diff --git a/examples/declarative/smooth/rect-painting.qml b/examples/declarative/smooth/rect-painting.qml new file mode 100644 index 0000000..2f01e4b --- /dev/null +++ b/examples/declarative/smooth/rect-painting.qml @@ -0,0 +1,64 @@ +import Qt 4.6 + +Rect { + width: 900; height: 500 + color: "white" + + Rect { + anchors.top: parent.verticalCenter + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + color: "#eeeeee" + } + + GridLayout { + anchors.centerIn: parent + columns: 8; rows:4; spacing: 30 + + MyRect { color: "lightsteelblue" } + MyRect { color: "lightsteelblue"; border: "gray" } + MyRect { color: "lightsteelblue"; radius: 10 } + MyRect { color: "lightsteelblue"; radius: 10; border: "gray" } + GradientRect { color: "lightsteelblue" } + GradientRect { color: "lightsteelblue"; border: "gray" } + GradientRect { color: "lightsteelblue"; radius: 10 } + GradientRect { color: "lightsteelblue"; radius: 10; border: "gray" } + + MyRect { color: "thistle"; rotation: 10 } + MyRect { color: "thistle"; border: "gray"; rotation: 10 } + MyRect { color: "thistle"; radius: 10; rotation: 10 } + MyRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10 } + GradientRect { color: "thistle"; rotation: 10 } + GradientRect { color: "thistle"; border: "gray"; rotation: 10 } + GradientRect { color: "thistle"; radius: 10; rotation: 10 } + GradientRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10 } + + MyRect { color: "lightsteelblue"; smooth: true } + MyRect { color: "lightsteelblue"; border: "gray"; smooth: true } + MyRect { color: "lightsteelblue"; radius: 10; smooth: true } + MyRect { color: "lightsteelblue"; radius: 10; border: "gray"; smooth: true } + GradientRect { color: "lightsteelblue"; smooth: true } + GradientRect { color: "lightsteelblue"; border: "gray"; smooth: true } + GradientRect { color: "lightsteelblue"; radius: 10; smooth: true } + GradientRect { color: "lightsteelblue"; radius: 10; border: "gray"; smooth: true } + + MyRect { color: "thistle"; rotation: 10; smooth: true } + MyRect { color: "thistle"; border: "gray"; rotation: 10; smooth: true } + MyRect { color: "thistle"; radius: 10; rotation: 10; smooth: true } + MyRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10; smooth: true } + GradientRect { color: "thistle"; rotation: 10; smooth: true } + GradientRect { color: "thistle"; border: "gray"; rotation: 10; smooth: true } + GradientRect { color: "thistle"; radius: 10; rotation: 10; smooth: true } + GradientRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10; smooth: true } + } + + Text { + text: "smooth: false"; font.bold: true + anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.top + } + Text { + text: "smooth: true"; font.bold: true + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom + } +} diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml index d3f626f..c607e75 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml @@ -1,6 +1,6 @@ import Qt 4.6 -FocusRealm { +FocusScope { id: groupBox width: Math.max(270, subItem.width+40) height: Math.max(70, subItem.height+40) diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml index d3f626f..c607e75 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml @@ -1,6 +1,6 @@ import Qt 4.6 -FocusRealm { +FocusScope { id: groupBox width: Math.max(270, subItem.width+40) height: Math.max(70, subItem.height+40) diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml index d3f626f..c607e75 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml @@ -1,6 +1,6 @@ import Qt 4.6 -FocusRealm { +FocusScope { id: groupBox width: Math.max(270, subItem.width+40) height: Math.max(70, subItem.height+40) diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index e9b836d..4af8af9 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -73,12 +73,12 @@ QFxFlowView::QFxFlowView() setAcceptedMouseButtons(Qt::LeftButton); } -QFxVisualItemModel *QFxFlowView::model() const +QFxVisualModel *QFxFlowView::model() const { return m_model; } -void QFxFlowView::setModel(QFxVisualItemModel *m) +void QFxFlowView::setModel(QFxVisualModel *m) { m_model = m; refresh(); diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h index c2b30a3..2d7a8bd 100644 --- a/src/declarative/extra/qfxflowview.h +++ b/src/declarative/extra/qfxflowview.h @@ -51,21 +51,21 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxVisualItemModel; +class QFxVisualModel; class QFxFlowViewValue; class QFxFlowViewAttached; class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem { Q_OBJECT - Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel) + Q_PROPERTY(QFxVisualModel *model READ model WRITE setModel) Q_PROPERTY(int column READ columns WRITE setColumns) Q_PROPERTY(bool vertical READ vertical WRITE setVertical) public: QFxFlowView(); - QFxVisualItemModel *model() const; - void setModel(QFxVisualItemModel *); + QFxVisualModel *model() const; + void setModel(QFxVisualModel *); int columns() const; void setColumns(int); @@ -86,7 +86,7 @@ private: void reflowDrag(const QPointF &); void clearTimeLine(); int m_columns; - QFxVisualItemModel *m_model; + QFxVisualModel *m_model; QList<QFxItem *> m_items; bool m_vertical; void moveItem(QFxItem *item, const QPointF &); diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index 3b6ffb4..18d33fb 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -121,7 +121,7 @@ public: QString namespaceDeclarations() const; void setNamespaceDeclarations(const QString&); - enum Status { Idle, Loading, Error }; + enum Status { Idle, Loading, Error }; // ### should include Null for consistency? Status status() const; qreal progress() const; diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 2c98dd3..bbb09fb 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -14,7 +14,7 @@ HEADERS += \ fx/qfximage_p.h \ fx/qfxitem.h \ fx/qfxitem_p.h \ - fx/qfxfocusrealm.h \ + fx/qfxfocusscope.h \ fx/qfxkeyactions.h \ fx/qfxkeyproxy.h \ fx/qfxlayouts.h \ @@ -53,7 +53,7 @@ SOURCES += \ fx/qfximage.cpp \ fx/qfxpainteditem.cpp \ fx/qfxitem.cpp \ - fx/qfxfocusrealm.cpp \ + fx/qfxfocusscope.cpp \ fx/qfxkeyactions.cpp \ fx/qfxkeyproxy.cpp \ fx/qfxlayouts.cpp \ diff --git a/src/declarative/fx/qfxfocusrealm.cpp b/src/declarative/fx/qfxfocusscope.cpp index 4484378..8981256 100644 --- a/src/declarative/fx/qfxfocusrealm.cpp +++ b/src/declarative/fx/qfxfocusscope.cpp @@ -39,34 +39,34 @@ ** ****************************************************************************/ -#include "qfxfocusrealm.h" +#include "qfxfocusscope.h" QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FocusRealm,QFxFocusRealm) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FocusScope,QFxFocusScope) /*! - \qmlclass FocusRealm - \brief The FocusRealm object explicitly creates a focus realm. + \qmlclass FocusScope + \brief The FocusScope object explicitly creates a focus scope. \inherits Item - Focus realms assist in keyboard focus handling when building reusable QML - components. All the details are covered in the + Focus scopes assist in keyboard focus handling when building reusable QML + components. All the details are covered in the \l {qmlfocus}{keyboard focus documentation}. */ /*! \internal - \class QFxFocusRealm + \class QFxFocusScope */ -QFxFocusRealm::QFxFocusRealm(QFxItem *parent) : +QFxFocusScope::QFxFocusScope(QFxItem *parent) : QFxItem(parent) { setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); } -QFxFocusRealm::~QFxFocusRealm() +QFxFocusScope::~QFxFocusScope() { } QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxfocusrealm.h b/src/declarative/fx/qfxfocusscope.h index 20fc5ad..28a6e30 100644 --- a/src/declarative/fx/qfxfocusrealm.h +++ b/src/declarative/fx/qfxfocusscope.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXFOCUSREALM_H -#define QFXFOCUSREALM_H +#ifndef QFXFOCUSSCOPE_H +#define QFXFOCUSSCOPE_H #include <QtDeclarative/qfxitem.h> @@ -50,18 +50,18 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QFxFocusRealm : public QFxItem +class Q_DECLARATIVE_EXPORT QFxFocusScope : public QFxItem { Q_OBJECT public: - QFxFocusRealm(QFxItem *parent=0); - virtual ~QFxFocusRealm(); + QFxFocusScope(QFxItem *parent=0); + virtual ~QFxFocusScope(); }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QFxFocusRealm) +QML_DECLARE_TYPE(QFxFocusScope) QT_END_HEADER -#endif // QFXFOCUSREALM_H +#endif // QFXFOCUSSCOPE_H diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index eb85c20..f471ef2 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -213,7 +213,7 @@ public: } bool isValid() const { - return model && model->count() && (!ownModel || model->delegate()); + return model && model->count() && model->isValid(); } int rowSize() const { @@ -293,7 +293,7 @@ public: } } - QFxVisualItemModel *model; + QFxVisualModel *model; QVariant modelVariant; QList<FxGridItem*> visibleItems; QHash<QFxItem*,int> unrequestedItems; @@ -730,8 +730,8 @@ void QFxGridView::setModel(const QVariant &model) d->clear(); d->modelVariant = model; QObject *object = qvariant_cast<QObject*>(model); - QFxVisualItemModel *vim = 0; - if (object && (vim = qobject_cast<QFxVisualItemModel *>(object))) { + QFxVisualModel *vim = 0; + if (object && (vim = qobject_cast<QFxVisualModel *>(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -739,10 +739,11 @@ void QFxGridView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setModel(model); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + dataModel->setModel(model); } if (d->model) { if (d->currentIndex >= d->model->count() || d->currentIndex < 0) @@ -769,19 +770,26 @@ void QFxGridView::setModel(const QVariant &model) QmlComponent *QFxGridView::delegate() const { Q_D(const QFxGridView); - return d->model ? d->model->delegate() : 0; + if (d->model) { + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + return dataModel->delegate(); + } + + return 0; } void QFxGridView::setDelegate(QmlComponent *delegate) { Q_D(QFxGridView); if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setDelegate(delegate); - d->updateCurrent(d->currentIndex); - refill(); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) { + dataModel->setDelegate(delegate); + d->updateCurrent(d->currentIndex); + refill(); + } } /*! diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index 2541884..63f93ca 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -49,7 +49,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxVisualItemModel; +class QFxVisualModel; class QFxGridViewAttached; class QFxGridViewPrivate; class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 5976cd5..ec3053c 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -61,7 +61,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage) \inherits Item The Image element supports untransformed, stretched, tiled, and grid-scaled images. - + For an explanation of stretching and tiling, see the fillMode property description. For an explanation of grid-scaling see the scaleGrid property description @@ -271,44 +271,6 @@ void QFxImage::componentComplete() \brief the 3x3 grid used to scale an image, excluding the corners. */ -/*! - \qmlproperty bool Image::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the Image is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. - */ - -/*! - \property QFxImage::smooth - \brief whether the image is smoothly transformed. - - This property is provided purely for the purpose of optimization. Turning - smooth transforms off is faster, but looks worse; turning smooth - transformations on is slower, but looks better. - - By default smooth transformations are off. -*/ -bool QFxImage::smoothTransform() const -{ - Q_D(const QFxImage); - return d->smooth; -} - -void QFxImage::setSmoothTransform(bool s) -{ - Q_D(QFxImage); - if (d->smooth == s) - return; - d->smooth = s; - update(); -} - void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QFxImage); diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 9c2ef30..fc9cfe0 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -67,7 +67,6 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid) Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false) - Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged); public: @@ -81,9 +80,6 @@ public: QPixmap pixmap() const; void setPixmap(const QPixmap &); - bool smoothTransform() const; - void setSmoothTransform(bool); - enum Status { Null, Ready, Loading, Error }; Status status() const; qreal progress() const; diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index 41b628c..2ce41f8 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -71,7 +71,7 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() - : scaleGrid(0), smooth(false), + : scaleGrid(0), fillMode(QFxImage::Stretch), status(QFxImage::Null), sciReply(0), progress(0.0) @@ -94,7 +94,6 @@ public: QFxScaleGrid *scaleGrid; QPixmap pix; - bool smooth : 1; QFxImage::FillMode fillMode; QFxImage::Status status; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 8195edb..2d3fa8d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -135,7 +135,7 @@ QFxContents::QFxContents() : m_height(0), m_width(0) The contents properties allow an item access to the size of its children. This property is useful if you have an item that needs to be - sized to fit its children. + sized to fit its children. */ /*! @@ -257,7 +257,7 @@ void QFxContents::setItem(QFxItem *item) } \endqml \endqmltext - + \ingroup group_coreitems */ @@ -458,10 +458,10 @@ QFxItem *QFxItem::parentItem() const \qmlproperty list<Item> Item::children \qmlproperty list<Object> Item::resources - The children property contains the list of visual children of this item. - The resources property contains non-visual resources that you want to + The children property contains the list of visual children of this item. + The resources property contains non-visual resources that you want to reference by name. - + Generally you can rely on Item's default property to handle all this for you, but it can come in handy in some cases. @@ -484,20 +484,20 @@ QFxItem *QFxItem::parentItem() const /*! \property QFxItem::children - This property contains the list of visual children of this item. + This property contains the list of visual children of this item. */ /*! \property QFxItem::resources - This property contains non-visual resources that you want to + This property contains non-visual resources that you want to reference by name. */ /*! Returns true if construction of the QML component is complete; otherwise returns false. - + It is often desireable to delay some processing until the component is completed. @@ -691,7 +691,7 @@ void QFxItemPrivate::transform_clear() } \endqml - data is a behind-the-scenes property: you should never need to explicitly + data is a behind-the-scenes property: you should never need to explicitly specify it. */ @@ -790,12 +790,12 @@ void QFxItem::setClip(bool c) \qmlproperty real Item::z Sets the stacking order of the item. By default the stacking order is 0. - + Items with a higher stacking value are drawn on top of items with a lower stacking order. Items with the same stacking value are drawn bottom up in the order they appear. Items with a negative stacking value are drawn under their parent's content. - + The following example shows the various effects of stacking order. \table @@ -869,7 +869,7 @@ void QFxItem::setClip(bool c) geometry from \a oldGeometry to \a newGeometry. If the two geometries are the same, it doesn't do anything. */ -void QFxItem::geometryChanged(const QRectF &newGeometry, +void QFxItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QFxItem); @@ -880,11 +880,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry, if (transformOrigin() != QFxItem::TopLeft) setTransformOriginPoint(d->computeTransformOrigin()); - if (newGeometry.x() != oldGeometry.x()) + if (newGeometry.x() != oldGeometry.x()) emit xChanged(); if (newGeometry.width() != oldGeometry.width()) emit widthChanged(); - if (newGeometry.y() != oldGeometry.y()) + if (newGeometry.y() != oldGeometry.y()) emit yChanged(); if (newGeometry.height() != oldGeometry.height()) emit heightChanged(); @@ -911,8 +911,6 @@ void QFxItem::keyPressEvent(QKeyEvent *event) QFxKeyEvent ke(*event); emit keyPress(&ke); event->setAccepted(ke.isAccepted()); - if (parentItem() && !ke.isAccepted()) - parentItem()->keyPressEvent(event); } /*! @@ -923,14 +921,12 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event) QFxKeyEvent ke(*event); emit keyRelease(&ke); event->setAccepted(ke.isAccepted()); - if (parentItem() && !ke.isAccepted()) - parentItem()->keyReleaseEvent(event); } /*! \qmlproperty string Item::id This property holds the identifier for the item. - + The identifier can be used in bindings and other expressions to refer to the item. For example: @@ -1087,7 +1083,7 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty real Item::anchors.horizontalCenterOffset \qmlproperty real Item::anchors.verticalCenterOffset \qmlproperty real Item::anchors.baselineOffset - + Anchors provide a way to position an item by specifying its relationship with other items. @@ -1555,7 +1551,7 @@ void QFxItem::componentComplete() if (d->_stateGroup) d->_stateGroup->componentComplete(); if (d->_anchors) { - d->_anchors->componentComplete(); + d->_anchors->componentComplete(); d->_anchors->d_func()->updateOnComplete(); } } @@ -1629,7 +1625,7 @@ bool QFxItem::sceneEvent(QEvent *event) return rv; } -QVariant QFxItem::itemChange(GraphicsItemChange change, +QVariant QFxItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemParentHasChanged) { @@ -1686,6 +1682,45 @@ void QFxItem::setTransformOrigin(TransformOrigin origin) } } +/*! + \qmlproperty bool Item::smooth + + Set this property if you want the item to be smoothly scaled or + transformed. Smooth filtering gives better visual quality, but is slower. If + the item is displayed at its natural size, this property has no visual or + performance effect. + Currently, only the \c Image, \c Text , \c TextEdit and \c LineEdit items implement smooth filtering. + + \note Generally scaling artifacts are only visible if the item is stationary on + the screen. A common pattern when animating an item is to disable smooth + filtering at the beginning of the animation and reenable it at the conclusion. + */ + +/*! + \property QFxItem::smooth + \brief whether the item is smoothly transformed. + + This property is provided purely for the purpose of optimization. Turning + smooth transforms off is faster, but looks worse; turning smooth + transformations on is slower, but looks better. + + By default smooth transformations are off. +*/ +bool QFxItem::smoothTransform() const +{ + Q_D(const QFxItem); + return d->smooth; +} + +void QFxItem::setSmoothTransform(bool s) +{ + Q_D(QFxItem); + if (d->smooth == s) + return; + d->smooth = s; + update(); +} + qreal QFxItem::width() const { Q_D(const QFxItem); @@ -1705,7 +1740,7 @@ void QFxItem::setWidth(qreal w) d->width = w; update(); - geometryChanged(QRectF(x(), y(), width(), height()), + geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), oldWidth, height())); } @@ -1721,7 +1756,7 @@ void QFxItem::setImplicitWidth(qreal w) d->width = w; update(); - geometryChanged(QRectF(x(), y(), width(), height()), + geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), oldWidth, height())); } @@ -1750,7 +1785,7 @@ void QFxItem::setHeight(qreal h) d->height = h; update(); - geometryChanged(QRectF(x(), y(), width(), height()), + geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), width(), oldHeight)); } @@ -1766,7 +1801,7 @@ void QFxItem::setImplicitHeight(qreal h) d->height = h; update(); - geometryChanged(QRectF(x(), y(), width(), height()), + geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), width(), oldHeight)); } @@ -1817,7 +1852,7 @@ void QFxItem::setFocus(bool focus) if (current->focusProxy() && current->focusProxy() != this) { QFxItem *currentItem = qobject_cast<QFxItem *>(current->focusProxy()); - if (currentItem) + if (currentItem) currentItem->setFocus(false); } diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index e832a67..b1676e4 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -147,6 +147,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) + Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -197,6 +198,9 @@ public: TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); + bool smoothTransform() const; + void setSmoothTransform(bool); + QRectF boundingRect() const; virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); @@ -235,7 +239,7 @@ protected: virtual void activeFocusChanged(bool); virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); - virtual void geometryChanged(const QRectF &newGeometry, + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); private Q_SLOTS: diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 674eada..b11b812 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -78,9 +78,9 @@ public: _componentComplete(true), _keepMouse(false), _anchorLines(0), _stateGroup(0), origin(QFxItem::TopLeft), - widthValid(false), heightValid(false), width(0), height(0) + widthValid(false), heightValid(false), width(0), height(0), smooth(false) {} - ~QFxItemPrivate() + ~QFxItemPrivate() { delete _anchors; } void init(QFxItem *parent) @@ -181,6 +181,7 @@ public: qreal width; qreal height; + bool smooth; QPointF computeTransformOrigin() const; diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index bef77e7..13267f2 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -473,7 +473,7 @@ void QFxLineEditPrivate::init() control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); control->setLayoutDirection(Qt::LeftToRight); - q->setSmooth(true); + q->setSmoothTransform(true); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemHasNoContents, false); q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index f976aec..860e9e4 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -265,7 +265,7 @@ public: } bool isValid() const { - return model && model->count() && (!ownModel || model->delegate()); + return model && model->count() && model->isValid(); } int snapIndex() { @@ -357,7 +357,7 @@ public: virtual void fixupY(); virtual void fixupX(); - QFxVisualItemModel *model; + QFxVisualModel *model; QVariant modelVariant; QList<FxListItem*> visibleItems; QHash<QFxItem*,int> unrequestedItems; @@ -697,9 +697,11 @@ void QFxListViewPrivate::updateSections() if (visibleIndex > 0) prevSection = sectionAt(visibleIndex-1); for (int i = 0; i < visibleItems.count(); ++i) { - QFxListViewAttached *attached = visibleItems.at(i)->attached; - attached->setPrevSection(prevSection); - prevSection = attached->section(); + if (visibleItems.at(i)->index != -1) { + QFxListViewAttached *attached = visibleItems.at(i)->attached; + attached->setPrevSection(prevSection); + prevSection = attached->section(); + } } } } @@ -908,8 +910,8 @@ void QFxListView::setModel(const QVariant &model) d->clear(); d->modelVariant = model; QObject *object = qvariant_cast<QObject*>(model); - QFxVisualItemModel *vim = 0; - if (object && (vim = qobject_cast<QFxVisualItemModel *>(object))) { + QFxVisualModel *vim = 0; + if (object && (vim = qobject_cast<QFxVisualModel *>(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -917,10 +919,11 @@ void QFxListView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setModel(model); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + dataModel->setModel(model); } if (d->model) { if (d->currentIndex >= d->model->count() || d->currentIndex < 0) @@ -947,19 +950,26 @@ void QFxListView::setModel(const QVariant &model) QmlComponent *QFxListView::delegate() const { Q_D(const QFxListView); - return d->model ? d->model->delegate() : 0; + if (d->model) { + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + return dataModel->delegate(); + } + + return 0; } void QFxListView::setDelegate(QmlComponent *delegate) { Q_D(QFxListView); if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setDelegate(delegate); - d->updateCurrent(d->currentIndex); - refill(); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) { + dataModel->setDelegate(delegate); + d->updateCurrent(d->currentIndex); + refill(); + } } /*! @@ -1528,6 +1538,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count) d->updateCurrent(qMin(modelIndex, d->model->count()-1)); } d->layout(); + d->updateSections(); emit countChanged(); return; } @@ -1590,6 +1601,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count) } else { // Correct the positioning of the items d->layout(); + d->updateSections(); } emit countChanged(); diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 0a0737f..e6898f6 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxVisualItemModel; +class QFxVisualModel; class QFxListViewAttached; class QFxListViewPrivate; class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 2bd17bc..8c04074 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -85,11 +85,6 @@ QT_BEGIN_NAMESPACE */ /*! - \property QFxPaintedItem::smooth - \brief Setting for whether smooth scaling is enabled. -*/ - -/*! Marks areas of the cache that intersect with the given \a rect as dirty and in need of being refreshed. @@ -120,17 +115,6 @@ void QFxPaintedItem::clearCache() } /*! - Returns if smooth scaling of the cache contents is enabled. - - \sa setSmooth() -*/ -bool QFxPaintedItem::isSmooth() const -{ - Q_D(const QFxPaintedItem); - return d->smooth; -} - -/*! Returns the size of the contents. \sa setContentsSize() @@ -142,20 +126,6 @@ QSize QFxPaintedItem::contentsSize() const } /*! - If \a smooth is true sets the image item to enable smooth scaling of - the cache contents. - - \sa isSmooth() -*/ -void QFxPaintedItem::setSmooth(bool smooth) -{ - Q_D(QFxPaintedItem); - if (d->smooth == smooth) return; - d->smooth = smooth; - update(); -} - -/*! Sets the size of the contents to the given \a size. \sa contentsSize() diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index 51e155e..9c40458 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -58,7 +58,6 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem Q_OBJECT Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) - Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) @@ -66,10 +65,7 @@ public: QFxPaintedItem(QFxItem *parent=0); ~QFxPaintedItem(); - bool isSmooth() const; QSize contentsSize() const; - - void setSmooth(bool); void setContentsSize(const QSize &); int cacheSize() const; diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index 06e80ff..f01936d 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -63,7 +63,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate public: QFxPaintedItemPrivate() - : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent) + : max_imagecache_size(100000), fillColor(Qt::transparent) { } @@ -78,7 +78,6 @@ public: QList<ImageCacheItem*> imagecache; int max_imagecache_size; - bool smooth; QSize contentsSize; QColor fillColor; }; diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 17f6dd3..6dcfcd1 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -144,7 +144,7 @@ QFxPathView::~QFxPathView() \brief the model providing data for the view. The model must be either a \l QListModelInterface or - \l QFxVisualItemModel subclass. + \l QFxVisualModel subclass. */ QVariant QFxPathView::model() const { @@ -168,8 +168,8 @@ void QFxPathView::setModel(const QVariant &model) d->modelVariant = model; QObject *object = qvariant_cast<QObject*>(model); - QFxVisualItemModel *vim = 0; - if (object && (vim = qobject_cast<QFxVisualItemModel *>(object))) { + QFxVisualModel *vim = 0; + if (object && (vim = qobject_cast<QFxVisualModel *>(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -177,10 +177,11 @@ void QFxPathView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setModel(model); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + dataModel->setModel(model); } if (d->model) { connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -341,18 +342,25 @@ void QFxPathView::setDragMargin(qreal dragMargin) QmlComponent *QFxPathView::delegate() const { Q_D(const QFxPathView); - return d->model ? d->model->delegate() : 0; + if (d->model) { + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) + return dataModel->delegate(); + } + + return 0; } void QFxPathView::setDelegate(QmlComponent *c) { Q_D(QFxPathView); if (!d->ownModel) { - d->model = new QFxVisualItemModel(qmlContext(this)); + d->model = new QFxVisualDataModel(qmlContext(this)); d->ownModel = true; } - d->model->setDelegate(c); - d->regenerate(); + if (QFxVisualDataModel *dataModel = qobject_cast<QFxVisualDataModel*>(d->model)) { + dataModel->setDelegate(c); + d->regenerate(); + } } /*! diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index eb5a1b1..801bdb8 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -106,7 +106,7 @@ public: } bool isValid() const { - return model && model->count() > 0 && model->delegate() && path; + return model && model->count() > 0 && model->isValid() && path; } int calcCurrentIndex(); @@ -140,7 +140,7 @@ public: int pathOffset; int requestedIndex; QList<QFxItem *> items; - QFxVisualItemModel *model; + QFxVisualModel *model; QVariant modelVariant; enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 0722d26..29321b8 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -475,10 +475,17 @@ void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QFxRect); if (d->radius > 0 || (d->pen && d->pen->isValid()) - || (d->gradient && d->gradient->gradient()) ) + || (d->gradient && d->gradient->gradient()) ) { drawRect(*p); - else + } + else { + bool oldAA = p->testRenderHint(QPainter::Antialiasing); + if (d->smooth) + p->setRenderHints(QPainter::Antialiasing, true); p->fillRect(QRect(0, 0, width(), height()), d->getColor()); + if (d->smooth) + p->setRenderHint(QPainter::Antialiasing, oldAA); + } } void QFxRect::drawRect(QPainter &p) @@ -488,7 +495,8 @@ void QFxRect::drawRect(QPainter &p) // XXX This path is still slower than the image path // Image path won't work for gradients though bool oldAA = p.testRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::Antialiasing); + if (d->smooth) + p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); p.setPen(pn); @@ -500,8 +508,14 @@ void QFxRect::drawRect(QPainter &p) p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); else p.drawRect(0, 0, width(), height()); - p.setRenderHint(QPainter::Antialiasing, oldAA); + if (d->smooth) + p.setRenderHint(QPainter::Antialiasing, oldAA); } else { + bool oldAA = p.testRenderHint(QPainter::Antialiasing); + bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform); + if (d->smooth) + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); + int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; @@ -569,6 +583,11 @@ void QFxRect::drawRect(QPainter &p) // Lower Right p.drawPixmap(QPoint(width()-xOffset+pw/2, height() - yOffset+pw/2), d->rectImage, QRect(d->rectImage.width()-xOffset, d->rectImage.height() - yOffset, xOffset, yOffset)); + + if (d->smooth) { + p.setRenderHint(QPainter::Antialiasing, oldAA); + p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); + } } } diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 1313dca..0c3f4e9 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -750,21 +750,6 @@ void QFxTextPrivate::checkImgCache() imgDirty = false; } -bool QFxText::smoothTransform() const -{ - Q_D(const QFxText); - return d->smooth; -} - -void QFxText::setSmoothTransform(bool s) -{ - Q_D(QFxText); - if (d->smooth == s) - return; - d->smooth = s; - update(); -} - void QFxText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QFxText); diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 41362ae..3665ac6 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -71,7 +71,6 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) Q_PROPERTY(QString activeLink READ activeLink) - Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) public: QFxText(QFxItem *parent=0); @@ -80,8 +79,8 @@ public: enum HAlignment { AlignLeft = Qt::AlignLeft, AlignRight = Qt::AlignRight, AlignHCenter = Qt::AlignHCenter }; - enum VAlignment { AlignTop = Qt::AlignTop, - AlignBottom = Qt::AlignBottom, + enum VAlignment { AlignTop = Qt::AlignTop, + AlignBottom = Qt::AlignBottom, AlignVCenter = Qt::AlignVCenter }; enum TextStyle { Normal, Outline, @@ -122,9 +121,6 @@ public: QString activeLink() const; - bool smoothTransform() const; - void setSmoothTransform(bool); - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); virtual void componentComplete(); @@ -141,7 +137,7 @@ protected: QFxText(QFxTextPrivate &dd, QFxItem *parent); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void geometryChanged(const QRectF &newGeometry, + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); private: diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h index 6692d9e..bbb54a3 100644 --- a/src/declarative/fx/qfxtext_p.h +++ b/src/declarative/fx/qfxtext_p.h @@ -71,7 +71,7 @@ public: QFxTextPrivate() : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true), hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone), - dirty(false), wrap(false), smooth(false), richText(false), singleline(false), control(0), doc(0), + dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0), format(QFxText::AutoText) { } @@ -119,7 +119,6 @@ public: Qt::TextElideMode elideMode; bool dirty; bool wrap; - bool smooth; bool richText; bool singleline; QTextControl *control; diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index b632268..e4001b2 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -1014,7 +1014,7 @@ void QFxTextEditPrivate::init() { Q_Q(QFxTextEdit); - q->setSmooth(true); + q->setSmoothTransform(true); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemHasNoContents, false); q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index b653057..6516545 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -58,16 +58,136 @@ QML_DECLARE_TYPE(QListModelInterface) QT_BEGIN_NAMESPACE -class QFxVisualItemModelParts; -class QFxVisualItemModelData; class QFxVisualItemModelPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QFxVisualItemModel); public: - QFxVisualItemModelPrivate(QmlContext *); + QFxVisualItemModelPrivate() : QObjectPrivate(), children(this) {} + + struct ItemList : public QmlConcreteList<QFxItem *> + { + ItemList(QFxVisualItemModelPrivate *m) : QmlConcreteList<QFxItem *>(), model(m) {} + + void append(QFxItem *item); + + QFxVisualItemModelPrivate *model; + }; + + void itemAppended() { + Q_Q(QFxVisualItemModel); + emit q->itemsInserted(children.count()-1, 1); + emit q->countChanged(); + } + + ItemList children; +}; + + +/*! + \qmlclass VisualItemModel QFxVisualItemModel + \brief The VisualItemModel allows items to be provided to a view. + + The children of the VisualItemModel are provided in a model which + can be used in a view. + + The example below places three colored rectangles in a ListView. + \code + Item { + VisualItemModel { + id: ItemModel + Rect { height: 30; width: 80; color: "red" } + Rect { height: 30; width: 80; color: "green" } + Rect { height: 30; width: 80; color: "blue" } + } + + ListView { + anchors.fill: parent + model: ItemModel + } + } + \endcode +*/ +QFxVisualItemModel::QFxVisualItemModel() + : QFxVisualModel(*(new QFxVisualItemModelPrivate)) +{ +} + +QmlList<QFxItem *> *QFxVisualItemModel::children() +{ + Q_D(QFxVisualItemModel); + return &(d->children); +} + +/*! + \qmlproperty int VisualItemModel::count + + The number of items in the model. This property is readonly. +*/ +int QFxVisualItemModel::count() const +{ + Q_D(const QFxVisualItemModel); + return d->children.count(); +} + +bool QFxVisualItemModel::isValid() const +{ + return true; +} + +QFxItem *QFxVisualItemModel::item(int index, bool) +{ + Q_D(QFxVisualItemModel); + return d->children.at(index); +} + +QFxVisualModel::ReleaseFlags QFxVisualItemModel::release(QFxItem *) +{ + // Nothing to do + return 0; +} + +void QFxVisualItemModel::completeItem() +{ + // Nothing to do +} + +QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext) +{ + Q_D(QFxVisualItemModel); + QmlContext *ccontext = qmlContext(this); + QmlContext *ctxt = new QmlContext(ccontext); + ctxt->addDefaultObject(d->children.at(index)); + QmlExpression e(ctxt, expression, objectContext); + e.setTrackChange(false); + QVariant value = e.value(); + delete ctxt; + return value; +} + +int QFxVisualItemModel::indexOf(QFxItem *item, QObject *) const +{ + Q_D(const QFxVisualItemModel); + return d->children.indexOf(item); +} + +void QFxVisualItemModelPrivate::ItemList::append(QFxItem *item) +{ + QmlConcreteList<QFxItem*>::append(item); + item->QObject::setParent(model->q_ptr); + model->itemAppended(); +} + + +class QFxVisualDataModelParts; +class QFxVisualDataModelData; +class QFxVisualDataModelPrivate : public QObjectPrivate +{ +public: + QFxVisualDataModelPrivate(QmlContext *); QGuard<QListModelInterface> m_listModelInterface; QGuard<QAbstractItemModel> m_abstractItemModel; - QGuard<QFxVisualItemModel> m_visualItemModel; + QGuard<QFxVisualDataModel> m_visualItemModel; QString m_part; QmlComponent *m_delegate; @@ -120,10 +240,10 @@ public: Cache m_cache; QHash<QObject *, QmlPackage*> m_packaged; - QFxVisualItemModelParts *m_parts; + QFxVisualDataModelParts *m_parts; friend class QFxVisualItemParts; - QFxVisualItemModelData *data(QObject *item); + QFxVisualDataModelData *data(QObject *item); QVariant m_modelVariant; QmlListAccessor *m_modelList; @@ -141,25 +261,25 @@ public: } }; -class QFxVisualItemModelDataMetaObject : public QmlOpenMetaObject +class QFxVisualDataModelDataMetaObject : public QmlOpenMetaObject { public: - QFxVisualItemModelDataMetaObject(QObject *parent) + QFxVisualDataModelDataMetaObject(QObject *parent) : QmlOpenMetaObject(parent) {} virtual QVariant propertyCreated(int, QMetaPropertyBuilder &); virtual int createProperty(const char *, const char *); private: - friend class QFxVisualItemModelData; + friend class QFxVisualDataModelData; QList<int> roles; }; -class QFxVisualItemModelData : public QObject +class QFxVisualDataModelData : public QObject { Q_OBJECT public: - QFxVisualItemModelData(int index, QFxVisualItemModelPrivate *model); + QFxVisualDataModelData(int index, QFxVisualDataModelPrivate *model); Q_PROPERTY(int index READ index NOTIFY indexChanged) int index() const; @@ -173,32 +293,32 @@ Q_SIGNALS: void indexChanged(); private: - friend class QFxVisualItemModelDataMetaObject; + friend class QFxVisualDataModelDataMetaObject; int m_index; - QFxVisualItemModelPrivate *m_model; - QFxVisualItemModelDataMetaObject *m_meta; + QFxVisualDataModelPrivate *m_model; + QFxVisualDataModelDataMetaObject *m_meta; }; -int QFxVisualItemModelData::count() const +int QFxVisualDataModelData::count() const { return m_meta->count(); } -int QFxVisualItemModelData::role(int id) const +int QFxVisualDataModelData::role(int id) const { Q_ASSERT(id >= 0 && id < count()); return m_meta->roles.at(id); } -void QFxVisualItemModelData::setValue(int id, const QVariant &val) +void QFxVisualDataModelData::setValue(int id, const QVariant &val) { m_meta->setValue(id, val); } -int QFxVisualItemModelDataMetaObject::createProperty(const char *name, const char *type) +int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const char *type) { - QFxVisualItemModelData *data = - static_cast<QFxVisualItemModelData *>(object()); + QFxVisualDataModelData *data = + static_cast<QFxVisualDataModelData *>(object()); if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel) && data->m_model->m_modelList) { @@ -217,12 +337,12 @@ int QFxVisualItemModelDataMetaObject::createProperty(const char *name, const cha } QVariant -QFxVisualItemModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) +QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); - QFxVisualItemModelData *data = - static_cast<QFxVisualItemModelData *>(object()); + QFxVisualDataModelData *data = + static_cast<QFxVisualDataModelData *>(object()); QString name = QLatin1String(prop.name()); if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel) && data->m_model->m_modelList) { @@ -255,105 +375,105 @@ QFxVisualItemModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro return QVariant(); } -QFxVisualItemModelData::QFxVisualItemModelData(int index, - QFxVisualItemModelPrivate *model) +QFxVisualDataModelData::QFxVisualDataModelData(int index, + QFxVisualDataModelPrivate *model) : m_index(index), m_model(model), - m_meta(new QFxVisualItemModelDataMetaObject(this)) + m_meta(new QFxVisualDataModelDataMetaObject(this)) { } -int QFxVisualItemModelData::index() const +int QFxVisualDataModelData::index() const { return m_index; } // This is internal only - it should not be set from qml -void QFxVisualItemModelData::setIndex(int index) +void QFxVisualDataModelData::setIndex(int index) { m_index = index; emit indexChanged(); } -class QFxVisualItemModelPartsMetaObject : public QmlOpenMetaObject +class QFxVisualDataModelPartsMetaObject : public QmlOpenMetaObject { public: - QFxVisualItemModelPartsMetaObject(QObject *parent) + QFxVisualDataModelPartsMetaObject(QObject *parent) : QmlOpenMetaObject(parent) {} virtual QVariant propertyCreated(int, QMetaPropertyBuilder &); }; -class QFxVisualItemModelParts : public QObject +class QFxVisualDataModelParts : public QObject { Q_OBJECT public: - QFxVisualItemModelParts(QFxVisualItemModel *parent); + QFxVisualDataModelParts(QFxVisualDataModel *parent); private: - friend class QFxVisualItemModelPartsMetaObject; - QFxVisualItemModel *model; + friend class QFxVisualDataModelPartsMetaObject; + QFxVisualDataModel *model; }; QVariant -QFxVisualItemModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) +QFxVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); - QFxVisualItemModel *m = new QFxVisualItemModel; + QFxVisualDataModel *m = new QFxVisualDataModel; m->setParent(object()); m->setPart(QLatin1String(prop.name())); - m->setModel(QVariant::fromValue(static_cast<QFxVisualItemModelParts *>(object())->model)); + m->setModel(QVariant::fromValue(static_cast<QFxVisualDataModelParts *>(object())->model)); QVariant var = QVariant::fromValue((QObject *)m); return var; } -QFxVisualItemModelParts::QFxVisualItemModelParts(QFxVisualItemModel *parent) +QFxVisualDataModelParts::QFxVisualDataModelParts(QFxVisualDataModel *parent) : QObject(parent), model(parent) { - new QFxVisualItemModelPartsMetaObject(this); + new QFxVisualDataModelPartsMetaObject(this); } -QFxVisualItemModelPrivate::QFxVisualItemModelPrivate(QmlContext *ctxt) +QFxVisualDataModelPrivate::QFxVisualDataModelPrivate(QmlContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) , m_context(ctxt), m_parts(0), m_modelList(0) { } -QFxVisualItemModelData *QFxVisualItemModelPrivate::data(QObject *item) +QFxVisualDataModelData *QFxVisualDataModelPrivate::data(QObject *item) { - QList<QFxVisualItemModelData *> dataList = - item->findChildren<QFxVisualItemModelData *>(); + QList<QFxVisualDataModelData *> dataList = + item->findChildren<QFxVisualDataModelData *>(); Q_ASSERT(dataList.count() == 1); return dataList.first(); } -QFxVisualItemModel::QFxVisualItemModel() -: QObject(*(new QFxVisualItemModelPrivate(0))) +QFxVisualDataModel::QFxVisualDataModel() +: QFxVisualModel(*(new QFxVisualDataModelPrivate(0))) { } -QFxVisualItemModel::QFxVisualItemModel(QmlContext *ctxt) -: QObject(*(new QFxVisualItemModelPrivate(ctxt))) +QFxVisualDataModel::QFxVisualDataModel(QmlContext *ctxt) +: QFxVisualModel(*(new QFxVisualDataModelPrivate(ctxt))) { } -QFxVisualItemModel::~QFxVisualItemModel() +QFxVisualDataModel::~QFxVisualDataModel() { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_modelList) delete d->m_modelList; } -QVariant QFxVisualItemModel::model() const +QVariant QFxVisualDataModel::model() const { - Q_D(const QFxVisualItemModel); + Q_D(const QFxVisualDataModel); return d->m_modelVariant; } -void QFxVisualItemModel::setModel(const QVariant &model) +void QFxVisualDataModel::setModel(const QVariant &model) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); d->m_modelVariant = model; if (d->m_listModelInterface) { // Assume caller has released all items. @@ -426,7 +546,7 @@ void QFxVisualItemModel::setModel(const QVariant &model) this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&))); return; } - if ((d->m_visualItemModel = qvariant_cast<QFxVisualItemModel *>(model))) { + if ((d->m_visualItemModel = qvariant_cast<QFxVisualDataModel *>(model))) { QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), this, SIGNAL(itemsInserted(int,int))); QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)), @@ -442,47 +562,51 @@ void QFxVisualItemModel::setModel(const QVariant &model) if (!d->m_modelList) d->m_modelList = new QmlListAccessor; d->m_modelList->setList(model); - if (d->m_delegate && d->modelCount()) + if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); + emit countChanged(); + } } -QmlComponent *QFxVisualItemModel::delegate() const +QmlComponent *QFxVisualDataModel::delegate() const { - Q_D(const QFxVisualItemModel); + Q_D(const QFxVisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->delegate(); return d->m_delegate; } -void QFxVisualItemModel::setDelegate(QmlComponent *delegate) +void QFxVisualDataModel::setDelegate(QmlComponent *delegate) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); d->m_delegate = delegate; - if (d->modelCount()) + if (d->modelCount()) { emit itemsInserted(0, d->modelCount()); + emit countChanged(); + } } -QString QFxVisualItemModel::part() const +QString QFxVisualDataModel::part() const { - Q_D(const QFxVisualItemModel); + Q_D(const QFxVisualDataModel); return d->m_part; } -void QFxVisualItemModel::setPart(const QString &part) +void QFxVisualDataModel::setPart(const QString &part) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); d->m_part = part; } -int QFxVisualItemModel::count() const +int QFxVisualDataModel::count() const { - Q_D(const QFxVisualItemModel); + Q_D(const QFxVisualDataModel); return d->modelCount(); } -QFxItem *QFxVisualItemModel::item(int index, bool complete) +QFxItem *QFxVisualDataModel::item(int index, bool complete) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->item(index, d->m_part.toLatin1(), complete); return item(index, QByteArray(), complete); @@ -491,9 +615,9 @@ QFxItem *QFxVisualItemModel::item(int index, bool complete) /* Returns ReleaseStatus flags. */ -QFxVisualItemModel::ReleaseFlags QFxVisualItemModel::release(QFxItem *item) +QFxVisualDataModel::ReleaseFlags QFxVisualDataModel::release(QFxItem *item) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->release(item); @@ -523,17 +647,17 @@ QFxVisualItemModel::ReleaseFlags QFxVisualItemModel::release(QFxItem *item) return stat; } -QObject *QFxVisualItemModel::parts() +QObject *QFxVisualDataModel::parts() { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (!d->m_parts) - d->m_parts = new QFxVisualItemModelParts(this); + d->m_parts = new QFxVisualDataModelParts(this); return d->m_parts; } -QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool complete) +QFxItem *QFxVisualDataModel::item(int index, const QByteArray &viewId, bool complete) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->item(index, viewId, complete); @@ -545,7 +669,7 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp QmlContext *ccontext = d->m_context; if (!ccontext) ccontext = qmlContext(this); QmlContext *ctxt = new QmlContext(ccontext); - QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d); + QFxVisualDataModelData *data = new QFxVisualDataModelData(index, d); ctxt->setContextProperty(QLatin1String("model"), data); ctxt->addDefaultObject(data); nobj = d->m_delegate->beginCreate(ctxt); @@ -576,9 +700,9 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp return item; } -void QFxVisualItemModel::completeItem() +void QFxVisualDataModel::completeItem() { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_visualItemModel) { d->m_visualItemModel->completeItem(); return; @@ -587,9 +711,9 @@ void QFxVisualItemModel::completeItem() d->m_delegate->completeCreate(); } -QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext) +QVariant QFxVisualDataModel::evaluate(int index, const QString &expression, QObject *objectContext) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->evaluate(index, expression, objectContext); @@ -609,7 +733,7 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj QmlContext *ccontext = d->m_context; if (!ccontext) ccontext = qmlContext(this); QmlContext *ctxt = new QmlContext(ccontext); - QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d); + QFxVisualDataModelData *data = new QFxVisualDataModelData(index, d); ctxt->addDefaultObject(data); QmlExpression e(ctxt, expression, objectContext); e.setTrackChange(false); @@ -621,7 +745,7 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj return value; } -int QFxVisualItemModel::indexOf(QFxItem *item, QObject *objectContext) const +int QFxVisualDataModel::indexOf(QFxItem *item, QObject *objectContext) const { QmlExpression e(qmlContext(item), QLatin1String("index"), objectContext); e.setTrackChange(false); @@ -631,15 +755,15 @@ int QFxVisualItemModel::indexOf(QFxItem *item, QObject *objectContext) const return -1; } -void QFxVisualItemModel::_q_itemsChanged(int index, int count, +void QFxVisualDataModel::_q_itemsChanged(int index, int count, const QList<int> &roles) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); // XXX - highly inefficient for (int ii = index; ii < index + count; ++ii) { if (QObject *item = d->m_cache.item(ii)) { - QFxVisualItemModelData *data = d->data(item); + QFxVisualDataModelData *data = d->data(item); for (int prop = 0; prop < data->count(); ++prop) { @@ -658,22 +782,22 @@ void QFxVisualItemModel::_q_itemsChanged(int index, int count, } } -void QFxVisualItemModel::_q_itemsInserted(int index, int count) +void QFxVisualDataModel::_q_itemsInserted(int index, int count) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); // XXX - highly inefficient - QHash<int,QFxVisualItemModelPrivate::ObjectRef> items; - for (QHash<int,QFxVisualItemModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); + QHash<int,QFxVisualDataModelPrivate::ObjectRef> items; + for (QHash<int,QFxVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= index) { - QFxVisualItemModelPrivate::ObjectRef objRef = *iter; + QFxVisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() + count; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QFxVisualItemModelData *data = d->data(objRef.obj); + QFxVisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -682,27 +806,28 @@ void QFxVisualItemModel::_q_itemsInserted(int index, int count) d->m_cache.unite(items); emit itemsInserted(index, count); + emit countChanged(); } -void QFxVisualItemModel::_q_itemsRemoved(int index, int count) +void QFxVisualDataModel::_q_itemsRemoved(int index, int count) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); // XXX - highly inefficient - QHash<int, QFxVisualItemModelPrivate::ObjectRef> items; - for (QHash<int, QFxVisualItemModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); + QHash<int, QFxVisualDataModelPrivate::ObjectRef> items; + for (QHash<int, QFxVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= index && iter.key() < index + count) { - QFxVisualItemModelPrivate::ObjectRef objRef = *iter; + QFxVisualDataModelPrivate::ObjectRef objRef = *iter; iter = d->m_cache.erase(iter); items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately - QFxVisualItemModelData *data = d->data(objRef.obj); + QFxVisualDataModelData *data = d->data(objRef.obj); data->setIndex(-1); } else if (iter.key() >= index + count) { - QFxVisualItemModelPrivate::ObjectRef objRef = *iter; + QFxVisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() - count; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QFxVisualItemModelData *data = d->data(objRef.obj); + QFxVisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -711,24 +836,25 @@ void QFxVisualItemModel::_q_itemsRemoved(int index, int count) d->m_cache.unite(items); emit itemsRemoved(index, count); + emit countChanged(); } -void QFxVisualItemModel::_q_itemsMoved(int from, int to, int count) +void QFxVisualDataModel::_q_itemsMoved(int from, int to, int count) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); // XXX - highly inefficient - QHash<int,QFxVisualItemModelPrivate::ObjectRef> items; - for (QHash<int,QFxVisualItemModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); + QHash<int,QFxVisualDataModelPrivate::ObjectRef> items; + for (QHash<int,QFxVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= from && iter.key() < from + count) { - QFxVisualItemModelPrivate::ObjectRef objRef = *iter; + QFxVisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() - from + to; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QFxVisualItemModelData *data = d->data(objRef.obj); + QFxVisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -739,35 +865,36 @@ void QFxVisualItemModel::_q_itemsMoved(int from, int to, int count) emit itemsMoved(from, to, count); } -void QFxVisualItemModel::_q_rowsInserted(const QModelIndex &, int begin, int end) +void QFxVisualDataModel::_q_rowsInserted(const QModelIndex &, int begin, int end) { _q_itemsInserted(begin, end - begin + 1); } -void QFxVisualItemModel::_q_rowsRemoved(const QModelIndex &, int begin, int end) +void QFxVisualDataModel::_q_rowsRemoved(const QModelIndex &, int begin, int end) { _q_itemsRemoved(begin, end - begin + 1); } -void QFxVisualItemModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) +void QFxVisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); } -void QFxVisualItemModel::_q_createdPackage(int index, QmlPackage *package) +void QFxVisualDataModel::_q_createdPackage(int index, QmlPackage *package) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); emit createdItem(index, qobject_cast<QFxItem*>(package->part(d->m_part))); } -void QFxVisualItemModel::_q_destroyingPackage(QmlPackage *package) +void QFxVisualDataModel::_q_destroyingPackage(QmlPackage *package) { - Q_D(QFxVisualItemModel); + Q_D(QFxVisualDataModel); emit destroyingItem(qobject_cast<QFxItem*>(package->part(d->m_part))); } -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VisualModel,QFxVisualItemModel) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VisualItemModel,QFxVisualItemModel) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VisualDataModel,QFxVisualDataModel) QT_END_NAMESPACE #include "qfxvisualitemmodel.moc" diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h index 551c08d..6160068 100644 --- a/src/declarative/fx/qfxvisualitemmodel.h +++ b/src/declarative/fx/qfxvisualitemmodel.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXVISUALITEMMODEL_H -#define QFXVISUALITEMMODEL_H +#ifndef QFXVISUALDATAMODEL_H +#define QFXVISUALDATAMODEL_H #include <QtCore/qobject.h> #include <QtCore/qabstractitemmodel.h> @@ -61,21 +61,89 @@ QT_MODULE(Declarative) class QFxItem; class QmlComponent; class QmlPackage; +class QFxVisualDataModelPrivate; + +class Q_DECLARATIVE_EXPORT QFxVisualModel : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int count READ count NOTIFY countChanged) + +public: + QFxVisualModel() {} + virtual ~QFxVisualModel() {} + + enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; + Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) + + virtual int count() const = 0; + virtual bool isValid() const = 0; + virtual QFxItem *item(int index, bool complete=true) = 0; + virtual ReleaseFlags release(QFxItem *item) = 0; + virtual void completeItem() = 0; + virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext) = 0; + + virtual int indexOf(QFxItem *item, QObject *objectContext) const = 0; + +Q_SIGNALS: + void countChanged(); + void itemsInserted(int index, int count); + void itemsRemoved(int index, int count); + void itemsMoved(int from, int to, int count); + void createdItem(int index, QFxItem *item); + void destroyingItem(QFxItem *item); + +protected: + QFxVisualModel(QObjectPrivate &dd, QObject *parent = 0) + : QObject(dd, parent) {} + +private: + Q_DISABLE_COPY(QFxVisualModel) +}; + class QFxVisualItemModelPrivate; -class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QObject +class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QFxVisualModel { Q_OBJECT Q_DECLARE_PRIVATE(QFxVisualItemModel) + Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "children") + +public: + QFxVisualItemModel(); + virtual ~QFxVisualItemModel() {} + + virtual int count() const; + virtual bool isValid() const; + virtual QFxItem *item(int index, bool complete=true); + virtual ReleaseFlags release(QFxItem *item); + virtual void completeItem(); + virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext); + + virtual int indexOf(QFxItem *item, QObject *objectContext) const; + + QmlList<QFxItem *> *children(); + +private: + Q_DISABLE_COPY(QFxVisualItemModel) +}; + + +class Q_DECLARATIVE_EXPORT QFxVisualDataModel : public QFxVisualModel +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QFxVisualDataModel) + Q_PROPERTY(QVariant model READ model WRITE setModel) Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(QString part READ part WRITE setPart) Q_PROPERTY(QObject *parts READ parts CONSTANT) Q_CLASSINFO("DefaultProperty", "delegate") public: - QFxVisualItemModel(); - QFxVisualItemModel(QmlContext *); - virtual ~QFxVisualItemModel(); + QFxVisualDataModel(); + QFxVisualDataModel(QmlContext *); + virtual ~QFxVisualDataModel(); QVariant model() const; void setModel(const QVariant &); @@ -86,10 +154,8 @@ public: QString part() const; void setPart(const QString &); - enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; - Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) - int count() const; + bool isValid() const { return delegate() != 0; } QFxItem *item(int index, bool complete=true); QFxItem *item(int index, const QByteArray &, bool complete=true); ReleaseFlags release(QFxItem *item); @@ -101,12 +167,7 @@ public: QObject *parts(); Q_SIGNALS: - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); - void itemsMoved(int from, int to, int count); - void createdItem(int index, QFxItem *item); void createdPackage(int index, QmlPackage *package); - void destroyingItem(QFxItem *item); void destroyingPackage(QmlPackage *package); private Q_SLOTS: @@ -121,13 +182,14 @@ private Q_SLOTS: void _q_destroyingPackage(QmlPackage *package); private: - Q_DISABLE_COPY(QFxVisualItemModel) + Q_DISABLE_COPY(QFxVisualDataModel) }; QT_END_NAMESPACE QML_DECLARE_TYPE(QFxVisualItemModel) +QML_DECLARE_TYPE(QFxVisualDataModel) QT_END_HEADER -#endif // QFXVISUALITEMMODEL_H +#endif // QFXVISUALDATAMODEL_H diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index 8d153ea..0dffa99 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -606,6 +606,7 @@ case $rule_number: { sym(1).UiImport->versionToken = loc(2); sym(1).UiImport->asToken = loc(3); sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = sym(4).sval; sym(1).UiImport->semicolonToken = loc(5); } break; ./ @@ -616,6 +617,7 @@ UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; case $rule_number: { sym(1).UiImport->asToken = loc(2); sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = sym(3).sval; sym(1).UiImport->semicolonToken = loc(4); } break; ./ diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index 2ee0f88..1386a21 100644 --- a/src/declarative/qml/parser/qmljsparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -241,12 +241,14 @@ case 14: { sym(1).UiImport->versionToken = loc(2); sym(1).UiImport->asToken = loc(3); sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = sym(4).sval; sym(1).UiImport->semicolonToken = loc(5); } break; case 16: { sym(1).UiImport->asToken = loc(2); sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = sym(3).sval; sym(1).UiImport->semicolonToken = loc(4); } break; diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index e7fbff3..bced8f2 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -74,19 +74,19 @@ QT_MODULE(Declarative) QT_BEGIN_NAMESPACE #define QML_DEFINE_INTERFACE(INTERFACE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *,0,0,0>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE)); #define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN_FROM), (VERSION_MIN_TO)>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); #define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN_FROM), (VERSION_MIN_TO)>::instance(qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); #define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0,0>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE)); #define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterType<TYPE>(#TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0,0>::instance(qmlRegisterType<TYPE>(#TYPE)); class QmlContext; class QmlEngine; diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 59cf15d..091b7bb 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -89,7 +89,7 @@ QmlCompiler::QmlCompiler() */ bool QmlCompiler::isError() const { - return !exceptions.isEmpty(); + return !exceptions.isEmpty(); } /*! @@ -113,7 +113,7 @@ bool QmlCompiler::isValidId(const QString &val) return false; QChar u(QLatin1Char('_')); - for (int ii = 0; ii < val.count(); ++ii) + for (int ii = 0; ii < val.count(); ++ii) if (val.at(ii) != u && ((ii == 0 && !val.at(ii).isLetter()) || (ii != 0 && !val.at(ii).isLetterOrNumber())) ) @@ -140,12 +140,12 @@ bool QmlCompiler::isAttachedPropertyName(const QByteArray &name) */ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) { - return name.length() >= 3 && name.startsWith("on") && + return name.length() >= 3 && name.startsWith("on") && 'A' <= name.at(2) && 'Z' >= name.at(2); } /*! - Inserts an error into the QmlCompiler error list, and returns false + Inserts an error into the QmlCompiler error list, and returns false (failure). \a token is used to source the error line and column, and \a desc is the @@ -169,7 +169,7 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) error.setDescription(exceptionDescription.trimmed()); \ exceptions << error; \ return false; \ - } + } /*! Returns false if \a is false, otherwise does nothing. @@ -186,13 +186,13 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) This test corresponds to action taken by genLiteralAssignment(). Any change made here, must have a corresponding action in genLiteralAssigment(). */ -bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, +bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QmlParser::Value *v) { QString string = v->value.asScript(); if (!prop.isWritable()) - COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property"); + COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property"); if (prop.isEnumType()) { int value; @@ -300,9 +300,9 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, int t = prop.type(); if (t == QVariant::UserType) t = prop.userType(); - QmlMetaType::StringConverter converter = + QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(t); - if (!converter) + if (!converter) COMPILE_EXCEPTION(v, "Invalid property assignment: unknown type" << prop.type()); } break; @@ -408,7 +408,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop, case QVariant::Time: { QTime time = QTime::fromString(string, Qt::ISODate); - int data[] = { time.hour(), time.minute(), + int data[] = { time.hour(), time.minute(), time.second(), time.msec() }; int index = output->indexForInt(data, 4); instr.type = QmlInstruction::StoreTime; @@ -434,7 +434,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop, case QVariant::PointF: { bool ok; - QPointF point = + QPointF point = QmlStringConverters::pointFFromString(string, &ok); float data[] = { point.x(), point.y() }; int index = output->indexForFloat(data, 2); @@ -466,7 +466,7 @@ void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop, { bool ok; QRectF rect = QmlStringConverters::rectFFromString(string, &ok); - float data[] = { rect.x(), rect.y(), + float data[] = { rect.x(), rect.y(), rect.width(), rect.height() }; int index = output->indexForFloat(data, 4); if (type == QVariant::RectF) @@ -523,14 +523,14 @@ void QmlCompiler::reset(QmlCompiledData *data) Compile \a unit, and store the output in \a out. \a engine is the QmlEngine with which the QmlCompiledData will be associated. - Returns true on success, false on failure. On failure, the compile errors + Returns true on success, false on failure. On failure, the compile errors are available from errors(). - If the environment variant QML_COMPILER_DUMP is set + If the environment variant QML_COMPILER_DUMP is set (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr on a successful compiler. */ -bool QmlCompiler::compile(QmlEngine *engine, +bool QmlCompiler::compile(QmlEngine *engine, QmlCompositeTypeData *unit, QmlCompiledData *out) { @@ -555,8 +555,8 @@ bool QmlCompiler::compile(QmlEngine *engine, if (ref.component->isError()) { QmlError error; - error.setUrl(output->url); - error.setDescription(QLatin1String("Unable to create type ") + + error.setUrl(output->url); + error.setDescription(QLatin1String("Unable to create type ") + unit->data.types().at(ii)); exceptions << error; exceptions << ref.component->errors(); @@ -565,7 +565,7 @@ bool QmlCompiler::compile(QmlEngine *engine, } ref.ref = tref.unit; ref.ref->addref(); - } + } ref.className = unit->data.types().at(ii).toLatin1(); out->types << ref; } @@ -620,13 +620,13 @@ void QmlCompiler::compileTree(Object *tree) } bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) -{ +{ Q_ASSERT (obj->type != -1); - const QmlCompiledData::TypeReference &tr = + const QmlCompiledData::TypeReference &tr = output->types.at(obj->type); obj->metatype = tr.metaObject(); - if (tr.component) + if (tr.component) obj->url = tr.component->url(); if (tr.type) obj->typeName = tr.type->qmlTypeName(); @@ -652,10 +652,10 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) if (obj->parserStatusCast != -1) compileState.parserStatusCount++; - // Check if this is a custom parser type. Custom parser types allow + // Check if this is a custom parser type. Custom parser types allow // assignments to non-existant properties. These assignments are then // compiled by the type. - bool isCustomParser = output->types.at(obj->type).type && + bool isCustomParser = output->types.at(obj->type).type && output->types.at(obj->type).type->customParser() != 0; QList<QmlCustomParserProperty> customProps; @@ -663,7 +663,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) QStringList deferredList = deferredProperties(obj); // Must do id property first. This is to ensure that the id given to any - // id reference created matches the order in which the objects are + // id reference created matches the order in which the objects are // instantiated foreach(Property *prop, obj->properties) { if (prop->name == "id") { @@ -697,8 +697,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) } } - if (canDefer && !deferredList.isEmpty() && - deferredList.contains(prop->name)) + if (canDefer && !deferredList.isEmpty() && + deferredList.contains(prop->name)) prop->isDeferred = true; } @@ -722,8 +722,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) canDefer = ids == compileState.ids.count(); } - if (canDefer && !deferredList.isEmpty() && - deferredList.contains(prop->name)) + if (canDefer && !deferredList.isEmpty() && + deferredList.contains(prop->name)) prop->isDeferred = true; } @@ -808,12 +808,12 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj) output->bytecode << defer; foreach(Property *prop, obj->valueProperties) { - if (!prop->isDeferred) + if (!prop->isDeferred) continue; genValueProperty(prop, obj); } - output->bytecode[deferIdx].defer.deferCount = + output->bytecode[deferIdx].defer.deferCount = output->bytecode.count() - deferIdx - 1; } @@ -828,7 +828,7 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj) QmlInstruction assign; assign.type = QmlInstruction::AssignSignalObject; assign.line = v->location.start.line; - assign.assignSignalObject.signal = + assign.assignSignalObject.signal = output->indexForByteArray(prop->name); output->bytecode << assign; @@ -838,7 +838,7 @@ void QmlCompiler::genObjectBody(QmlParser::Object *obj) store.type = QmlInstruction::StoreSignal; store.line = v->location.start.line; store.storeSignal.signalIndex = prop->index; - store.storeSignal.value = + store.storeSignal.value = output->indexForString(v->value.asScript().trimmed()); output->bytecode << store; @@ -908,7 +908,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) create.line = root->location.start.line; create.createComponent.endLine = root->location.end.line; output->bytecode << create; - int count = output->bytecode.count(); + int count = output->bytecode.count(); ComponentCompileState oldCompileState = compileState; compileState = componentState(root); @@ -941,7 +941,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) } } -bool QmlCompiler::buildComponent(QmlParser::Object *obj, +bool QmlCompiler::buildComponent(QmlParser::Object *obj, const BindingContext &ctxt) { // The special "Component" element can only have the id property and a @@ -953,7 +953,7 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, (obj->properties.count() == 1 && obj->properties.begin().key() != "id")) COMPILE_EXCEPTION(obj, "Invalid component specification"); - if (obj->properties.count()) + if (obj->properties.count()) idProp = *obj->properties.begin(); if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive()))) COMPILE_EXCEPTION(obj, "Invalid component id specification"); @@ -969,15 +969,15 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, } // Check the Component tree is well formed - if (obj->defaultProperty && + if (obj->defaultProperty && (obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 || (obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object))) COMPILE_EXCEPTION(obj, "Invalid component body specification"); Object *root = 0; - if (obj->defaultProperty && obj->defaultProperty->values.count()) + if (obj->defaultProperty && obj->defaultProperty->values.count()) root = obj->defaultProperty->values.first()->object; - + if (!root) COMPILE_EXCEPTION(obj, "Cannot create empty component specification"); @@ -987,14 +987,14 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, return true; } -bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj, +bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj, const BindingContext &ctxt) { ComponentCompileState oldComponentCompileState = compileState; compileState = ComponentCompileState(); compileState.root = obj; - if (obj) + if (obj) COMPILE_CHECK(buildObject(obj, ctxt)); COMPILE_CHECK(completeComponentBuild()); @@ -1005,16 +1005,16 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj, } -// Build a sub-object. A sub-object is one that was not created directly by +// Build a sub-object. A sub-object is one that was not created directly by // QML - such as a grouped property object, or an attached object. Sub-object's // can't have an id, involve a custom parser, have attached properties etc. bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt) { Q_ASSERT(obj->metatype); - Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding + Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding // sub-context - if (obj->defaultProperty) + if (obj->defaultProperty) COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt)); foreach(Property *prop, obj->properties) { @@ -1051,7 +1051,7 @@ int QmlCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name) int idx = methodName.indexOf('('); methodName = methodName.left(idx); - if (methodName == name) + if (methodName == name) return ii; } return -1; @@ -1094,7 +1094,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, prop->values.at(0)->type = Value::SignalExpression; } } - + return true; } @@ -1102,7 +1102,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, /*! Returns true if (value) property \a prop exists on obj, false otherwise. */ -bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop, +bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop, QmlParser::Object *obj) { if(isAttachedPropertyName(prop->name) || prop->name == "id") @@ -1118,12 +1118,12 @@ bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop, return idx != -1; } } - + return false; } -bool QmlCompiler::buildProperty(QmlParser::Property *prop, - QmlParser::Object *obj, +bool QmlCompiler::buildProperty(QmlParser::Property *prop, + QmlParser::Object *obj, const BindingContext &ctxt) { if (prop->isEmpty()) @@ -1172,7 +1172,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, } } - // We can't error here as the "id" property does not require a + // We can't error here as the "id" property does not require a // successful index resolution if (p.name()) { int t = p.type(); @@ -1187,11 +1187,11 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, if (!prop->isDefault && prop->name == "id" && !ctxt.isSubContext()) { // The magic "id" behaviour doesn't apply when "id" is resolved as a - // default property or to sub-objects (which are always in binding + // default property or to sub-objects (which are always in binding // sub-contexts) COMPILE_CHECK(buildIdProperty(prop, obj)); - if (prop->type == QVariant::String && - prop->values.at(0)->value.isString()) + if (prop->type == QVariant::String && + prop->values.at(0)->value.isString()) COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt)); } else if (isAttachedPropertyName(prop->name)) { @@ -1210,7 +1210,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt)); - } else if (QmlMetaType::isQmlList(prop->type) || + } else if (QmlMetaType::isQmlList(prop->type) || QmlMetaType::isList(prop->type)) { COMPILE_CHECK(buildListProperty(prop, obj, ctxt)); @@ -1224,7 +1224,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, return true; } -void QmlCompiler::genValueProperty(QmlParser::Property *prop, +void QmlCompiler::genValueProperty(QmlParser::Property *prop, QmlParser::Object *obj) { if (QmlMetaType::isQmlList(prop->type) || QmlMetaType::isList(prop->type)) { @@ -1234,7 +1234,7 @@ void QmlCompiler::genValueProperty(QmlParser::Property *prop, } } -void QmlCompiler::genListProperty(QmlParser::Property *prop, +void QmlCompiler::genListProperty(QmlParser::Property *prop, QmlParser::Object *obj) { QmlInstruction::Type fetchType; @@ -1291,7 +1291,7 @@ void QmlCompiler::genListProperty(QmlParser::Property *prop, output->bytecode << pop; } -void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop, +void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop, QmlParser::Object *obj, QmlParser::Property *valueTypeProperty) { @@ -1326,7 +1326,7 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop, store.storeObject.propertyIndex = prop->index; output->bytecode << store; - } + } } else if (v->type == Value::ValueSource) { genObject(v->object); @@ -1338,7 +1338,7 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop, store.assignValueSource.property = QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index, prop->index); store.assignValueSource.owner = 1; } else { - store.assignValueSource.property = + store.assignValueSource.property = QmlMetaPropertyPrivate::saveProperty(prop->index); store.assignValueSource.owner = 0; } @@ -1353,12 +1353,12 @@ void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop, QMetaProperty mp = obj->metaObject()->property(prop->index); genLiteralAssignment(mp, v); - } + } } } -bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, +bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, QmlParser::Object *obj) { if (prop->value || @@ -1404,7 +1404,7 @@ void QmlCompiler::saveComponentState() savedCompileStates.insert(compileState.root, compileState); } -QmlCompiler::ComponentCompileState +QmlCompiler::ComponentCompileState QmlCompiler::componentState(QmlParser::Object *obj) { Q_ASSERT(savedCompileStates.contains(obj)); @@ -1416,7 +1416,7 @@ QmlCompiler::componentState(QmlParser::Object *obj) // GridView.row: 10 // } // GridView is an attached property object. -bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop, +bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop, QmlParser::Object *obj, const BindingContext &ctxt) { @@ -1447,10 +1447,10 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, Q_ASSERT(prop->index != -1); if (prop->type < QVariant::UserType) { - QmlEnginePrivate *ep = + QmlEnginePrivate *ep = static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine)); if (ep->valueTypes[prop->type]) { - COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type], + COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type], prop->value, ctxt.incr())); obj->addValueTypeProperty(prop); } else { @@ -1461,7 +1461,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, // Load the nested property's meta type prop->value->metatype = QmlMetaType::metaObjectForType(prop->type); if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" << + COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" << prop->name); obj->addGroupedProperty(prop); @@ -1472,7 +1472,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, return true; } -bool QmlCompiler::buildValueTypeProperty(QObject *type, +bool QmlCompiler::buildValueTypeProperty(QObject *type, QmlParser::Object *obj, const BindingContext &ctxt) { @@ -1494,11 +1494,11 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, Value *value = prop->values.at(0); if (value->object) { - const QMetaObject *c = + const QMetaObject *c = output->types.at(value->object->type).metaObject(); - bool isPropertyValue = false; + bool isPropertyValue = false; while (c && !isPropertyValue) { - isPropertyValue = + isPropertyValue = (c == &QmlPropertyValueSource::staticMetaObject); c = c->superClass(); } @@ -1539,7 +1539,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, QmlParser::Object *obj, const BindingContext &ctxt) { - Q_ASSERT(QmlMetaType::isList(prop->type) || + Q_ASSERT(QmlMetaType::isList(prop->type) || QmlMetaType::isQmlList(prop->type)); int t = prop->type; @@ -1586,7 +1586,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, if (!canCoerce(listType, v->object)) { COMPILE_EXCEPTION(v, "Cannot assign object to list"); } - } + } } else if (v->value.isScript()) { if (assignedBinding) @@ -1642,7 +1642,7 @@ bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop, return true; } -// Compile assigning a single object instance to a regular property +// Compile assigning a single object instance to a regular property bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop, QmlParser::Object *obj, QmlParser::Value *v, @@ -1665,21 +1665,21 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop, v->type = Value::CreatedObject; } else { - // Normally buildObject() will set this up, but we need the static + // Normally buildObject() will set this up, but we need the static // meta object earlier to test for assignability. It doesn't matter // that there may still be outstanding synthesized meta object changes // on this type, as they are not relevant for assignability testing v->object->metatype = output->types.at(v->object->type).metaObject(); Q_ASSERT(v->object->metaObject()); - // We want to raw metaObject here as the raw metaobject is the - // actual property type before we applied any extensions that might + // We want to raw metaObject here as the raw metaobject is the + // actual property type before we applied any extensions that might // effect the properties on the type, but don't effect assignability - const QMetaObject *propertyMetaObject = + const QMetaObject *propertyMetaObject = QmlMetaType::rawMetaObjectForType(prop->type); - + // Will be true if the assigned type inherits QmlPropertyValueSource - bool isPropertyValue = false; + bool isPropertyValue = false; // Will be true if the assgned type inherits propertyMetaObject bool isAssignable = false; // Determine isPropertyValue and isAssignable values @@ -1729,7 +1729,7 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop, return true; } -// Compile assigning a literal or binding to a regular property +// Compile assigning a literal or binding to a regular property bool QmlCompiler::buildPropertyLiteralAssignment(QmlParser::Property *prop, QmlParser::Object *obj, QmlParser::Value *v, @@ -1762,16 +1762,16 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) // Check properties for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { - const QmlParser::Object::DynamicProperty &prop = + const QmlParser::Object::DynamicProperty &prop = obj->dynamicProperties.at(ii); if (prop.isDefaultProperty) { if (seenDefaultProperty) COMPILE_EXCEPTION(obj, "Duplicate default property"); seenDefaultProperty = true; - } - - if (propNames.contains(prop.name)) + } + + if (propNames.contains(prop.name)) COMPILE_EXCEPTION(obj, "Duplicate property name"); propNames.insert(prop.name); @@ -1802,7 +1802,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj) continue; Property *property = 0; - if (p.isDefaultProperty) + if (p.isDefaultProperty) property = obj->getDefaultProperty(); else property = obj->getProperty(p.name); @@ -1821,7 +1821,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj) bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) { - if (obj->dynamicProperties.isEmpty() && + if (obj->dynamicProperties.isEmpty() && obj->dynamicSignals.isEmpty() && obj->dynamicSlots.isEmpty()) return true; @@ -1839,7 +1839,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { const Object::DynamicProperty &p = obj->dynamicProperties.at(ii); - int propIdx = + int propIdx = obj->metaObject()->indexOfProperty(p.name.constData()); if (-1 != propIdx) { QMetaProperty prop = obj->metaObject()->property(propIdx); @@ -1847,8 +1847,8 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) COMPILE_EXCEPTION(&p, "Cannot override FINAL property"); } - if (p.isDefaultProperty && - (p.type != Object::DynamicProperty::Alias || + if (p.isDefaultProperty && + (p.type != Object::DynamicProperty::Alias || mode == ResolveAliases)) builder.addClassInfo("DefaultProperty", p.name); @@ -1937,7 +1937,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) b.setParameterNames(s.parameterNames); ((QmlVMEMetaData *)dynamicData.data())->methodCount++; - QmlVMEMetaData::MethodData methodData = + QmlVMEMetaData::MethodData methodData = { s.parameterNames.count(), 0, s.body.length(), 0 }; dynamicData.append((char *)&methodData, sizeof(methodData)); @@ -1945,19 +1945,19 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) { const Object::DynamicSlot &s = obj->dynamicSlots.at(ii); - QmlVMEMetaData::MethodData *data = + QmlVMEMetaData::MethodData *data = ((QmlVMEMetaData *)dynamicData.data())->methodData() + ii; data->bodyOffset = dynamicData.size(); - dynamicData.append((const char *)s.body.constData(), + dynamicData.append((const char *)s.body.constData(), (s.body.length() * sizeof(QChar))); } obj->metadata = builder.toRelocatableData(); builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata); - if (mode == IgnoreAliases && hasAlias) + if (mode == IgnoreAliases && hasAlias) compileState.aliasingObjects << obj; obj->synthdata = dynamicData; @@ -1969,7 +1969,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) static QStringList astNodeToStringList(QmlJS::AST::Node *node) { if (node->kind == QmlJS::AST::Node::Kind_IdentifierExpression) { - QString name = + QString name = static_cast<QmlJS::AST::IdentifierExpression *>(node)->name->asString(); return QStringList() << name; } else if (node->kind == QmlJS::AST::Node::Kind_FieldMemberExpression) { @@ -1980,13 +1980,13 @@ static QStringList astNodeToStringList(QmlJS::AST::Node *node) return rv; rv.append(expr->name->asString()); return rv; - } + } return QStringList(); } -bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, +bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, QByteArray &data, - Object *obj, + Object *obj, const Object::DynamicProperty &prop) { if (!prop.defaultValue) @@ -1994,27 +1994,27 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, if (prop.defaultValue->values.count() != 1 || prop.defaultValue->values.at(0)->object || - !prop.defaultValue->values.at(0)->value.isScript()) + !prop.defaultValue->values.at(0)->value.isScript()) COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST(); - if (!node) + if (!node) COMPILE_EXCEPTION(obj, "No property alias location"); // ### Can this happen? QStringList alias = astNodeToStringList(node); - if (alias.count() != 2) + if (alias.count() != 2) COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); - if (!compileState.ids.contains(alias.at(0))) + if (!compileState.ids.contains(alias.at(0))) COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); Object *idObject = compileState.ids[alias.at(0)]; int propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData()); - if (-1 == propIdx) + if (-1 == propIdx) COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); - + QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex)); @@ -2025,7 +2025,7 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, return true; } -bool QmlCompiler::buildBinding(QmlParser::Value *value, +bool QmlCompiler::buildBinding(QmlParser::Value *value, QmlParser::Property *prop, const BindingContext &ctxt) { @@ -2035,7 +2035,7 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value, QMetaProperty mp = prop->parent->metaObject()->property(prop->index); if (!mp.isWritable() && !QmlMetaType::isList(prop->type)) - COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property"); + COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property"); BindingReference reference; reference.expression = value->value; @@ -2047,11 +2047,12 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value, return true; } -void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, - QmlParser::Property *prop, +void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, + QmlParser::Property *prop, QmlParser::Object *obj, QmlParser::Property *valueTypeProperty) { + Q_UNUSED(obj); Q_ASSERT(compileState.bindings.contains(binding)); const BindingReference &ref = compileState.bindings.value(binding); @@ -2069,11 +2070,11 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, Q_ASSERT(ref.bindingContext.owner == 0 || (ref.bindingContext.owner != 0 && valueTypeProperty)); if (ref.bindingContext.owner) { - store.assignBinding.property = - QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index, + store.assignBinding.property = + QmlMetaPropertyPrivate::saveValueType(valueTypeProperty->index, prop->index); } else { - store.assignBinding.property = + store.assignBinding.property = QmlMetaPropertyPrivate::saveProperty(prop->index); } store.assignBinding.value = dataRef; @@ -2106,8 +2107,8 @@ bool QmlCompiler::completeComponentBuild() expr.expression = binding.expression; bs.compile(expr); - if (bs.isValid()) - binding.compiledData = + if (bs.isValid()) + binding.compiledData = QByteArray(bs.compileData(), bs.compileDataSize()); } @@ -2115,12 +2116,12 @@ bool QmlCompiler::completeComponentBuild() } /*! - Returns true if from can be assigned to a (QObject) property of type + Returns true if from can be assigned to a (QObject) property of type to. */ bool QmlCompiler::canCoerce(int to, QmlParser::Object *from) { - const QMetaObject *toMo = + const QMetaObject *toMo = QmlMetaType::rawMetaObjectForType(to); const QMetaObject *fromMo = from->metaObject(); @@ -2135,7 +2136,7 @@ bool QmlCompiler::canCoerce(int to, QmlParser::Object *from) QmlType *QmlCompiler::toQmlType(QmlParser::Object *from) { // ### Optimize - const QMetaObject *mo = from->metatype; + const QMetaObject *mo = from->metatype; QmlType *type = 0; while (!type && mo) { type = QmlMetaType::qmlType(mo); diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 3d55d3e..74bd15c 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -113,7 +113,7 @@ public: virtual void setCustomData(QObject *, const QByteArray &); }; #define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN_FROM), (VERSION_MAJ_TO)>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE)); QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 321feb9..f6d70e0 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -94,12 +94,12 @@ struct StaticQtMetaObject : public QObject }; QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) -: rootContext(0), currentBindContext(0), currentExpression(0), +: rootContext(0), currentBindContext(0), currentExpression(0), isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0), scriptEngine(this), rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) { - QScriptValue qtObject = + QScriptValue qtObject = scriptEngine.newQMetaObject(StaticQtMetaObject::get()); scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject); } @@ -115,7 +115,7 @@ QmlEnginePrivate::~QmlEnginePrivate() delete networkAccessManager; networkAccessManager = 0; - for(int ii = 0; ii < bindValues.count(); ++ii) + for(int ii = 0; ii < bindValues.count(); ++ii) clear(bindValues[ii]); for(int ii = 0; ii < parserStatus.count(); ++ii) clear(parserStatus[ii]); @@ -126,7 +126,7 @@ void QmlEnginePrivate::clear(SimpleList<QmlBinding> &bvs) for (int ii = 0; ii < bvs.count; ++ii) { QmlBinding *bv = bvs.at(ii); if(bv) { - QmlBindingPrivate *p = + QmlBindingPrivate *p = static_cast<QmlBindingPrivate *>(QObjectPrivate::get(bv)); p->mePtr = 0; } @@ -138,7 +138,7 @@ void QmlEnginePrivate::clear(SimpleList<QmlParserStatus> &pss) { for (int ii = 0; ii < pss.count; ++ii) { QmlParserStatus *ps = pss.at(ii); - if(ps) + if(ps) ps->d = 0; } pss.clear(); @@ -166,7 +166,7 @@ void QmlEnginePrivate::init() scriptEngine.globalObject().setProperty(QLatin1String("createComponent"), scriptEngine.newFunction(QmlEnginePrivate::createComponent, 1)); - if (QCoreApplication::instance()->thread() == q->thread() && + if (QCoreApplication::instance()->thread() == q->thread() && QmlEngineDebugServer::isDebuggingEnabled()) { qmlEngineDebugServer(); isDebugging = true; @@ -196,7 +196,7 @@ QmlEnginePrivate::queryObject(const QString &propName, { QScriptClass::QueryFlags rv = 0; - QmlMetaProperty prop(obj, propName); + QmlMetaProperty prop(obj, propName, rootContext); if (prop.type() == QmlMetaProperty::Invalid) { QPair<const QMetaObject *, QString> key = qMakePair(obj->metaObject(), propName); @@ -279,14 +279,14 @@ QScriptValue QmlEnginePrivate::propertyObject(const QScriptString &propName, \brief The QmlEngine class provides an environment for instantiating QML components. \mainclass - Each QML component is instantiated in a QmlContext. QmlContext's are + Each QML component is instantiated in a QmlContext. QmlContext's are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QmlEngine. Prior to creating any QML components, an application must have created a QmlEngine to gain access to a QML context. The following example shows how to create a simple Text item. - + \code QmlEngine engine; QmlComponent component(&engine, "Text { text: \"Hello world!\" }"); @@ -317,7 +317,7 @@ QmlEngine::QmlEngine(QObject *parent) /*! Destroys the QmlEngine. - Any QmlContext's created on this engine will be invalidated, but not + Any QmlContext's created on this engine will be invalidated, but not destroyed (unless they are parented to the QmlEngine object). */ QmlEngine::~QmlEngine() @@ -340,13 +340,13 @@ void QmlEngine::clearComponentCache() } /*! - Returns the engine's root context. + Returns the engine's root context. - The root context is automatically created by the QmlEngine. Data that + The root context is automatically created by the QmlEngine. Data that should be available to all QML component instances instantiated by the engine should be put in the root context. - Additional data that should only be available to a subset of component + Additional data that should only be available to a subset of component instances should be added to sub-contexts parented to the root context. */ QmlContext *QmlEngine::rootContext() @@ -374,13 +374,13 @@ void QmlEngine::setNetworkAccessManager(QNetworkAccessManager *network) Returns the common QNetworkAccessManager used by all QML elements instantiated by this engine. - The default implements no caching, cookiejar, etc., just a default + The default implements no caching, cookiejar, etc., just a default QNetworkAccessManager. */ QNetworkAccessManager *QmlEngine::networkAccessManager() const { Q_D(const QmlEngine); - if (!d->networkAccessManager) + if (!d->networkAccessManager) d->networkAccessManager = new QNetworkAccessManager; return d->networkAccessManager; } @@ -389,7 +389,7 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const Return the base URL for this engine. The base URL is only used to resolve components when a relative URL is passed to the QmlComponent constructor. - If a base URL has not been explicitly set, this method returns the + If a base URL has not been explicitly set, this method returns the application's current working directory. \sa setBaseUrl() @@ -405,7 +405,7 @@ QUrl QmlEngine::baseUrl() const } /*! - Set the base URL for this engine to \a url. + Set the base URL for this engine to \a url. \sa baseUrl() */ @@ -427,7 +427,7 @@ QmlContext *QmlEngine::contextForObject(const QObject *object) QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object)); - QmlSimpleDeclarativeData *data = + QmlSimpleDeclarativeData *data = static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); return data?data->context:0; @@ -444,7 +444,7 @@ void QmlEngine::setContextForObject(QObject *object, QmlContext *context) { QObjectPrivate *priv = QObjectPrivate::get(object); - QmlSimpleDeclarativeData *data = + QmlSimpleDeclarativeData *data = static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); if (data && data->context) { @@ -487,7 +487,7 @@ QmlEngine *qmlEngine(const QObject *obj) QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create) { - QmlExtendedDeclarativeData *edata = + QmlExtendedDeclarativeData *edata = QmlExtendedDeclarativeData::get(const_cast<QObject *>(object), true); QObject *rv = edata->attachedProperties.value(id); @@ -500,7 +500,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre rv = pf(const_cast<QObject *>(object)); - if (rv) + if (rv) edata->attachedProperties.insert(id, rv); return rv; @@ -508,7 +508,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre void QmlSimpleDeclarativeData::destroyed(QObject *object) { - if (context) + if (context) context->d_func()->contextObjects.removeAll(object); } @@ -537,7 +537,7 @@ QScriptEngine *QmlEngine::scriptEngine() to the special needs of QML requiring more functionality than a standard QtScript QObject. */ -QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object, +QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object, QmlEngine* engine) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -597,12 +597,12 @@ QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object, If you want to just create an arbitrary string of QML, instead of loading a qml file, consider the createQmlObject() function. */ -QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt, +QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine) { QmlComponentJS* c; - QmlEnginePrivate *activeEnginePriv = + QmlEnginePrivate *activeEnginePriv = static_cast<QmlScriptEngine*>(engine)->p; QmlEngine* activeEngine = activeEnginePriv->q_func(); @@ -646,11 +646,11 @@ QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt, */ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) { - QmlEnginePrivate *activeEnginePriv = + QmlEnginePrivate *activeEnginePriv = static_cast<QmlScriptEngine*>(engine)->p; QmlEngine* activeEngine = activeEnginePriv->q_func(); - if(ctxt->argumentCount() < 2) + if(ctxt->argumentCount() < 2) return engine->nullValue(); QString qml = ctxt->argument(0).toString(); @@ -664,7 +664,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi if(component.isError()) { QList<QmlError> errors = component.errors(); qWarning() <<"QmlEngine::createQmlObject():"; - foreach (const QmlError &error, errors) + foreach (const QmlError &error, errors) qWarning() << " " << error; return engine->nullValue(); @@ -675,7 +675,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi if(component.isError()) { QList<QmlError> errors = component.errors(); qWarning() <<"QmlEngine::createQmlObject():"; - foreach (const QmlError &error, errors) + foreach (const QmlError &error, errors) qWarning() << " " << error; return engine->nullValue(); @@ -690,14 +690,14 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi } QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) -: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)), +: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)), engine(bindengine) { } QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val) { - QmlEnginePrivate *ep = + QmlEnginePrivate *ep = static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine)); QScriptClass *sc = val.scriptClass(); @@ -708,12 +708,12 @@ QVariant QmlScriptClass::toVariant(QmlEngine *engine, const QScriptValue &val) } else if (sc == ep->objectClass) { return QVariant::fromValue(val.data().toQObject()); } else if (sc == ep->valueTypeClass) { - QmlValueTypeReference ref = + QmlValueTypeReference ref = qvariant_cast<QmlValueTypeReference>(val.data().toVariant()); if (!ref.object) return QVariant(); - + QMetaProperty p = ref.object->metaObject()->property(ref.property); return p.read(ref.object); } @@ -735,13 +735,13 @@ QmlContextScriptClass::~QmlContextScriptClass() { } -QScriptClass::QueryFlags +QScriptClass::QueryFlags QmlContextScriptClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id) { Q_UNUSED(flags); - QmlContext *bindContext = + QmlContext *bindContext = static_cast<QmlContext*>(object.data().toQObject()); QueryFlags rv = 0; @@ -755,11 +755,11 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object, if (bindContext->d_func()->propertyNames.contains(propName)) { rv |= HandlesReadAccess; *id = VariantPropertyId; - } + } for (int ii = 0; !rv && ii < bindContext->d_func()->defaultObjects.count(); ++ii) { rv = QmlEnginePrivate::get(engine)->queryObject(propName, id, bindContext->d_func()->defaultObjects.at(ii)); - if (rv) + if (rv) *id |= (ii << 24); } @@ -767,10 +767,10 @@ QmlContextScriptClass::queryProperty(const QScriptValue &object, } QScriptValue QmlContextScriptClass::property(const QScriptValue &object, - const QScriptString &name, + const QScriptString &name, uint id) { - QmlContext *bindContext = + QmlContext *bindContext = static_cast<QmlContext*>(object.data().toQObject()); #ifdef PROPERTY_DEBUG @@ -829,7 +829,7 @@ void QmlContextScriptClass::setProperty(QScriptValue &object, { Q_UNUSED(name); - QmlContext *bindContext = + QmlContext *bindContext = static_cast<QmlContext*>(object.data().toQObject()); #ifdef PROPERTY_DEBUG @@ -863,12 +863,13 @@ QmlValueTypeScriptClass::~QmlValueTypeScriptClass() { } -QmlValueTypeScriptClass::QueryFlags +QmlValueTypeScriptClass::QueryFlags QmlValueTypeScriptClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id) { - QmlValueTypeReference ref = + Q_UNUSED(flags); + QmlValueTypeReference ref = qvariant_cast<QmlValueTypeReference>(object.data().toVariant()); if (!ref.object) @@ -883,7 +884,7 @@ QmlValueTypeScriptClass::queryProperty(const QScriptValue &object, QMetaProperty prop = ref.object->metaObject()->property(idx); - QmlValueTypeScriptClass::QueryFlags rv = + QmlValueTypeScriptClass::QueryFlags rv = QmlValueTypeScriptClass::HandlesReadAccess; if (prop.isWritable()) rv |= QmlValueTypeScriptClass::HandlesWriteAccess; @@ -892,10 +893,11 @@ QmlValueTypeScriptClass::queryProperty(const QScriptValue &object, } QScriptValue QmlValueTypeScriptClass::property(const QScriptValue &object, - const QScriptString &name, + const QScriptString &name, uint id) { - QmlValueTypeReference ref = + Q_UNUSED(name); + QmlValueTypeReference ref = qvariant_cast<QmlValueTypeReference>(object.data().toVariant()); if (!ref.object) @@ -914,7 +916,8 @@ void QmlValueTypeScriptClass::setProperty(QScriptValue &object, uint id, const QScriptValue &value) { - QmlValueTypeReference ref = + Q_UNUSED(name); + QmlValueTypeReference ref = qvariant_cast<QmlValueTypeReference>(object.data().toVariant()); if (!ref.object) @@ -983,7 +986,7 @@ QScriptClass::QueryFlags QmlObjectScriptClass::queryProperty(const QScriptValue } QScriptValue QmlObjectScriptClass::property(const QScriptValue &object, - const QScriptString &name, + const QScriptString &name, uint id) { QObject *obj = object.data().toQObject(); @@ -993,7 +996,7 @@ QScriptValue QmlObjectScriptClass::property(const QScriptValue &object, qWarning() << "QmlObject Property:" << propName << obj; #endif - QScriptValue rv = + QScriptValue rv = QmlEnginePrivate::get(engine)->propertyObject(name, obj, id); if (rv.isValid()) { #ifdef PROPERTY_DEBUG @@ -1227,7 +1230,7 @@ void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url) */ void QmlEngine::addImportPath(const QString& path) { - if (qmlImportTrace()) + if (qmlImportTrace()) qDebug() << "QmlEngine::addImportPath" << path; Q_D(QmlEngine); d->fileImportPath.prepend(path); @@ -1250,7 +1253,7 @@ void QmlEngine::addImportPath(const QString& path) bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType) const { bool ok = imports->d->add(imports->base,uri,prefix,version,importType,fileImportPath); - if (qmlImportTrace()) + if (qmlImportTrace()) qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok; return ok; } @@ -1279,7 +1282,7 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ if (!t) t = QmlMetaType::qmlType(type); if (t) { if (type_return) *type_return = t; - if (qmlImportTrace()) + if (qmlImportTrace()) qDebug() << "QmlEngine::resolveType" << type << "= (builtin)"; return true; } @@ -1291,12 +1294,12 @@ bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& typ if (url.isValid()) { if (url_return) *url_return = url; - if (qmlImportTrace()) + if (qmlImportTrace()) qDebug() << "QmlEngine::resolveType" << type << "=" << url; return true; } } - if (qmlImportTrace()) + if (qmlImportTrace()) qDebug() << "QmlEngine::resolveType" << type << " not found"; return false; } diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 18cdd83..dffae6c 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -71,6 +71,7 @@ #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlexpression.h> #include <QtScript/qscriptengine.h> +#include <private/qmlmetaproperty_p.h> QT_BEGIN_NAMESPACE @@ -177,6 +178,7 @@ public: } QmlValueTypeFactory valueTypes; + QHash<const QMetaObject *, QmlMetaObjectCache> propertyCache; struct Imports { Imports(); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 3d040e5..e6ffd50 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -56,31 +56,27 @@ Q_DECLARE_METATYPE(QList<QObject *>); QT_BEGIN_NAMESPACE -class QMetaPropertyEx : public QMetaProperty +QmlMetaObjectCache::Data +QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject) { -public: - QMetaPropertyEx() - : propertyType(-1) {} - - QMetaPropertyEx(const QMetaProperty &p) - : QMetaProperty(p), propertyType(p.userType()) {} - - QMetaPropertyEx(const QMetaPropertyEx &o) - : QMetaProperty(o), - propertyType(o.propertyType) {} - - QMetaPropertyEx &operator=(const QMetaPropertyEx &o) - { - static_cast<QMetaProperty *>(this)->operator=(o); - propertyType = o.propertyType; - return *this; - } + QHash<QString, Data>::ConstIterator iter = properties.find(name); + if (iter != properties.end()) { + return *iter; + } else { + Data cacheData = { -1, -1 }; - private: - friend class QmlMetaProperty; - int propertyType; -}; + int idx = metaObject->indexOfProperty(name.toUtf8().constData()); + if (idx == -1) + return cacheData; + QMetaProperty property = metaObject->property(idx); + cacheData.propType = property.userType(); + cacheData.coreIndex = idx; + properties.insert(name, cacheData); + + return cacheData; + } +} /*! \class QmlMetaProperty @@ -111,16 +107,13 @@ struct CachedPropertyData { int coreIdx; }; -// ### not thread safe -static QHash<const QMetaObject *, CachedPropertyData> qmlCacheDefProp; - /*! Creates a QmlMetaProperty for the default property of \a obj. If there is no default property, an invalid QmlMetaProperty will be created. */ QmlMetaProperty::QmlMetaProperty(QObject *obj) { - initDefault(obj); + d->initDefault(obj); } /*! @@ -132,32 +125,24 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, QmlContext *ctxt) : d(new QmlMetaPropertyPrivate) { d->context = ctxt; - initDefault(obj); + d->initDefault(obj); } -void QmlMetaProperty::initDefault(QObject *obj) +/*! + Initialize from the default property of \a obj +*/ +void QmlMetaPropertyPrivate::initDefault(QObject *obj) { if (!obj) return; - d->object = obj; - QHash<const QMetaObject *, CachedPropertyData>::ConstIterator iter = - qmlCacheDefProp.find(obj->metaObject()); - if (iter != qmlCacheDefProp.end()) { - d->name = iter->name; - d->propType = iter->propType; - d->coreIdx = iter->coreIdx; - } else { - QMetaPropertyEx p(QmlMetaType::defaultProperty(obj)); - d->name = QLatin1String(p.name()); - d->propType = p.propertyType; - d->coreIdx = p.propertyIndex(); - if (!QObjectPrivate::get(obj)->metaObject) - qmlCacheDefProp.insert(obj->metaObject(), CachedPropertyData(d->name, d->propType, d->coreIdx)); - } - if (!d->name.isEmpty()) { - d->type = Property | Default; - } + object = obj; + QMetaProperty p = QmlMetaType::defaultProperty(obj); + name = QLatin1String(p.name()); + propType = p.userType();; + coreIdx = p.propertyIndex(); + if (!name.isEmpty()) + type = QmlMetaProperty::Property | QmlMetaProperty::Default; } /*! @@ -171,22 +156,20 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) d->context = ctxt; d->object = obj; d->type = Property; - QMetaPropertyEx p(obj->metaObject()->property(idx)); - d->propType = p.propertyType; + QMetaProperty p = obj->metaObject()->property(idx); + d->propType = p.userType(); d->coreIdx = idx; if (p.name() != 0) d->name = QLatin1String(p.name()); } -// ### Not thread safe!!!! -static QHash<const QMetaObject *, QHash<QString, CachedPropertyData> > qmlCacheProps; /*! Creates a QmlMetaProperty for the property \a name of \a obj. */ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) : d(new QmlMetaPropertyPrivate) { - initProperty(obj, name); + d->initProperty(obj, name); } /*! @@ -197,51 +180,62 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext * : d(new QmlMetaPropertyPrivate) { d->context = ctxt; - initProperty(obj, name); + d->initProperty(obj, name); } -void QmlMetaProperty::initProperty(QObject *obj, const QString &name) +void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) { - d->name = name; - d->object = obj; + QmlEnginePrivate *enginePrivate = 0; + if (context && context->engine()) + enginePrivate = QmlEnginePrivate::get(context->engine()); + + this->name = name; + object = obj; + if (name.isEmpty() || !obj) return; if (name.at(0).isUpper()) { // Attached property - d->attachedFunc = QmlMetaType::attachedPropertiesFuncId(name.toLatin1()); - if (d->attachedFunc != -1) - d->type = Property | Attached; + attachedFunc = QmlMetaType::attachedPropertiesFuncId(name.toLatin1()); + if (attachedFunc != -1) + type = QmlMetaProperty::Property | QmlMetaProperty::Attached; return; - } else if (name.count() >= 3 && name.startsWith(QLatin1String("on")) && name.at(2).isUpper()) { + + } else if (name.count() >= 3 && + name.at(0) == QChar(QLatin1Char('o')) && + name.at(1) == QChar(QLatin1Char('n')) && + name.at(2).isUpper()) { // Signal QString signalName = name.mid(2); signalName[0] = signalName.at(0).toLower(); - d->findSignalInt(obj, signalName); - if (d->signal.signature() != 0) { - d->type = SignalProperty; + findSignalInt(obj, signalName); + if (signal.signature() != 0) { + type = QmlMetaProperty::SignalProperty; return; } } // Property - QHash<QString, CachedPropertyData> &props = qmlCacheProps[obj->metaObject()]; - QHash<QString, CachedPropertyData>::ConstIterator iter = props.find(name); - if (iter != props.end()) { - d->name = iter->name; - d->propType = iter->propType; - d->coreIdx = iter->coreIdx; + if (!QObjectPrivate::get(obj)->metaObject && enginePrivate) { + // Can cache + QmlMetaObjectCache &cache = + enginePrivate->propertyCache[obj->metaObject()]; + QmlMetaObjectCache::Data data = cache.property(name, obj->metaObject()); + if (data.coreIndex != -1) { + type = QmlMetaProperty::Property; + propType = data.propType; + coreIdx = data.coreIndex; + } } else { - QMetaPropertyEx p = QmlMetaType::property(obj, name.toLatin1().constData()); - d->name = QLatin1String(p.name()); - d->propType = p.propertyType; - d->coreIdx = p.propertyIndex(); - if (!QObjectPrivate::get(obj)->metaObject) - props.insert(name, CachedPropertyData(d->name, d->propType, d->coreIdx)); + // Can't cache + QMetaProperty p = QmlMetaType::property(obj, name.toUtf8().constData()); + propType = p.userType(); + coreIdx = p.propertyIndex(); + if (p.name()) + type = QmlMetaProperty::Property; } - if (!d->name.isEmpty()) - d->type = Property; } /*! @@ -1037,18 +1031,18 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) QmlValueType *valueType = qmlValueTypes()->valueTypes[p.type()]; - QMetaPropertyEx p2(valueType->metaObject()->property(valueTypeIdx)); + QMetaProperty p2(valueType->metaObject()->property(valueTypeIdx)); d->name = QLatin1String(p2.name()); - d->propType = p2.propertyType; + d->propType = p2.userType(); d->coreIdx = coreIdx; d->valueTypeIdx = valueTypeIdx; d->valueTypeId = p.type(); } else if (d->type & Property) { - QMetaPropertyEx p(obj->metaObject()->property(id)); + QMetaProperty p(obj->metaObject()->property(id)); d->name = QLatin1String(p.name()); - d->propType = p.propertyType; + d->propType = p.userType(); d->coreIdx = id; } else if (d->type & SignalProperty) { d->signal = obj->metaObject()->method(id); @@ -1086,7 +1080,7 @@ QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj, QmlMetaProperty prop(object, pathName); if (jj == path.count() - 2 && - prop.propertyType() < QVariant::UserType && + prop.propertyType() < (int)QVariant::UserType && qmlValueTypes()->valueTypes[prop.propertyType()]) { // We're now at a value type property QObject *typeObject = diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index 2470d5d..434ff55 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -129,8 +129,6 @@ public: int coreIndex() const; private: - void initDefault(QObject *obj); - void initProperty(QObject *obj, const QString &name); friend class QmlEnginePrivate; QmlMetaPropertyPrivate *d; }; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 64cdbae..0410dd6 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -58,6 +58,19 @@ QT_BEGIN_NAMESPACE +class QmlMetaObjectCache +{ +public: + struct Data { + int propType; + int coreIndex; + }; + + QHash<QString, Data> properties; + + Data property(const QString &, const QMetaObject *); +}; + class QmlContext; class QmlMetaPropertyPrivate { @@ -86,6 +99,9 @@ public: mutable QmlMetaProperty::PropertyCategory category; + void initProperty(QObject *obj, const QString &name); + void initDefault(QObject *obj); + QObject *attachedObject() const; void findSignalInt(QObject *, const QString &); diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index a037702..29fe026 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -104,7 +104,7 @@ class QmlTypePrivate { public: QmlTypePrivate(); - + void init() const; bool m_isInterface : 1; @@ -128,7 +128,7 @@ public: QmlTypePrivate::QmlTypePrivate() : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0), m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0), - m_parserStatusCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), + m_parserStatusCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false) { } @@ -149,11 +149,11 @@ QmlType::QmlType(int type, int listType, int qmlListType, } QmlType::QmlType(int type, int listType, int qmlListType, - QmlPrivate::Func opFunc, const char *qmlName, - const QMetaObject *metaObject, - QmlAttachedPropertiesFunc attachedPropertiesFunc, + QmlPrivate::Func opFunc, const char *qmlName, + const QMetaObject *metaObject, + QmlAttachedPropertiesFunc attachedPropertiesFunc, const QMetaObject *attachedType, - int parserStatusCast, QmlPrivate::CreateFunc extFunc, + int parserStatusCast, QmlPrivate::CreateFunc extFunc, const QMetaObject *extMetaObject, int index, QmlCustomParser *customParser) : d(new QmlTypePrivate) @@ -195,7 +195,7 @@ void QmlTypePrivate::init() const QMetaObject *mmo = new QMetaObject; *mmo = *m_extMetaObject; mmo->d.superdata = mo; - QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0 }; + QmlProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 }; m_metaObjects << data; } @@ -207,9 +207,9 @@ void QmlTypePrivate::init() const QMetaObject *mmo = new QMetaObject; *mmo = *t->d->m_extMetaObject; mmo->d.superdata = m_baseMetaObject; - if (!m_metaObjects.isEmpty()) + if (!m_metaObjects.isEmpty()) m_metaObjects.last().metaObject->d.superdata = mmo; - QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0 }; + QmlProxyMetaObject::ProxyData data = { mmo, t->d->m_extFunc, 0, 0 }; m_metaObjects << data; } } @@ -217,9 +217,9 @@ void QmlTypePrivate::init() const } for (int ii = 0; ii < m_metaObjects.count(); ++ii) { - m_metaObjects[ii].propertyOffset = + m_metaObjects[ii].propertyOffset = m_metaObjects.at(ii).metaObject->propertyOffset(); - m_metaObjects[ii].methodOffset = + m_metaObjects[ii].methodOffset = m_metaObjects.at(ii).metaObject->methodOffset(); } @@ -276,7 +276,7 @@ QObject *QmlType::create() const QObject *rv = 0; d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv); - if (rv && !d->m_metaObjects.isEmpty()) + if (rv && !d->m_metaObjects.isEmpty()) (void *)new QmlProxyMetaObject(rv, &d->m_metaObjects); return rv; @@ -386,7 +386,7 @@ int QmlType::index() const } int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, - QmlPrivate::Func listFunction, + QmlPrivate::Func listFunction, const char *iid) { QWriteLocker lock(metaTypeDataLock()); @@ -404,11 +404,11 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, if (!type->qmlTypeName().isEmpty()) data->nameToType.insert(type->qmlTypeName(), type); - if (data->interfaces.size() < id.typeId) + if (data->interfaces.size() < id.typeId) data->interfaces.resize(id.typeId + 16); - if (data->qmllists.size() < id.qmlListId) + if (data->qmllists.size() < id.qmlListId) data->qmllists.resize(id.qmlListId + 16); - if (data->lists.size() < id.listId) + if (data->lists.size() < id.listId) data->lists.resize(id.listId + 16); data->interfaces.setBit(id.typeId, true); data->qmllists.setBit(id.qmlListId, true); @@ -448,16 +448,20 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun int pStatus, int object, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser) { Q_UNUSED(object); - QByteArray name = cname; - + QByteArray name; if (uri) { + // Convert to path + name = uri; + name.replace('.','/'); if (version) { - name = QByteArray(uri) + '/' + version + '/' + name; - } else { - name = QByteArray(uri) + '/' + name; + name += '/'; + name += version; } + name += '/'; + name += cname; } else { // No URI? No version! + name = cname; Q_ASSERT(!version); } @@ -484,16 +488,16 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun data->idToType.insert(type->qListTypeId(), type); data->idToType.insert(type->qmlListTypeId(), type); - if (!type->qmlTypeName().isEmpty()) + if (!type->qmlTypeName().isEmpty()) data->nameToType.insert(type->qmlTypeName(), type); data->metaObjectToType.insert(type->baseMetaObject(), type); - - if (data->objects.size() <= id.typeId) + + if (data->objects.size() <= id.typeId) data->objects.resize(id.typeId + 16); - if (data->qmllists.size() <= id.qmlListId) + if (data->qmllists.size() <= id.qmlListId) data->qmllists.resize(id.qmlListId + 16); - if (data->lists.size() <= id.listId) + if (data->lists.size() <= id.listId) data->lists.resize(id.listId + 16); data->objects.setBit(id.typeId, true); data->qmllists.setBit(id.qmlListId, true); @@ -518,7 +522,7 @@ QObject *QmlMetaType::toQObject(const QVariant &v) if (!isObject(v.userType())) return 0; - // NOTE: This assumes a cast to QObject does not alter the + // NOTE: This assumes a cast to QObject does not alter the // object pointer QObject *rv = *(QObject **)v.constData(); return rv; @@ -527,7 +531,7 @@ QObject *QmlMetaType::toQObject(const QVariant &v) /* Returns the item type for a list of type \a id. */ -int QmlMetaType::listType(int id) +int QmlMetaType::listType(int id) { QReadLocker lock(metaTypeDataLock()); QmlMetaTypeData *data = metaTypeData(); @@ -574,7 +578,7 @@ bool QmlMetaType::append(const QVariant &list, const QVariant &item) QmlMetaTypeData *data = metaTypeData(); QmlType *type = data->idToType.value(userType); lock.unlock(); - if (type && type->qListTypeId() == userType && + if (type && type->qListTypeId() == userType && item.userType() == type->typeId()) { type->listAppend(list, item); return true; @@ -703,7 +707,7 @@ QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFuncById(int id) return data->types.at(id)->attachedPropertiesFunction(); } -QmlAttachedPropertiesFunc +QmlAttachedPropertiesFunc QmlMetaType::attachedPropertiesFunc(const QByteArray &name) { QReadLocker lock(metaTypeDataLock()); @@ -876,8 +880,8 @@ QVariant QmlMetaType::listAt(const QVariant &v, int idx) return 0; } -/*! - A custom string convertor allows you to specify a function pointer that +/*! + A custom string convertor allows you to specify a function pointer that returns a variant of \a type. For example, if you have written your own icon class that you want to support as an object property assignable in QML: @@ -902,7 +906,7 @@ void QmlMetaType::registerCustomStringConverter(int type, StringConverter conver } /*! - Return the custom string converter for \a type, previously installed through + Return the custom string converter for \a type, previously installed through registerCustomStringConverter() */ QmlMetaType::StringConverter QmlMetaType::customStringConverter(int type) diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 3d5fa61..e821759 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -240,7 +240,7 @@ namespace QmlPrivate InstanceType(int); }; - template<typename T> + template<typename T, int VMAJ, int VMIN1, int VMIN2> struct Define { static InstanceType instance; }; diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp index e93fbc1..ca968fc 100644 --- a/src/declarative/qml/qmlvaluetype.cpp +++ b/src/declarative/qml/qmlvaluetype.cpp @@ -46,13 +46,13 @@ QT_BEGIN_NAMESPACE QmlValueTypeFactory::QmlValueTypeFactory() { // ### Optimize - for (int ii = 0; ii < (QVariant::UserType - 1); ++ii) + for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii) valueTypes[ii] = valueType(ii); } QmlValueTypeFactory::~QmlValueTypeFactory() { - for (int ii = 0; ii < (QVariant::UserType - 1); ++ii) + for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii) delete valueTypes[ii]; } diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index 987ccb0..1fb321c 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -66,13 +66,13 @@ public: qreal velocityms; int lastTime; qreal mass; + bool useMass; qreal spring; qreal damping; qreal velocity; qreal epsilon; qreal modulus; bool haveModulus; - bool useMass; bool enabled; enum Mode { diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 6fade03..e714bc7 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -124,6 +124,18 @@ QColor QmlPalette::base() const } /*! + \qmlproperty color Palette::text + The text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QmlPalette::text() const +{ + Q_D(const QmlPalette); + return d->palette.color(d->group, QPalette::Text); +} + +/*! \qmlproperty color Palette::alternateBase The alternate base color of the current color group. @@ -260,27 +272,23 @@ QColor QmlPalette::darker(const QColor& color) const } /*! - \qmlproperty enum Palette::colorGroup + \qmlproperty QPalette::ColorGroup Palette::colorGroup - The color group of the palette. It can be one of: - \list - \o Active - used for the window that has focus. - \o Inactive - used for other windows. - \o Disabled - used for widgets that are disabled for some reason. - \endlist + The color group of the palette. It can be Active, Inactive or Disabled. + Active is the default. \sa QPalette::ColorGroup */ -QmlPalette::ColorGroup QmlPalette::colorGroup() const +QPalette::ColorGroup QmlPalette::colorGroup() const { Q_D(const QmlPalette); - return (QmlPalette::ColorGroup)int(d->group); + return d->group; } -void QmlPalette::setColorGroup(ColorGroup colorGroup) +void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup) { Q_D(QmlPalette); - d->group = (QPalette::ColorGroup)int(colorGroup); + d->group = colorGroup; emit paletteChanged(); } diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index 7de5e0e..e381814 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -57,12 +57,12 @@ class Q_DECLARATIVE_EXPORT QmlPalette : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QmlPalette) - Q_ENUMS(ColorGroup) - Q_PROPERTY(ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) + Q_PROPERTY(QPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) + Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) @@ -78,13 +78,11 @@ public: QmlPalette(QObject *parent=0); ~QmlPalette(); - enum ColorGroup { Disabled = QPalette::Disabled, Active = QPalette::Active, - Inactive = QPalette::Inactive, Normal = QPalette::Normal }; - QColor window() const; QColor windowText() const; QColor base() const; + QColor text() const; QColor alternateBase() const; QColor button() const; @@ -99,8 +97,8 @@ public: QColor highlight() const; QColor highlightedText() const; - ColorGroup colorGroup() const; - void setColorGroup(ColorGroup); + QPalette::ColorGroup colorGroup() const; + void setColorGroup(QPalette::ColorGroup); // FIXME: Move to utility class? Q_INVOKABLE QColor lighter(const QColor&) const; diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index af60a6f..b5ba909 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,16 +53,16 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() +Action::Action() : restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } -Action::Action(QObject *target, const QString &propertyName, +Action::Action(QObject *target, const QString &propertyName, const QVariant &value) : restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0), - toBinding(0), event(0), specifiedObject(target), + toBinding(0), event(0), specifiedObject(target), specifiedProperty(propertyName) { property = QmlMetaProperty::createProperty(target, propertyName); @@ -112,6 +112,7 @@ void ActionEvent::clearReverseBindings() bool ActionEvent::override(ActionEvent *other) { + Q_UNUSED(other); return false; } @@ -213,7 +214,7 @@ QmlBinding *QmlState::when() const return d->when; } -void QmlState::setWhen(QmlBinding *when) +void QmlState::setWhen(QmlBinding *when) { Q_D(QmlState); d->when = when; @@ -300,7 +301,7 @@ void QmlStatePrivate::complete() // Generate a list of actions for this state. This includes coelescing state // actions that this state "extends" -QmlStateOperation::ActionList +QmlStateOperation::ActionList QmlStatePrivate::generateActionList(QmlStateGroup *group) const { QmlStateOperation::ActionList applyList; @@ -342,7 +343,7 @@ void QmlState::cancel() d->transitionManager.cancel(); } -void Action::deleteFromBinding() +void Action::deleteFromBinding() { if (fromBinding) { property.setBinding(0); @@ -362,7 +363,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->reverting.clear(); if (revert) { - QmlStatePrivate *revertPrivate = + QmlStatePrivate *revertPrivate = static_cast<QmlStatePrivate*>(revert->d_ptr); d->revertList = revertPrivate->revertList; revertPrivate->revertList.clear(); @@ -419,7 +420,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } } } - + // Any reverts from a previous state that aren't carried forth // into this state need to be translated into apply actions for (int ii = 0; ii < d->revertList.count(); ++ii) { @@ -466,7 +467,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever // Output for debugging if (stateChangeDebug()) { foreach(const Action &action, applyList) { - qWarning() << " Action:" << action.property.object() + qWarning() << " Action:" << action.property.object() << action.property.name() << action.toValue; } } diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 7caf3ed..1f53bee 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -457,22 +457,22 @@ QList<Action> QmlSetAnchors::extraActions() if (d->target) { Action a; a.fromValue = d->origX; - a.property = QmlMetaProperty(d->target, "x"); + a.property = QmlMetaProperty(d->target, QLatin1String("x")); extra << a; a.fromValue = d->origY; - a.property = QmlMetaProperty(d->target, "y"); + a.property = QmlMetaProperty(d->target, QLatin1String("y")); extra << a; a.fromValue = d->origWidth; - a.property = QmlMetaProperty(d->target, "width"); + a.property = QmlMetaProperty(d->target, QLatin1String("width")); extra << a; a.fromValue = d->origHeight; - a.property = QmlMetaProperty(d->target, "height"); + a.property = QmlMetaProperty(d->target, QLatin1String("height")); extra << a; } - + return extra; } diff --git a/tests/auto/declarative/qmlparser/MyComponent.qml b/tests/auto/declarative/qmlparser/MyComponent.qml index 5caa547..1a23277 100644 --- a/tests/auto/declarative/qmlparser/MyComponent.qml +++ b/tests/auto/declarative/qmlparser/MyComponent.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Test 1.0 MyQmlObject { property real x; diff --git a/tests/auto/declarative/qmlparser/MyContainerComponent.qml b/tests/auto/declarative/qmlparser/MyContainerComponent.qml index cf17dcc..61f54c5 100644 --- a/tests/auto/declarative/qmlparser/MyContainerComponent.qml +++ b/tests/auto/declarative/qmlparser/MyContainerComponent.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Test 1.0 MyContainer { property int x diff --git a/tests/auto/declarative/qmlparser/assignBasicTypes.txt b/tests/auto/declarative/qmlparser/assignBasicTypes.txt index 71e400d..cef9f8d 100644 --- a/tests/auto/declarative/qmlparser/assignBasicTypes.txt +++ b/tests/auto/declarative/qmlparser/assignBasicTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { flagProperty: "FlagVal1 | FlagVal3" enumProperty: "EnumVal2" diff --git a/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt b/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt index f3a7ac7..399fcea 100644 --- a/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt +++ b/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onLiteralSignal: 10 } diff --git a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt index 0d6bc4e..789cc66 100644 --- a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt +++ b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onBasicSignal: MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/assignObjectToVariant.txt b/tests/auto/declarative/qmlparser/assignObjectToVariant.txt index 180221d..28c68c4 100644 --- a/tests/auto/declarative/qmlparser/assignObjectToVariant.txt +++ b/tests/auto/declarative/qmlparser/assignObjectToVariant.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { property var a; a: MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/assignQmlComponent.txt b/tests/auto/declarative/qmlparser/assignQmlComponent.txt index 6b6d77f..20bdc55 100644 --- a/tests/auto/declarative/qmlparser/assignQmlComponent.txt +++ b/tests/auto/declarative/qmlparser/assignQmlComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyComponent { x: 10; y: 11; } } diff --git a/tests/auto/declarative/qmlparser/assignSignal.txt b/tests/auto/declarative/qmlparser/assignSignal.txt index 6c0fd54..153b403 100644 --- a/tests/auto/declarative/qmlparser/assignSignal.txt +++ b/tests/auto/declarative/qmlparser/assignSignal.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onBasicSignal: basicSlot() } diff --git a/tests/auto/declarative/qmlparser/assignTypeExtremes.txt b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt index dbd281a..60ede52 100644 --- a/tests/auto/declarative/qmlparser/assignTypeExtremes.txt +++ b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { uintProperty: 4000000000 intProperty: -2000000000 diff --git a/tests/auto/declarative/qmlparser/attachedProperties.txt b/tests/auto/declarative/qmlparser/attachedProperties.txt index bfe5733..8343754 100644 --- a/tests/auto/declarative/qmlparser/attachedProperties.txt +++ b/tests/auto/declarative/qmlparser/attachedProperties.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { MyQmlObject.value: 10 } diff --git a/tests/auto/declarative/qmlparser/autoComponentCreation.txt b/tests/auto/declarative/qmlparser/autoComponentCreation.txt index e0dbbae..5d00144 100644 --- a/tests/auto/declarative/qmlparser/autoComponentCreation.txt +++ b/tests/auto/declarative/qmlparser/autoComponentCreation.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { componentProperty : MyTypeObject { realProperty: 9 } } diff --git a/tests/auto/declarative/qmlparser/customParserTypes.txt b/tests/auto/declarative/qmlparser/customParserTypes.txt index 52848fa..cf2f272 100644 --- a/tests/auto/declarative/qmlparser/customParserTypes.txt +++ b/tests/auto/declarative/qmlparser/customParserTypes.txt @@ -1,3 +1,4 @@ +import Qt 4.6 ListModel { ListElement { a: 10 } ListElement { a: 12 } diff --git a/tests/auto/declarative/qmlparser/customVariantTypes.txt b/tests/auto/declarative/qmlparser/customVariantTypes.txt index dc5031e..0263ed2 100644 --- a/tests/auto/declarative/qmlparser/customVariantTypes.txt +++ b/tests/auto/declarative/qmlparser/customVariantTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { customType: "10" } diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt index 99f4c7c..66241cf 100644 --- a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt +++ b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt @@ -1 +1 @@ -3:19:id is not unique +4:19:id is not unique diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.txt b/tests/auto/declarative/qmlparser/duplicateIDs.txt index e76ee21..9605b5b 100644 --- a/tests/auto/declarative/qmlparser/duplicateIDs.txt +++ b/tests/auto/declarative/qmlparser/duplicateIDs.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyQmlObject { id: MyID } MyQmlObject { id: MyID } diff --git a/tests/auto/declarative/qmlparser/dynamicObject.1.txt b/tests/auto/declarative/qmlparser/dynamicObject.1.txt index ac892c3..4be0c8d 100644 --- a/tests/auto/declarative/qmlparser/dynamicObject.1.txt +++ b/tests/auto/declarative/qmlparser/dynamicObject.1.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 SetProperties { propa: a + 10 propb: Math.min(a, 10) diff --git a/tests/auto/declarative/qmlparser/dynamicProperties.txt b/tests/auto/declarative/qmlparser/dynamicProperties.txt index 14c85a7..f93e446 100644 --- a/tests/auto/declarative/qmlparser/dynamicProperties.txt +++ b/tests/auto/declarative/qmlparser/dynamicProperties.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { default property int intProperty : 10 property bool boolProperty: false diff --git a/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt index 7cf65ee..b0ca970 100644 --- a/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt +++ b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt @@ -1,3 +1,4 @@ +import Qt 4.6 Object { signal signal1 function slot1() {} diff --git a/tests/auto/declarative/qmlparser/empty.errors.txt b/tests/auto/declarative/qmlparser/empty.errors.txt index e0ed268..d416e76 100644 --- a/tests/auto/declarative/qmlparser/empty.errors.txt +++ b/tests/auto/declarative/qmlparser/empty.errors.txt @@ -1 +1,2 @@ -0:0:Expected token `identifier' +0:0:Expected token `numeric literal' +0:0:Expected a qualified name id diff --git a/tests/auto/declarative/qmlparser/failingComponent.errors.txt b/tests/auto/declarative/qmlparser/failingComponent.errors.txt index a18f2e7..388fa76 100644 --- a/tests/auto/declarative/qmlparser/failingComponent.errors.txt +++ b/tests/auto/declarative/qmlparser/failingComponent.errors.txt @@ -1,2 +1,2 @@ -1:-1:Unable to create type FailingComponent -2:5:Cannot assign to non-existant property "a" +4:5:Cannot assign to non-existant property "a" diff --git a/tests/auto/declarative/qmlparser/failingComponent.txt b/tests/auto/declarative/qmlparser/failingComponent.txt index 8c43f84..bc21243 100644 --- a/tests/auto/declarative/qmlparser/failingComponent.txt +++ b/tests/auto/declarative/qmlparser/failingComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { FailingComponent {} } diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt index 989d0e6..e56ad3a 100644 --- a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt @@ -1 +1 @@ -2:5:Invalid property access +3:5:Invalid property access diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.txt index 28eb9dc..d971eee 100644 --- a/tests/auto/declarative/qmlparser/fakeDotProperty.txt +++ b/tests/auto/declarative/qmlparser/fakeDotProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value.something: "hello" } diff --git a/tests/auto/declarative/qmlparser/finalOverride.errors.txt b/tests/auto/declarative/qmlparser/finalOverride.errors.txt index fc7070c..49e06cb 100644 --- a/tests/auto/declarative/qmlparser/finalOverride.errors.txt +++ b/tests/auto/declarative/qmlparser/finalOverride.errors.txt @@ -1 +1 @@ -2:5:Cannot override FINAL property +3:5:Cannot override FINAL property diff --git a/tests/auto/declarative/qmlparser/finalOverride.txt b/tests/auto/declarative/qmlparser/finalOverride.txt index 54ea6fb..a84393a 100644 --- a/tests/auto/declarative/qmlparser/finalOverride.txt +++ b/tests/auto/declarative/qmlparser/finalOverride.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { property int value: 10 } diff --git a/tests/auto/declarative/qmlparser/idProperty.txt b/tests/auto/declarative/qmlparser/idProperty.txt index c3c2e50..a413c0b 100644 --- a/tests/auto/declarative/qmlparser/idProperty.txt +++ b/tests/auto/declarative/qmlparser/idProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { property var object : MyObjectId diff --git a/tests/auto/declarative/qmlparser/inlineQmlComponents.txt b/tests/auto/declarative/qmlparser/inlineQmlComponents.txt index e713a88..79ceda6 100644 --- a/tests/auto/declarative/qmlparser/inlineQmlComponents.txt +++ b/tests/auto/declarative/qmlparser/inlineQmlComponents.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 MyContainer { Component { id: MyComponent diff --git a/tests/auto/declarative/qmlparser/interfaceProperty.txt b/tests/auto/declarative/qmlparser/interfaceProperty.txt index cbad7f1..c9a20fb 100644 --- a/tests/auto/declarative/qmlparser/interfaceProperty.txt +++ b/tests/auto/declarative/qmlparser/interfaceProperty.txt @@ -1,3 +1,5 @@ -MyQmlObject { +import Test 1.0 +import Qt 4.6 +Object { interface: MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/interfaceQList.txt b/tests/auto/declarative/qmlparser/interfaceQList.txt index 6c6ab4b..c87dfae 100644 --- a/tests/auto/declarative/qmlparser/interfaceQList.txt +++ b/tests/auto/declarative/qmlparser/interfaceQList.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qlistInterfaces: [ MyQmlObject {}, diff --git a/tests/auto/declarative/qmlparser/interfaceQmlList.txt b/tests/auto/declarative/qmlparser/interfaceQmlList.txt index f41c105..8392bea 100644 --- a/tests/auto/declarative/qmlparser/interfaceQmlList.txt +++ b/tests/auto/declarative/qmlparser/interfaceQmlList.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qmllistInterfaces: [ MyQmlObject {}, diff --git a/tests/auto/declarative/qmlparser/invalidID.2.errors.txt b/tests/auto/declarative/qmlparser/invalidID.2.errors.txt index 9c54aab..56e3eeb 100644 --- a/tests/auto/declarative/qmlparser/invalidID.2.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.2.errors.txt @@ -1,2 +1,2 @@ -2:5:"" is not a valid object id +3:5:"" is not a valid object id diff --git a/tests/auto/declarative/qmlparser/invalidID.2.txt b/tests/auto/declarative/qmlparser/invalidID.2.txt index a7af29e..4fb3b29 100644 --- a/tests/auto/declarative/qmlparser/invalidID.2.txt +++ b/tests/auto/declarative/qmlparser/invalidID.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: "" } diff --git a/tests/auto/declarative/qmlparser/invalidID.3.errors.txt b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt index 36cd489..bb811cf 100644 --- a/tests/auto/declarative/qmlparser/invalidID.3.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt @@ -1 +1 @@ -2:5:Invalid use of id property +3:5:Invalid use of id property diff --git a/tests/auto/declarative/qmlparser/invalidID.3.txt b/tests/auto/declarative/qmlparser/invalidID.3.txt index c686914..6684172 100644 --- a/tests/auto/declarative/qmlparser/invalidID.3.txt +++ b/tests/auto/declarative/qmlparser/invalidID.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id.other: 10 } diff --git a/tests/auto/declarative/qmlparser/invalidID.4.errors.txt b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt index bb811cf..cfe8756 100644 --- a/tests/auto/declarative/qmlparser/invalidID.4.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt @@ -1 +1 @@ -3:5:Invalid use of id property +4:5:Invalid use of id property diff --git a/tests/auto/declarative/qmlparser/invalidID.4.txt b/tests/auto/declarative/qmlparser/invalidID.4.txt index 734ccc4..1f15fce 100644 --- a/tests/auto/declarative/qmlparser/invalidID.4.txt +++ b/tests/auto/declarative/qmlparser/invalidID.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: Hello id: World diff --git a/tests/auto/declarative/qmlparser/invalidID.errors.txt b/tests/auto/declarative/qmlparser/invalidID.errors.txt index 7cefb7e..1ca678c 100644 --- a/tests/auto/declarative/qmlparser/invalidID.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.errors.txt @@ -1 +1 @@ -2:5:"1" is not a valid object id +3:5:"1" is not a valid object id diff --git a/tests/auto/declarative/qmlparser/invalidID.txt b/tests/auto/declarative/qmlparser/invalidID.txt index f91e8c4..04db3eb 100644 --- a/tests/auto/declarative/qmlparser/invalidID.txt +++ b/tests/auto/declarative/qmlparser/invalidID.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: 1 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt index 8bcd71e..d68d487 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt @@ -1 +1 @@ -2:24:Cannot assign primitives to lists +3:24:Cannot assign primitives to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.txt b/tests/auto/declarative/qmlparser/listAssignment.1.txt index e2376f2..4240425 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.1.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qmllistInterfaces: 1 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt index 312ba8a..8b40aa3 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt @@ -1,2 +1,2 @@ -2:15:Cannot assign primitives to lists +3:15:Cannot assign primitives to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.txt b/tests/auto/declarative/qmlparser/listAssignment.2.txt index 375e4b4..e3baadb 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.2.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { children: 2 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt index c52debf..8c7b7e9 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt @@ -1 +1 @@ -3:15:Can only assign one binding to lists +4:15:Can only assign one binding to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.txt b/tests/auto/declarative/qmlparser/listAssignment.3.txt index b776bee..00c4c6b 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.3.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { children: childBinding.expression children: childBinding2.expression diff --git a/tests/auto/declarative/qmlparser/missingObject.errors.txt b/tests/auto/declarative/qmlparser/missingObject.errors.txt index 8438b9e..b31b562 100644 --- a/tests/auto/declarative/qmlparser/missingObject.errors.txt +++ b/tests/auto/declarative/qmlparser/missingObject.errors.txt @@ -1 +1 @@ -1:10:Syntax error +1:10:Expected token `{' diff --git a/tests/auto/declarative/qmlparser/missingSignal.errors.txt b/tests/auto/declarative/qmlparser/missingSignal.errors.txt index bcee331..e243ae5 100644 --- a/tests/auto/declarative/qmlparser/missingSignal.errors.txt +++ b/tests/auto/declarative/qmlparser/missingSignal.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "onClicked" +4:5:Cannot assign to non-existant property "onClicked" diff --git a/tests/auto/declarative/qmlparser/missingSignal.txt b/tests/auto/declarative/qmlparser/missingSignal.txt index 07d1bfa..fd489ca 100644 --- a/tests/auto/declarative/qmlparser/missingSignal.txt +++ b/tests/auto/declarative/qmlparser/missingSignal.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { onClicked: print("Hello world!") } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt index 6f85946..cfc6fc8 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt @@ -1 +1 @@ -1:15:Cannot assign to non-existant property "something" +2:15:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt index 5023b38..df7406c 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt @@ -1 +1,2 @@ +import Test 1.0 MyQmlObject { something: 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt index 3b6cfa6..06ccd37 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt index 61f3625..5b08608 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: 1 + 1 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt index 5ee1d3a..6579191 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: ; } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt index 4234fca4..c07f2b9 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt @@ -1 +1 @@ -2:5:Unexpected token `numeric literal' +3:5:Expected a qualified name id diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt index 1dc6985..37af057 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt index fac833e..c02d7bd 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant default property +3:5:Cannot assign to non-existant default property diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt index 4940833..5cd55d0 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt index 8482634..07a4094 100644 --- a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt @@ -1 +1 @@ -2:-1:Cannot set properties on obj as it is null +3:-1:Cannot set properties on obj as it is null diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.txt b/tests/auto/declarative/qmlparser/nullDotProperty.txt index 5c60c5b..4e36779 100644 --- a/tests/auto/declarative/qmlparser/nullDotProperty.txt +++ b/tests/auto/declarative/qmlparser/nullDotProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyDotPropertyObject { obj.value: 1 } diff --git a/tests/auto/declarative/qmlparser/propertyValueSource.txt b/tests/auto/declarative/qmlparser/propertyValueSource.txt index 780f527..ad71fcf 100644 --- a/tests/auto/declarative/qmlparser/propertyValueSource.txt +++ b/tests/auto/declarative/qmlparser/propertyValueSource.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { intProperty : MyPropertyValueSource {} } diff --git a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt index 8608370..97219af 100644 --- a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt @@ -1 +1 @@ -2:21:Invalid property assignment: read-only property +3:21:Invalid property assignment: read-only property diff --git a/tests/auto/declarative/qmlparser/readOnly.1.txt b/tests/auto/declarative/qmlparser/readOnly.1.txt index c47fdf3..60757bd 100644 --- a/tests/auto/declarative/qmlparser/readOnly.1.txt +++ b/tests/auto/declarative/qmlparser/readOnly.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { readOnlyString: "Hello World" } diff --git a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt index 633d56f..471505c 100644 --- a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt @@ -1 +1 @@ -2:5:Invalid property assignment: read-only property +3:5:Invalid property assignment: read-only property diff --git a/tests/auto/declarative/qmlparser/readOnly.2.txt b/tests/auto/declarative/qmlparser/readOnly.2.txt index 2b6f733..8f1633c 100644 --- a/tests/auto/declarative/qmlparser/readOnly.2.txt +++ b/tests/auto/declarative/qmlparser/readOnly.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { readOnlyString: "Hello" + "World" } diff --git a/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt b/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt index 8cb57ff..8d72cd3 100644 --- a/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt +++ b/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainerComponent { x: 11 MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/simpleBindings.txt b/tests/auto/declarative/qmlparser/simpleBindings.txt index 78f2503..74867b3 100644 --- a/tests/auto/declarative/qmlparser/simpleBindings.txt +++ b/tests/auto/declarative/qmlparser/simpleBindings.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { id: Me property int v1: 10 diff --git a/tests/auto/declarative/qmlparser/simpleContainer.txt b/tests/auto/declarative/qmlparser/simpleContainer.txt index 8b30ed9..c3a795f 100644 --- a/tests/auto/declarative/qmlparser/simpleContainer.txt +++ b/tests/auto/declarative/qmlparser/simpleContainer.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyQmlObject {} MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/simpleObject.txt b/tests/auto/declarative/qmlparser/simpleObject.txt index 05ed87a..30c7823 100644 --- a/tests/auto/declarative/qmlparser/simpleObject.txt +++ b/tests/auto/declarative/qmlparser/simpleObject.txt @@ -1 +1,2 @@ +import Test 1.0 MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/testtypes.cpp b/tests/auto/declarative/qmlparser/testtypes.cpp index 69df5c3..19776a9 100644 --- a/tests/auto/declarative/qmlparser/testtypes.cpp +++ b/tests/auto/declarative/qmlparser/testtypes.cpp @@ -1,9 +1,9 @@ #include "testtypes.h" QML_DEFINE_INTERFACE(MyInterface); -QML_DEFINE_TYPE(MyQmlObject,MyQmlObject); -QML_DEFINE_TYPE(MyTypeObject,MyTypeObject); -QML_DEFINE_TYPE(MyContainer,MyContainer); -QML_DEFINE_TYPE(MyPropertyValueSource,MyPropertyValueSource); -QML_DEFINE_TYPE(MyDotPropertyObject,MyDotPropertyObject); +QML_DEFINE_TYPE(Test,1,0,0,MyQmlObject,MyQmlObject); +QML_DEFINE_TYPE(Test,1,0,0,MyTypeObject,MyTypeObject); +QML_DEFINE_TYPE(Test,1,0,0,MyContainer,MyContainer); +QML_DEFINE_TYPE(Test,1,0,0,MyPropertyValueSource,MyPropertyValueSource); +QML_DEFINE_TYPE(Test,1,0,0,MyDotPropertyObject,MyDotPropertyObject); diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp index eaa8267..92c23d4 100644 --- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp +++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp @@ -46,6 +46,9 @@ private slots: void customVariantTypes(); void valueTypes(); + void imports_data(); + void imports(); + // regression tests for crashes void crash1(); @@ -55,6 +58,8 @@ private: #define VERIFY_ERRORS(errorfile) \ if (!errorfile) { \ + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ + qWarning() << "Unexpected Errors:" << component.errors(); \ QVERIFY(!component.isError()); \ QVERIFY(component.errors().isEmpty()); \ } else { \ @@ -94,12 +99,12 @@ void tst_qmlparser::errors_data() QTest::addColumn<QString>("errorFile"); QTest::addColumn<bool>("create"); - QTest::newRow("nonExistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << false; - QTest::newRow("nonExistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << false; - QTest::newRow("nonExistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << false; - QTest::newRow("nonExistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << false; - QTest::newRow("nonExistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false; - QTest::newRow("nonExistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << false; + QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << false; + QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << false; + QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << false; + QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << false; + QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false; + QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << false; QTest::newRow("wrongType (string for int)") << "wrongType.1.txt" << "wrongType.1.errors.txt" << false; QTest::newRow("wrongType (int for bool)") << "wrongType.2.txt" << "wrongType.2.errors.txt" << false; @@ -168,6 +173,7 @@ void tst_qmlparser::simpleObject() void tst_qmlparser::simpleContainer() { QmlComponent component(&engine, TEST_FILE("simpleContainer.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); QCOMPARE(container->children()->count(),2); @@ -176,6 +182,7 @@ void tst_qmlparser::simpleContainer() void tst_qmlparser::interfaceProperty() { QmlComponent component(&engine, TEST_FILE("interfaceProperty.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QVERIFY(object->interface()); @@ -185,6 +192,7 @@ void tst_qmlparser::interfaceProperty() void tst_qmlparser::interfaceQmlList() { QmlComponent component(&engine, TEST_FILE("interfaceQmlList.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); QVERIFY(container->qmllistAccessor().count() == 2); @@ -195,6 +203,7 @@ void tst_qmlparser::interfaceQmlList() void tst_qmlparser::interfaceQList() { QmlComponent component(&engine, TEST_FILE("interfaceQList.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); QVERIFY(container->qlistInterfaces()->count() == 2); @@ -205,6 +214,7 @@ void tst_qmlparser::interfaceQList() void tst_qmlparser::assignObjectToSignal() { QmlComponent component(&engine, TEST_FILE("assignObjectToSignal.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); @@ -214,6 +224,7 @@ void tst_qmlparser::assignObjectToSignal() void tst_qmlparser::assignObjectToVariant() { QmlComponent component(&engine, TEST_FILE("assignObjectToVariant.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVariant v = object->property("a"); @@ -223,6 +234,7 @@ void tst_qmlparser::assignObjectToVariant() void tst_qmlparser::assignLiteralSignalProperty() { QmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->onLiteralSignal(), 10); @@ -232,6 +244,7 @@ void tst_qmlparser::assignLiteralSignalProperty() void tst_qmlparser::assignQmlComponent() { QmlComponent component(&engine, TEST_FILE("assignQmlComponent.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QVERIFY(object->children()->count() == 1); @@ -244,6 +257,7 @@ void tst_qmlparser::assignQmlComponent() void tst_qmlparser::assignBasicTypes() { QmlComponent component(&engine, TEST_FILE("assignBasicTypes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); @@ -275,6 +289,7 @@ void tst_qmlparser::assignBasicTypes() void tst_qmlparser::assignTypeExtremes() { QmlComponent component(&engine, TEST_FILE("assignTypeExtremes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->uintProperty(), 0xEE6B2800); @@ -285,6 +300,7 @@ void tst_qmlparser::assignTypeExtremes() void tst_qmlparser::customParserTypes() { QmlComponent component(&engine, TEST_FILE("customParserTypes.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->property("count") == QVariant(2)); @@ -294,6 +310,7 @@ void tst_qmlparser::customParserTypes() void tst_qmlparser::rootAsQmlComponent() { QmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); @@ -304,6 +321,7 @@ void tst_qmlparser::rootAsQmlComponent() void tst_qmlparser::inlineQmlComponents() { QmlComponent component(&engine, TEST_FILE("inlineQmlComponents.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->children()->count(), 1); @@ -318,6 +336,7 @@ void tst_qmlparser::inlineQmlComponents() void tst_qmlparser::idProperty() { QmlComponent component(&engine, TEST_FILE("idProperty.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->children()->count(), 1); @@ -332,6 +351,7 @@ void tst_qmlparser::idProperty() void tst_qmlparser::assignSignal() { QmlComponent component(&engine, TEST_FILE("assignSignal.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); @@ -342,6 +362,7 @@ void tst_qmlparser::assignSignal() void tst_qmlparser::dynamicProperties() { QmlComponent component(&engine, TEST_FILE("dynamicProperties.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("intProperty"), QVariant(10)); @@ -359,6 +380,7 @@ void tst_qmlparser::dynamicProperties() void tst_qmlparser::dynamicSignalsAndSlots() { QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1); @@ -370,6 +392,7 @@ void tst_qmlparser::dynamicSignalsAndSlots() void tst_qmlparser::simpleBindings() { QmlComponent component(&engine, TEST_FILE("simpleBindings.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value1"), QVariant(10)); @@ -382,6 +405,7 @@ void tst_qmlparser::simpleBindings() void tst_qmlparser::autoComponentCreation() { QmlComponent component(&engine, TEST_FILE("autoComponentCreation.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QVERIFY(object->componentProperty() != 0); @@ -393,6 +417,7 @@ void tst_qmlparser::autoComponentCreation() void tst_qmlparser::propertyValueSource() { QmlComponent component(&engine, TEST_FILE("propertyValueSource.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QList<QmlPropertyValueSource *> valueSources = @@ -408,6 +433,7 @@ void tst_qmlparser::propertyValueSource() void tst_qmlparser::attachedProperties() { QmlComponent component(&engine, TEST_FILE("attachedProperties.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object); @@ -419,6 +445,7 @@ void tst_qmlparser::attachedProperties() void tst_qmlparser::dynamicObjects() { QmlComponent component(&engine, TEST_FILE("dynamicObject.1.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } @@ -427,6 +454,7 @@ void tst_qmlparser::dynamicObjects() void tst_qmlparser::customVariantTypes() { QmlComponent component(&engine, TEST_FILE("customVariantTypes.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QCOMPARE(object->customType().a, 10); @@ -435,6 +463,7 @@ void tst_qmlparser::customVariantTypes() void tst_qmlparser::valueTypes() { QmlComponent component(&engine, TEST_FILE("valueTypes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); QVERIFY(object != 0); @@ -457,6 +486,64 @@ void tst_qmlparser::valueTypes() QCOMPARE(p2.read(), QVariant(13)); } +class TestType : public QObject { + Q_OBJECT +public: + TestType(QObject *p=0) : QObject(p) {} +}; + +class TestType2 : public QObject { + Q_OBJECT +public: + TestType2(QObject *p=0) : QObject(p) {} +}; + +QML_DECLARE_TYPE(TestType) +QML_DECLARE_TYPE(TestType2) + +QML_DEFINE_TYPE(com.nokia.Test, 1, 0, 3, Test, TestType) +QML_DEFINE_TYPE(com.nokia.Test, 1, 5, 7, Test, TestType) +QML_DEFINE_TYPE(com.nokia.Test, 1, 8, 9, Test, TestType2) +QML_DEFINE_TYPE(com.nokia.Test, 1, 12, 13, Test, TestType2) +QML_DEFINE_TYPE(com.nokia.Test, 1, 9, 11, OldTest, TestType) + +void tst_qmlparser::imports_data() +{ + QTest::addColumn<QString>("qml"); + QTest::addColumn<QString>("type"); + + QTest::newRow("missing import") << "Test {}" << ""; + QTest::newRow("not in version 0.0") << "import com.nokia.Test 0.0\nTest {}" << ""; + QTest::newRow("in version 1.0") << "import com.nokia.Test 1.0\nTest {}" << "TestType"; + QTest::newRow("in version 1.1") << "import com.nokia.Test 1.1\nTest {}" << "TestType"; + QTest::newRow("in version 1.3") << "import com.nokia.Test 1.3\nTest {}" << "TestType"; + QTest::newRow("not in version 1.4") << "import com.nokia.Test 1.4\nTest {}" << ""; + QTest::newRow("in version 1.5") << "import com.nokia.Test 1.5\nTest {}" << "TestType"; + QTest::newRow("changed in version 1.8") << "import com.nokia.Test 1.8\nTest {}" << "TestType2"; + QTest::newRow("not in version 1.10") << "import com.nokia.Test 1.10\nTest {}" << ""; + QTest::newRow("back in version 1.12") << "import com.nokia.Test 1.12\nTest {}" << "TestType2"; + QTest::newRow("old in version 1.9") << "import com.nokia.Test 1.9\nOldTest {}" << "TestType"; + QTest::newRow("old in version 1.11") << "import com.nokia.Test 1.11\nOldTest {}" << "TestType"; + QTest::newRow("no old in version 1.12") << "import com.nokia.Test 1.12\nOldTest {}" << ""; +} + +// Tests the registration of custom variant string converters +void tst_qmlparser::imports() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + + QmlComponent component(&engine, qml.toUtf8(), TEST_FILE("empty.txt")); + + if (type.isEmpty()) { + QVERIFY(component.isError()); + } else { + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(QString(object->metaObject()->className()), type); + } +} + void tst_qmlparser::crash1() { QmlComponent component(&engine, "Component {}"); diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.txt b/tests/auto/declarative/qmlparser/unregisteredObject.txt index ff46457..9498e31 100644 --- a/tests/auto/declarative/qmlparser/unregisteredObject.txt +++ b/tests/auto/declarative/qmlparser/unregisteredObject.txt @@ -1 +1,2 @@ +import Test 1.0 UnregisteredObject {} diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt index 7ccfc75..3a90a7d 100644 --- a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt @@ -1 +1 @@ -2:13:Invalid property assignment: unknown type QVariant::QMatrix +3:13:Invalid property assignment: unknown type QVariant::QMatrix diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.txt index bbbd31d..9f19680 100644 --- a/tests/auto/declarative/qmlparser/unsupportedProperty.txt +++ b/tests/auto/declarative/qmlparser/unsupportedProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { matrix: "1,0,0,0,1,0,0,0,1" } diff --git a/tests/auto/declarative/qmlparser/valueTypes.txt b/tests/auto/declarative/qmlparser/valueTypes.txt index 0d670af..bf325a7 100644 --- a/tests/auto/declarative/qmlparser/valueTypes.txt +++ b/tests/auto/declarative/qmlparser/valueTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { rectProperty.x: 10 rectProperty.y: 11 diff --git a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt index 194da94..ba7a076 100644 --- a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt @@ -1 +1 @@ -2:12:Invalid property assignment: int expected +3:12:Invalid property assignment: int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.1.txt b/tests/auto/declarative/qmlparser/wrongType.1.txt index 281a227..289d37f 100644 --- a/tests/auto/declarative/qmlparser/wrongType.1.txt +++ b/tests/auto/declarative/qmlparser/wrongType.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value: "hello" } diff --git a/tests/auto/declarative/qmlparser/wrongType.10.errors.txt b/tests/auto/declarative/qmlparser/wrongType.10.errors.txt index f391e2a..ae75b52 100644 --- a/tests/auto/declarative/qmlparser/wrongType.10.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.10.errors.txt @@ -1 +1 @@ -2:23:Invalid property assignment: datetime expected +3:23:Invalid property assignment: datetime expected diff --git a/tests/auto/declarative/qmlparser/wrongType.10.txt b/tests/auto/declarative/qmlparser/wrongType.10.txt index 07a90e0..2cf0e50 100644 --- a/tests/auto/declarative/qmlparser/wrongType.10.txt +++ b/tests/auto/declarative/qmlparser/wrongType.10.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { dateTimeProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.11.errors.txt b/tests/auto/declarative/qmlparser/wrongType.11.errors.txt index 9f5ebc9..23a4cda 100644 --- a/tests/auto/declarative/qmlparser/wrongType.11.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.11.errors.txt @@ -1 +1 @@ -2:20:Invalid property assignment: point expected +3:20:Invalid property assignment: point expected diff --git a/tests/auto/declarative/qmlparser/wrongType.11.txt b/tests/auto/declarative/qmlparser/wrongType.11.txt index 90a3797..ae77ba1 100644 --- a/tests/auto/declarative/qmlparser/wrongType.11.txt +++ b/tests/auto/declarative/qmlparser/wrongType.11.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { pointProperty: "apples" } diff --git a/tests/auto/declarative/qmlparser/wrongType.12.errors.txt b/tests/auto/declarative/qmlparser/wrongType.12.errors.txt index 4bbb2bf..3092100 100644 --- a/tests/auto/declarative/qmlparser/wrongType.12.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.12.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: size expected +3:19:Invalid property assignment: size expected diff --git a/tests/auto/declarative/qmlparser/wrongType.12.txt b/tests/auto/declarative/qmlparser/wrongType.12.txt index c3fa4a0..b7a366f 100644 --- a/tests/auto/declarative/qmlparser/wrongType.12.txt +++ b/tests/auto/declarative/qmlparser/wrongType.12.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { sizeProperty: "red" } diff --git a/tests/auto/declarative/qmlparser/wrongType.13.errors.txt b/tests/auto/declarative/qmlparser/wrongType.13.errors.txt index 194da94..ba7a076 100644 --- a/tests/auto/declarative/qmlparser/wrongType.13.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.13.errors.txt @@ -1 +1 @@ -2:12:Invalid property assignment: int expected +3:12:Invalid property assignment: int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.13.txt b/tests/auto/declarative/qmlparser/wrongType.13.txt index 075ec03..477aff1 100644 --- a/tests/auto/declarative/qmlparser/wrongType.13.txt +++ b/tests/auto/declarative/qmlparser/wrongType.13.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value: "12" } diff --git a/tests/auto/declarative/qmlparser/wrongType.14.errors.txt b/tests/auto/declarative/qmlparser/wrongType.14.errors.txt index f90b8c6..d621fdd 100644 --- a/tests/auto/declarative/qmlparser/wrongType.14.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.14.errors.txt @@ -1 +1 @@ -2:21:Invalid property assignment: string expected +3:21:Invalid property assignment: string expected diff --git a/tests/auto/declarative/qmlparser/wrongType.14.txt b/tests/auto/declarative/qmlparser/wrongType.14.txt index 3d39c87..672d693 100644 --- a/tests/auto/declarative/qmlparser/wrongType.14.txt +++ b/tests/auto/declarative/qmlparser/wrongType.14.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { stringProperty: 10 } diff --git a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt index 4353165..9ff9f25 100644 --- a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt @@ -1 +1 @@ -2:14:Invalid property assignment: boolean expected +3:14:Invalid property assignment: boolean expected diff --git a/tests/auto/declarative/qmlparser/wrongType.2.txt b/tests/auto/declarative/qmlparser/wrongType.2.txt index cdedf8c..34b74f7 100644 --- a/tests/auto/declarative/qmlparser/wrongType.2.txt +++ b/tests/auto/declarative/qmlparser/wrongType.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { enabled: 5 } diff --git a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt index 87b4eed..6d971c6 100644 --- a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt @@ -1 +1 @@ -2:11:Invalid property assignment: rect expected +3:11:Invalid property assignment: rect expected diff --git a/tests/auto/declarative/qmlparser/wrongType.3.txt b/tests/auto/declarative/qmlparser/wrongType.3.txt index 839e0c7..384181a 100644 --- a/tests/auto/declarative/qmlparser/wrongType.3.txt +++ b/tests/auto/declarative/qmlparser/wrongType.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { rect: "5,5x10" } diff --git a/tests/auto/declarative/qmlparser/wrongType.4.errors.txt b/tests/auto/declarative/qmlparser/wrongType.4.errors.txt index 57a0744..ef34d0e 100644 --- a/tests/auto/declarative/qmlparser/wrongType.4.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.4.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: unknown enumeration +3:19:Invalid property assignment: unknown enumeration diff --git a/tests/auto/declarative/qmlparser/wrongType.4.txt b/tests/auto/declarative/qmlparser/wrongType.4.txt index 6fa4a9c..0787bf5 100644 --- a/tests/auto/declarative/qmlparser/wrongType.4.txt +++ b/tests/auto/declarative/qmlparser/wrongType.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { enumProperty: "InvalidEnumName" } diff --git a/tests/auto/declarative/qmlparser/wrongType.5.errors.txt b/tests/auto/declarative/qmlparser/wrongType.5.errors.txt index 0023d1d..cab10bd 100644 --- a/tests/auto/declarative/qmlparser/wrongType.5.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.5.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: unsigned int expected +3:19:Invalid property assignment: unsigned int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.5.txt b/tests/auto/declarative/qmlparser/wrongType.5.txt index 95b0904..c50ae9a 100644 --- a/tests/auto/declarative/qmlparser/wrongType.5.txt +++ b/tests/auto/declarative/qmlparser/wrongType.5.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { uintProperty: -13 } diff --git a/tests/auto/declarative/qmlparser/wrongType.6.errors.txt b/tests/auto/declarative/qmlparser/wrongType.6.errors.txt index 06349e7..d0a0b00 100644 --- a/tests/auto/declarative/qmlparser/wrongType.6.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.6.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: double expected +3:19:Invalid property assignment: double expected diff --git a/tests/auto/declarative/qmlparser/wrongType.6.txt b/tests/auto/declarative/qmlparser/wrongType.6.txt index 78351f4..da10b78 100644 --- a/tests/auto/declarative/qmlparser/wrongType.6.txt +++ b/tests/auto/declarative/qmlparser/wrongType.6.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { realProperty: "Hello" } diff --git a/tests/auto/declarative/qmlparser/wrongType.7.errors.txt b/tests/auto/declarative/qmlparser/wrongType.7.errors.txt index e053f3b..614346b 100644 --- a/tests/auto/declarative/qmlparser/wrongType.7.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.7.errors.txt @@ -1 +1 @@ -2:20:Invalid property assignment: color expected +3:20:Invalid property assignment: color expected diff --git a/tests/auto/declarative/qmlparser/wrongType.7.txt b/tests/auto/declarative/qmlparser/wrongType.7.txt index 8279ffa..ddc3835 100644 --- a/tests/auto/declarative/qmlparser/wrongType.7.txt +++ b/tests/auto/declarative/qmlparser/wrongType.7.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { colorProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.8.errors.txt b/tests/auto/declarative/qmlparser/wrongType.8.errors.txt index b11f92b..1773c00 100644 --- a/tests/auto/declarative/qmlparser/wrongType.8.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.8.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: date expected +3:19:Invalid property assignment: date expected diff --git a/tests/auto/declarative/qmlparser/wrongType.8.txt b/tests/auto/declarative/qmlparser/wrongType.8.txt index e1cfe9a..a5f6756 100644 --- a/tests/auto/declarative/qmlparser/wrongType.8.txt +++ b/tests/auto/declarative/qmlparser/wrongType.8.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { dateProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.9.errors.txt b/tests/auto/declarative/qmlparser/wrongType.9.errors.txt index 419a5ce..8630975 100644 --- a/tests/auto/declarative/qmlparser/wrongType.9.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.9.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: time expected +3:19:Invalid property assignment: time expected diff --git a/tests/auto/declarative/qmlparser/wrongType.9.txt b/tests/auto/declarative/qmlparser/wrongType.9.txt index 84dfa66..a3db732 100644 --- a/tests/auto/declarative/qmlparser/wrongType.9.txt +++ b/tests/auto/declarative/qmlparser/wrongType.9.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { timeProperty: 12 } diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt index 05ed87a..9c3f7f8 100644 --- a/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt +++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject.txt @@ -1 +1,3 @@ +import Qt.test 4.6 + MyQmlObject {} diff --git a/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt index 4dfa7c3..e6cc4cf 100644 --- a/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt +++ b/tests/benchmarks/declarative/qmlcomponent/myqmlobject_binding.txt @@ -1,3 +1,5 @@ +import Qt.test 4.6 + MyQmlObject { result: value } diff --git a/tests/benchmarks/declarative/qmlcomponent/object.txt b/tests/benchmarks/declarative/qmlcomponent/object.txt index 7dc75192..85e74b9 100644 --- a/tests/benchmarks/declarative/qmlcomponent/object.txt +++ b/tests/benchmarks/declarative/qmlcomponent/object.txt @@ -1 +1,3 @@ +import Qt 4.6 + Object {} diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qmlcomponent/samegame/BoomBlock.qml new file mode 100644 index 0000000..8a505da --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/BoomBlock.qml @@ -0,0 +1,54 @@ +import Qt 4.6 + +Item { id:block + property bool dying: false + property bool spawned: false + property int type: 0 + property int targetX: 0 + property int targetY: 0 + + x: Follow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } + y: Follow { source: targetY; spring: 2; damping: 0.2 } + + Image { id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } + anchors.fill: parent + } + + Particles { id: particles + width:1; height:1; anchors.centerIn: parent; opacity: 0 + lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false + angle: 0; angleDeviation: 360; velocity: 100; velocityDeviation:30 + source: { + if(type == 0){ + "pics/redStar.png"; + } else if (type == 1) { + "pics/blueStar.png"; + } else { + "pics/greenStar.png"; + } + } + } + + states: [ + State{ name: "AliveState"; when: spawned == true && dying == false + SetProperties { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + SetProperties { target: particles; count: 50 } + SetProperties { target: particles; opacity: 1 } + SetProperties { target: particles; emitting: false } // i.e. emit only once + SetProperties { target: img; opacity: 0 } + } + ] +} diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStar.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStar.png Binary files differnew file mode 100644 index 0000000..ff9588f --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStar.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStone.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStone.png Binary files differnew file mode 100644 index 0000000..bf342e0 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/blueStone.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStar.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStar.png Binary files differnew file mode 100644 index 0000000..cd06854 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStar.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStone.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStone.png Binary files differnew file mode 100644 index 0000000..5ac14a5 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/greenStone.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStar.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStar.png Binary files differnew file mode 100644 index 0000000..0a4dffe --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStar.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStone.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStone.png Binary files differnew file mode 100644 index 0000000..b099f60 --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/redStone.png diff --git a/tests/benchmarks/declarative/qmlcomponent/samegame/pics/yellowStone.png b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/yellowStone.png Binary files differnew file mode 100644 index 0000000..c56124a --- /dev/null +++ b/tests/benchmarks/declarative/qmlcomponent/samegame/pics/yellowStone.png diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt index d59104d..90db37c 100644 --- a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt +++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.2.txt @@ -1,3 +1,5 @@ +import Qt 4.6 + Object { property int a property bool b diff --git a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt index d9eb708..bb5469a 100644 --- a/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt +++ b/tests/benchmarks/declarative/qmlcomponent/synthesized_properties.txt @@ -1,3 +1,5 @@ +import Qt 4.6 + Object { property int a } diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp index 60e69e2..5021bf3 100644 --- a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp +++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp @@ -1,3 +1,3 @@ #include "testtypes.h" -QML_DEFINE_TYPE(MyQmlObject, MyQmlObject); +QML_DEFINE_TYPE(Qt/test, 4, 6, 6, MyQmlObject, MyQmlObject); diff --git a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp index 1920bf2..f032004 100644 --- a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp +++ b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp @@ -60,6 +60,7 @@ void tst_qmlcomponent::creation_data() QTest::newRow("MyQmlObject: basic binding") << "myqmlobject_binding.txt"; QTest::newRow("Synthesized properties") << "synthesized_properties.txt"; QTest::newRow("Synthesized properties.2") << "synthesized_properties.2.txt"; + QTest::newRow("SameGame - BoomBlock") << "samegame/BoomBlock.qml"; } void tst_qmlcomponent::creation() diff --git a/tests/benchmarks/declarative/qmlmetaproperty/object.txt b/tests/benchmarks/declarative/qmlmetaproperty/object.txt new file mode 100644 index 0000000..11b95e1 --- /dev/null +++ b/tests/benchmarks/declarative/qmlmetaproperty/object.txt @@ -0,0 +1,3 @@ +import Qt 4.6 + +Item {} diff --git a/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro new file mode 100644 index 0000000..b4e83d7 --- /dev/null +++ b/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qmlmetaproperty +QT += declarative + +SOURCES += tst_qmlmetaproperty.cpp + diff --git a/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt b/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt new file mode 100644 index 0000000..a923a0a --- /dev/null +++ b/tests/benchmarks/declarative/qmlmetaproperty/synthesized_object.txt @@ -0,0 +1,6 @@ +import Qt 4.6 + +Item { + property int blah +} + diff --git a/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp new file mode 100644 index 0000000..c22af03 --- /dev/null +++ b/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +****************************************************************************/ + +#include <qtest.h> +#include <QmlEngine> +#include <QmlComponent> +#include <QmlMetaProperty> +#include <QFile> +#include <QDebug> + +//TESTED_FILES= + + +class tst_qmlmetaproperty : public QObject +{ + Q_OBJECT + +public: + tst_qmlmetaproperty(); + virtual ~tst_qmlmetaproperty(); + +public slots: + void init(); + void cleanup(); + +private slots: + void lookup_data(); + void lookup(); + +private: + QmlEngine engine; +}; + +tst_qmlmetaproperty::tst_qmlmetaproperty() +{ +} + +tst_qmlmetaproperty::~tst_qmlmetaproperty() +{ +} + +void tst_qmlmetaproperty::init() +{ +} + +void tst_qmlmetaproperty::cleanup() +{ +} + +void tst_qmlmetaproperty::lookup_data() +{ + QTest::addColumn<QString>("file"); + + QTest::newRow("Simple Object") << "object.txt"; + QTest::newRow("Synthesized Object") << "synthesized_object.txt"; +} + +void tst_qmlmetaproperty::lookup() +{ + QFETCH(QString, file); + + QmlComponent c(&engine, file); + QVERIFY(c.isReady()); + + QObject *obj = c.create(); + + QBENCHMARK { + QmlMetaProperty p(obj, "x"); + } + + delete obj; +} + +QTEST_MAIN(tst_qmlmetaproperty) +#include "tst_qmlmetaproperty.moc" |