summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2009-05-05 08:39:27 (GMT)
committerMartin Smith <msmith@trolltech.com>2009-05-05 08:39:27 (GMT)
commita189a500173ed038e777902ac0a77f837a330c26 (patch)
tree14f6cdb392bebeb97273501e26b9ebd08c89fa75 /src
parentca4d0be72c35cd693cab61b35831f8392a44e09c (diff)
parent983b5260f5a2a0ef1788107618b523a37afe6268 (diff)
downloadQt-a189a500173ed038e777902ac0a77f837a330c26.zip
Qt-a189a500173ed038e777902ac0a77f837a330c26.tar.gz
Qt-a189a500173ed038e777902ac0a77f837a330c26.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r--src/declarative/extra/qmlsqlconnection.cpp31
-rw-r--r--src/declarative/extra/qmlsqlquery.cpp36
-rw-r--r--src/declarative/fx/fx.pri9
-rw-r--r--src/declarative/fx/qfxflipable.cpp4
-rw-r--r--src/declarative/fx/qfximage.cpp4
-rw-r--r--src/declarative/fx/qfxitem.cpp260
-rw-r--r--src/declarative/fx/qfxpainted.cpp194
-rw-r--r--src/declarative/fx/qfxpainted.h87
-rw-r--r--src/declarative/fx/qfxpainted_p.h84
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp (renamed from src/declarative/fx/qfximageitem.cpp)68
-rw-r--r--src/declarative/fx/qfxpainteditem.h (renamed from src/declarative/fx/qfximageitem.h)19
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h (renamed from src/declarative/fx/qfximageitem_p.h)6
-rw-r--r--src/declarative/fx/qfxparticles.cpp22
-rw-r--r--src/declarative/fx/qfxreflectionfilter.cpp12
-rw-r--r--src/declarative/fx/qfxshadowfilter.cpp2
-rw-r--r--src/declarative/fx/qfxtextedit.cpp20
-rw-r--r--src/declarative/fx/qfxtextedit.h4
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/fx/qfxtransform.cpp12
-rw-r--r--src/declarative/fx/qfxwebview.cpp143
-rw-r--r--src/declarative/fx/qfxwebview.h16
-rw-r--r--src/declarative/qml/parser/javascript.g6
-rw-r--r--src/declarative/qml/parser/javascriptast_p.h8
-rw-r--r--src/declarative/qml/parser/javascriptparser.cpp6
-rw-r--r--src/declarative/qml/qml.pri8
-rw-r--r--src/declarative/qml/qmlcompiler.cpp314
-rw-r--r--src/declarative/qml/qmlcompiler_p.h12
-rw-r--r--src/declarative/qml/qmlcomponent.cpp47
-rw-r--r--src/declarative/qml/qmlcomponent.h5
-rw-r--r--src/declarative/qml/qmlcomponent_p.h4
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp23
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h4
-rw-r--r--src/declarative/qml/qmlcustomparser_p.h17
-rw-r--r--src/declarative/qml/qmldom.cpp27
-rw-r--r--src/declarative/qml/qmldom.h2
-rw-r--r--src/declarative/qml/qmldom_p.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp2
-rw-r--r--src/declarative/qml/qmlerror.cpp227
-rw-r--r--src/declarative/qml/qmlerror.h (renamed from src/declarative/qml/qmlxmlparser_p.h)55
-rw-r--r--src/declarative/qml/qmlinstruction.cpp5
-rw-r--r--src/declarative/qml/qmlinstruction_p.h6
-rw-r--r--src/declarative/qml/qmlparser.cpp20
-rw-r--r--src/declarative/qml/qmlparser_p.h20
-rw-r--r--src/declarative/qml/qmlparserstatus.cpp7
-rw-r--r--src/declarative/qml/qmlparserstatus.h2
-rw-r--r--src/declarative/qml/qmlpropertyvaluesource.cpp3
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp174
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h11
-rw-r--r--src/declarative/qml/qmlvme.cpp47
-rw-r--r--src/declarative/qml/qmlvme_p.h5
-rw-r--r--src/declarative/qml/qmlvmemetaobject.cpp132
-rw-r--r--src/declarative/qml/qmlvmemetaobject_p.h6
-rw-r--r--src/declarative/qml/qmlxmlparser.cpp391
-rw-r--r--src/declarative/util/qfxview.cpp79
-rw-r--r--src/declarative/util/qfxview.h3
-rw-r--r--src/declarative/util/qmllistmodel.cpp180
-rw-r--r--src/script/qscriptextqobject.cpp2
57 files changed, 1016 insertions, 1883 deletions
diff --git a/src/declarative/extra/qmlsqlconnection.cpp b/src/declarative/extra/qmlsqlconnection.cpp
index a39aa6f..25ab033 100644
--- a/src/declarative/extra/qmlsqlconnection.cpp
+++ b/src/declarative/extra/qmlsqlconnection.cpp
@@ -79,13 +79,14 @@ public:
Qml the query should connect using its name.
\qml
- <SqlConnection id="myConnection">
- <name>qmlConnection</name>
- <driver>QSQLITE</driver>
- <databaseName>"mydb.sqlite"</databaseName>
- </SqlConnection>
- <SqlQuery id="listmodel" connection="{myConnection}">SELECT * FROM mytable</SqlQuery>
- <SqlQuery id="othermodel" connection="qmlConnection">SELECT * FROM myothertable</SqlQuery>
+ SqlConnection {
+ id: myConnection
+ name: "qmlConnection"
+ driver: "QSQLITE"
+ databaseName: "mydb.sqlite"
+ }
+ SqlQuery { id: listmodel; connection: myConnection; query: "SELECT * FROM mytable" }
+ SqlQuery { id: othermodel; connection: "qmlConnection"; query: "SELECT * FROM myothertable" }
\endqml
*/
@@ -99,34 +100,34 @@ public:
*/
/*!
- \qmlproperty QStringList SqlConnection::tables
+ \qmlproperty list<string> SqlConnection::tables
Defines the set of tables that exist in the database for the connection.
*/
/*!
- \qmlproperty QString SqlConnection::databaseName
+ \qmlproperty string SqlConnection::databaseName
Defines the connection's database name. This is used when opening the
connection to the database.
*/
/*!
- \qmlproperty QString SqlConnection::driver
+ \qmlproperty string SqlConnection::driver
Defines the driver type of the connection. This is used when opening the
connection to the database.
*/
/*!
- \qmlproperty QString SqlConnection::connectOptions
+ \qmlproperty string SqlConnection::connectOptions
Defines the options used when connecting to the database. These are used
when opening the connection to the database.
*/
/*!
- \qmlproperty QString SqlConnection::hostName
+ \qmlproperty string SqlConnection::hostName
Defines the connection's host name. This is used when opening the
connection to the database.
@@ -140,21 +141,21 @@ public:
*/
/*!
- \qmlproperty QString SqlConnection::userName
+ \qmlproperty string SqlConnection::userName
Defines the connection's user name. This is used when opening the
connection to the database.
*/
/*!
- \qmlproperty QString SqlConnection::password
+ \qmlproperty string SqlConnection::password
Defines the connection's password. This is used when opening the
connection to the database.
*/
/*!
- \qmlproperty QString SqlConnection::lastError
+ \qmlproperty string SqlConnection::lastError
Defines the last error, if one occurred, when working with the database.
If the error occurred in conjunction with an SQL query the error will be
diff --git a/src/declarative/extra/qmlsqlquery.cpp b/src/declarative/extra/qmlsqlquery.cpp
index 70b3bdd..5bd1459 100644
--- a/src/declarative/extra/qmlsqlquery.cpp
+++ b/src/declarative/extra/qmlsqlquery.cpp
@@ -77,18 +77,19 @@ public:
values will only apply when the SqlQuery exec() slot is called.
\qml
- <SqlQuery>
- SELECT * FROM mytable WHERE name LIKE :value
- <bindings>
- <SqlBind name=":value" value="{searchText + '%'}"/>
- </bindings>
- </SqlQuery>
- <SqlQuery>
- SELECT * FROM mytable WHERE type = ?
- <bindings>
- <SqlBind value="simple"/>
- </bindings>
- <SqlQuery>
+ SqlQuery {
+ query: "SELECT * FROM mytable WHERE name LIKE :value"
+ bindings: SqlBind {
+ name: ":value"
+ value: searchText + '%'
+ }
+ }
+ SqlQuery {
+ query: "SELECT * FROM mytable WHERE type = ?"
+ bindings: SqlBind {
+ value: "simple"
+ }
+ }
\endqml
*/
@@ -254,11 +255,12 @@ public:
appropriate table column name for the result column.
\qml
- <SqlQuery connection="{qmlConnectionId}" query="DELETE FROM mytable"/>
- <SqlQuery connection="connectionName">
- SELECT * FROM mytable
- </SqlQuery>
- <SqlQuery>SELECT id AS recordId, (firstName || ' ' || lastName) AS fullName FROM mytable</SqlQuery>
+ SqlQuery { connection: qmlConnectionId; query: "DELETE FROM mytable" }
+ SqlQuery {
+ connection: "connectionName"
+ query: "SELECT * FROM mytable"
+ }
+ SqlQuery { query: "SELECT id AS recordId, (firstName || ' ' || lastName) AS fullName FROM mytable" }
\endqml
*/
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index ef059c7..90820fa 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -17,8 +17,8 @@ HEADERS += \
fx/qfxgridview.h \
fx/qfxhighlightfilter.h \
fx/qfximage.h \
- fx/qfximageitem.h \
- fx/qfximageitem_p.h \
+ fx/qfxpainteditem.h \
+ fx/qfxpainteditem_p.h \
fx/qfximage_p.h \
fx/qfxitem.h \
fx/qfxitem_p.h \
@@ -28,8 +28,6 @@ HEADERS += \
fx/qfxlayouts_p.h \
fx/qfxmouseregion.h \
fx/qfxmouseregion_p.h \
- fx/qfxpainted.h \
- fx/qfxpainted_p.h \
fx/qfxparticles.h \
fx/qfxpath.h \
fx/qfxpath_p.h \
@@ -67,13 +65,12 @@ SOURCES += \
fx/qfxgridview.cpp \
fx/qfxhighlightfilter.cpp \
fx/qfximage.cpp \
- fx/qfximageitem.cpp \
+ fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
fx/qfxkeyactions.cpp \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
fx/qfxmouseregion.cpp \
- fx/qfxpainted.cpp \
fx/qfxparticles.cpp \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index db390d2..24ae428 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -80,8 +80,8 @@ Flipable {
endX: 20
endY: 40
}
- front: Image { src: "front.png" }
- back: Image { src: "back.png" }
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
states: [
State {
name: "back"
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 53c6137..838da30 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -203,8 +203,8 @@ QFxScaleGrid *QFxImage::scaleGrid()
\qml
Item {
Image { source: "tile.png" }
- Image { x: 80; width: 100; height: 100; src: "tile.png" }
- Image { x: 190; width: 100; height: 100; tile: true; src: "tile.png" }
+ Image { x: 80; width: 100; height: 100; source: "tile.png" }
+ Image { x: 190; width: 100; height: 100; tile: true; source: "tile.png" }
}
\endqml
\image declarative-image_tile.png
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 380dd53..b737615 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -448,7 +448,7 @@ QFxItem::~QFxItem()
This example scales an image about its center.
\qml
Image {
- src: "myimage.png"
+ source: "myimage.png"
transformOrigin: "Center"
scale: 4
}
@@ -555,17 +555,18 @@ QFxItem *QFxItem::itemParent() const
you, but it can come in handy in some cases.
\qml
- <Item>
- <children>
- <Text />
- <Rect />
- </children>
- <resources>
- <Component id="myComponent">
- <Text />
- </Component>
- </resources>
- </Item>
+ Item {
+ children: [
+ Text {},
+ Rect {}
+ ]
+ resources: [
+ Component {
+ id: myComponent
+ Text {}
+ }
+ ]
+ }
\endqml
*/
@@ -732,24 +733,24 @@ void QFxItemPrivate::children_clear()
So you can write:
\qml
- <Item>
- <Text />
- <Rect />
- <Script />
- </Item>
+ Item {
+ Text {}
+ Rect {}
+ Script {}
+ }
\endqml
instead of:
\qml
- <Item>
- <children>
- <Text />
- <Rect />
- </children>
- <resources>
- <Script/>
- </resources>
- </Item>
+ Item {
+ children: [
+ Text {},
+ Rect {}
+ ]
+ resources: [
+ Script {}
+ ]
+ }
\endqml
data is a behind-the-scenes property: you should never need to explicitly
@@ -937,7 +938,7 @@ void QFxItem::qmlLoaded()
Defines the item's position and size relative to its parent.
\qml
- <Item x="100" y="100" width="100" height="100" />
+ Item { x: 100; y: 100; width: 100; height: 100 }
\endqml
*/
@@ -991,39 +992,63 @@ void QFxItem::qmlLoaded()
\o \image declarative-item_stacking1.png
\o Same \c z - later children above earlier children:
\qml
- <Item>
- <Rect color="red" width="100" height="100" />
- <Rect color="blue" x="50" y="50" width="100" height="100" />
- </Item>
+ Item {
+ Rect {
+ color: "red"
+ width: 100; height: 100
+ }
+ Rect {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
\endqml
\row
\o \image declarative-item_stacking2.png
\o Higher \c z on top:
\qml
- <Item>
- <Rect z="1" color="red" width="100" height="100" />
- <Rect color="blue" x="50" y="50" width="100" height="100" />
- </Item>
+ Item {
+ Rect {
+ z: 1
+ color: "red"
+ width: 100; height: 100
+ }
+ Rect {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
\endqml
\row
\o \image declarative-item_stacking3.png
\o Same \c z - children above parents:
\qml
- <Item>
- <Rect color="red" width="100" height="100">
- <Rect color="blue" x="50" y="50" width="100" height="100" />
- </Rect>
- </Item>
+ Item {
+ Rect {
+ color: "red"
+ width: 100; height: 100
+ Rect {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
\endqml
\row
\o \image declarative-item_stacking4.png
\o Lower \c z below:
\qml
- <Item>
- <Rect color="red" width="100" height="100">
- <Rect z="-1" color="blue" x="50" y="50" width="100" height="100" />
- </Rect>
- </Item>
+ Item {
+ Rect {
+ color: "red"
+ width: 100; height: 100
+ Rect {
+ z: -1
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
\endqml
\endtable
*/
@@ -1212,8 +1237,8 @@ QRectF QFxItem::sceneBoundingRect() const
refer to the item. For example:
\qml
- <Text id="myText" .../>
- <Text text="{myText.text}"/>
+ Text { id: myText; ... }
+ Text { text: myText.text }
\endqml
The identifier is available throughout to the \l {components}{component}
@@ -1228,8 +1253,8 @@ QRectF QFxItem::sceneBoundingRect() const
refer to the item. For example:
\qml
- <Text id="myText" .../>
- <Text text="{myText.text}"/>
+ Text { id: myText; ... }
+ Text { text: myText.text }
\endqml
The identifier is available throughout the \l {components}{component}
@@ -1392,10 +1417,14 @@ QFxAnchorLine QFxItem::verticalCenter() const
\o \image declarative-anchors_example.png
\o Text anchored to Image, horizontally centered and vertically below, with a margin.
\qml
- <Image id="pic" .../>
- <Text id="label" anchors.horizontalCenter="{pic.horizontalCenter}"
- anchors.top="{pic.bottom}"
- anchors.topMargin="5" .../>
+ Image { id: pic; ... }
+ Text {
+ id: label
+ anchors.horizontalCenter: pic.horizontalCenter
+ anchors.top: pic.bottom
+ anchors.topMargin: 5
+ ...
+ }
\endqml
\row
\o \image declarative-anchors_example2.png
@@ -1404,9 +1433,13 @@ QFxAnchorLine QFxItem::verticalCenter() const
property of both defaults to 0.
\qml
- <Image id="pic" .../>
- <Text id="label" anchors.left="{pic.right}"
- anchors.leftMargin="5" .../>
+ Image { id: pic; ... }
+ Text {
+ id: label
+ anchors.left: pic.right
+ anchors.leftMargin: 5
+ ...
+ }
\endqml
\endtable
@@ -1465,10 +1498,19 @@ void QFxItem::setBaselineOffset(int offset)
\o \image declarative-rotation.png
\o
\qml
- <Rect color="blue" width="100" height="100">
- <Rect color="green" width="25" height="25"/>
- <Rect color="red" width="50" height="50" x="25" y="25" rotation="30"/>
- </Rect>
+ Rect {
+ color: "blue"
+ width: 100; height: 100
+ Rect {
+ color: "green"
+ width: 25; height: 25
+ }
+ Rect {
+ color: "red"
+ x: 25; y: 25; width: 50; height: 50
+ rotation: 30
+ }
+ }
\endqml
\endtable
*/
@@ -1534,10 +1576,19 @@ void QFxItem::setRotation(qreal rotation)
\o \image declarative-scale.png
\o
\qml
- <Rect color="blue" width="100" height="100">
- <Rect color="green" width="25" height="25"/>
- <Rect color="red" width="50" height="50" x="25" y="25" scale="1.4"/>
- </Rect>
+ Rect {
+ color: "blue"
+ width: 100; height: 100
+ Rect {
+ color: "green"
+ width: 25; height: 25
+ }
+ Rect {
+ color: "red"
+ x: 25; y: 25; width: 50; height: 50
+ scale: 1.4
+ }
+ }
\endqml
\endtable
*/
@@ -1585,21 +1636,32 @@ void QFxItem::setScale(qreal s)
\o \image declarative-item_opacity1.png
\o
\qml
- <Item>
- <Rect color="red" width="100" height="100">
- <Rect color="blue" x="50" y="50" width="100" height="100" />
- </Rect>
- </Item>
+ Item {
+ Rect {
+ color: "red"
+ width: 100; height: 100
+ Rect {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
\endqml
\row
\o \image declarative-item_opacity2.png
\o
\qml
- <Item>
- <Rect opacity="0.5" color="red" width="100" height="100">
- <Rect color="blue" x="50" y="50" width="100" height="100" />
- </Rect>
- </Item>
+ Item {
+ Rect {
+ opacity: 0.5
+ color: "red"
+ width: 100; height: 100
+ Rect {
+ color: "blue"
+ x: 50; y: 50; width: 100; height: 100
+ }
+ }
+ }
\endqml
\endtable
*/
@@ -1686,13 +1748,13 @@ QmlList<QObject *> *QFxItem::resources()
This property holds a list of states defined by the item.
\qml
- <Item>
- <states>
- <State .../>
- <State .../>
- ...
- </states>
- </Item>
+ Item {
+ states: [
+ State { ... },
+ State { ... }
+ ...
+ ]
+ }
\endqml
\sa {states-transitions}{States and Transitions}
@@ -1715,13 +1777,13 @@ QmlList<QmlState *>* QFxItem::states()
This property holds a list of transitions defined by the item.
\qml
- <Item>
- <transitions>
- <Transition .../>
- <Transition .../>
- ...
- </transitions>
- </Item>
+ Item {
+ transitions: [
+ Transition { ... },
+ Transition { ... }
+ ...
+ ]
+ }
\endqml
\sa {states-transitions}{States and Transitions}
@@ -1755,13 +1817,13 @@ QmlList<QmlTransition *>* QFxItem::transitions()
that canvas (but the QML will still be considered valid).
\qml
- <Item>
- <filter>
- <Blur .../>
- <Relection .../>
- ...
- </filter>
- </Item>
+ Item {
+ filter: [
+ Blur { ... },
+ Relection { ... }
+ ...
+ ]
+ }
\endqml
*/
@@ -1806,14 +1868,14 @@ QmlState *QFxItem::findState(const QString &name) const
example:
\qml
- <Script>
+ Script {
function toggle() {
if (button.state == 'On')
button.state = 'Off';
else
button.state = 'On';
}
- </Script>
+ }
\endqml
If the item is in its base state (i.e. no explicit state has been
@@ -1832,14 +1894,14 @@ QmlState *QFxItem::findState(const QString &name) const
example:
\qml
- <Script>
+ Script {
function toggle() {
if (button.state == 'On')
button.state = 'Off';
else
button.state = 'On';
}
- </Script>
+ }
\endqml
If the item is in its base state (i.e. no explicit state has been
diff --git a/src/declarative/fx/qfxpainted.cpp b/src/declarative/fx/qfxpainted.cpp
deleted file mode 100644
index 68918c3..0000000
--- a/src/declarative/fx/qfxpainted.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxpainted.h"
-#include "qfxpainted_p.h"
-
-
-QT_BEGIN_NAMESPACE
-/*!
- \internal
- \class QFxPainted
- \brief The QFxPainted class is an abstract base class for QFxView items that want cached painting.
-
- \ingroup group_coreitems
-
- This is a convenience class allowing easy use of cached painting within a custom item.
- The contents of the item are cached behind the scenes. Any time you change the contents
- you should call markDirty to make sure the cache is refreshed the next time painting occurs.
-
- \code
- class GradientRect : public QFxPainted
- {
- Q_OBJECT
- public:
- GradientRect() : QFxPainted()
- {
- connect(this, SIGNAL(widthChanged()), this, SLOT(markDirty()));
- connect(this, SIGNAL(heightChanged()), this, SLOT(markDirty()));
- }
-
- void paint(QPainter *painter)
- {
- painter->fillRect(0, 0, width(), height(), QBrush(QLinearGradient(0,0,width(),height())));
- }
- };
- \endcode
-
- \warning Dirty is only ever automatically set by QFxPainted at construction. Any other changes (including resizes) to the item need to be handled by the subclass (as in the example above).
- \warning Frequent calls to markDirty will result in sub-optimal painting performance.
-*/
-
-/*!
- Constructs a painted item with parent object \a parent.
-*/
-QFxPainted::QFxPainted(QFxItem *parent)
- : QFxItem(*(new QFxPaintedPrivate), parent)
-{
- //### what options do we need to set?
- setOptions(HasContents, true);
-}
-
-/*!
- Destroys the item.
-*/
-QFxPainted::~QFxPainted()
-{
-}
-
-/*! \internal
-*/
-QFxPainted::QFxPainted(QFxPaintedPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
- setOptions(HasContents, true);
-}
-
-/*!
- \fn QFxPainted::paint(QPainter *painter)
-
- Implement this method to paint the item using \a painter.
- The painting will be cached and paint() will only be called again
- if \l markDirty() has been called.
-
- \sa markDirty()
-*/
-
-/*!
- The contents of the item are cached behind the scenes. Any time you change the contents
- you should call markDirty to make sure the cache is refreshed the next time painting occurs.
-*/
-void QFxPainted::markDirty()
-{
- Q_D(QFxPainted);
- if (d->dirty)
- return;
- d->dirty = true;
-
- // release cache memory (will be reallocated upon paintContents, if visible)
-#if defined(QFX_RENDER_QPAINTER)
- d->cachedImage = QImage();
-#elif defined(QFX_RENDER_OPENGL)
- d->cachedTexture.clear();
-#endif
-
- update();
-}
-
-#if defined(QFX_RENDER_QPAINTER)
-void QFxPainted::paintContents(QPainter &p)
-{
- Q_D(QFxPainted);
- if (d->dirty) {
- d->cachedImage = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
- d->cachedImage.fill(0);
- QPainter painter(&(d->cachedImage));
- paint(&painter);
- d->dirty = false;
- }
- p.drawImage(0, 0, d->cachedImage);
-}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxPainted::paintGLContents(GLPainter &painter)
-{
- Q_D(QFxPainted);
- if (d->dirty) {
- QImage img = QImage(width(), height(), QImage::Format_ARGB32);
- img.fill(0);
- QPainter p(&(img));
- paint(&p);
- d->cachedTexture.setImage(img);
- d->dirty = false;
- }
-
- //### mainly copied from QFxImage code
- QGLShaderProgram *shader = painter.useTextureShader();
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *tex = &d->cachedTexture;
-
- float widthV = d->cachedTexture.width();
- float heightV = d->cachedTexture.height();
-
- vertices[0] = 0; vertices[1] = heightV;
- vertices[2] = widthV; vertices[3] = heightV;
- vertices[4] = 0; vertices[5] = 0;
- vertices[6] = widthV; vertices[7] = 0;
-
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = 1; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = 1;
- texVertices[6] = 1; texVertices[7] = 1;
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, tex->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainted.h b/src/declarative/fx/qfxpainted.h
deleted file mode 100644
index 1f22414..0000000
--- a/src/declarative/fx/qfxpainted.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXPAINTED_H
-#define QFXPAINTED_H
-
-#include <qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-/*
-WARNING: INTENDED TO MERGE WITH QFxImageItem
-*/
-
-class QFxPaintedPrivate;
-class Q_DECLARATIVE_EXPORT QFxPainted : public QFxItem
-{
-Q_OBJECT
-public:
- QFxPainted(QFxItem *parent);
- ~QFxPainted();
-
- virtual void paint(QPainter *painter) = 0;
-
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
-
-protected Q_SLOTS:
- void markDirty();
-
-protected:
- QFxPainted(QFxPaintedPrivate &dd, QFxItem *parent);
-
-private:
- Q_DISABLE_COPY(QFxPainted)
- Q_DECLARE_PRIVATE(QFxPainted)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFXPAINTED_H
diff --git a/src/declarative/fx/qfxpainted_p.h b/src/declarative/fx/qfxpainted_p.h
deleted file mode 100644
index 68ac83e..0000000
--- a/src/declarative/fx/qfxpainted_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXPAINTED_P_H
-#define QFXPAINTED_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxPaintedPrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxPainted)
-
-public:
- QFxPaintedPrivate()
- : dirty(true)
- {
- }
-
- bool dirty;
-
-#if defined(QFX_RENDER_QPAINTER)
- QSimpleCanvasConfig::Image cachedImage;
-#elif defined(QFX_RENDER_OPENGL)
- GLTexture cachedTexture;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // QFXPAINTED_P_H
diff --git a/src/declarative/fx/qfximageitem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index d751845..950b468 100644
--- a/src/declarative/fx/qfximageitem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qfximageitem.h"
-#include "qfximageitem_p.h"
+#include "qfxpainteditem.h"
+#include "qfxpainteditem_p.h"
#include <QDebug>
#include <QPen>
@@ -57,30 +57,30 @@
QT_BEGIN_NAMESPACE
/*!
- \class QFxImageItem
- \brief The QFxImageItem class is an abstract base class for QFxView items that want cached painting.
+ \class QFxPaintedItem
+ \brief The QFxPaintedItem class is an abstract base class for QFxView items that want cached painting.
\ingroup group_coreitems
- This is a convenience class allowing easy use of cached painting within a custom
- item. The contents of the item are are cached behind the scenes.
+ This is a convenience class for implementing items that paint their contents
+ using a QPainter. The contents of the item are are cached behind the scenes.
The dirtyCache() function should be called if the contents change to
ensure the cache is refreshed the next time painting occurs.
- To subclass QFxImageItem, you must reimplement drawContents() to draw
+ To subclass QFxPaintedItem, you must reimplement drawContents() to draw
the contents of the item.
*/
/*!
- \fn void QFxImageItem::drawContents(QPainter *painter, const QRect &rect)
+ \fn void QFxPaintedItem::drawContents(QPainter *painter, const QRect &rect)
This function is called when the cache needs to be refreshed. When
- sub-classing QFxImageItem this function should be implemented so as to
+ sub-classing QFxPaintedItem this function should be implemented so as to
paint the contents of the item using the given \a painter for the
area of the contents specified by \a rect.
*/
/*!
- \property QFxImageItem::contentsSize
+ \property QFxPaintedItem::contentsSize
\brief The size of the contents
The contents size is the size of the item in regards to how it is painted
@@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QFxImageItem::smooth
+ \property QFxPaintedItem::smooth
\brief Setting for whether smooth scaling is enabled.
*/
@@ -99,9 +99,9 @@ QT_BEGIN_NAMESPACE
\sa clearCache()
*/
-void QFxImageItem::dirtyCache(const QRect& rect)
+void QFxPaintedItem::dirtyCache(const QRect& rect)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
for (int i=0; i < d->imagecache.count(); ) {
if (d->imagecache[i]->area.intersects(rect)) {
d->imagecache.removeAt(i);
@@ -116,9 +116,9 @@ void QFxImageItem::dirtyCache(const QRect& rect)
\sa dirtyCache()
*/
-void QFxImageItem::clearCache()
+void QFxPaintedItem::clearCache()
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
qDeleteAll(d->imagecache);
d->imagecache.clear();
}
@@ -128,9 +128,9 @@ void QFxImageItem::clearCache()
\sa setSmooth()
*/
-bool QFxImageItem::isSmooth() const
+bool QFxPaintedItem::isSmooth() const
{
- Q_D(const QFxImageItem);
+ Q_D(const QFxPaintedItem);
return d->smooth;
}
@@ -139,9 +139,9 @@ bool QFxImageItem::isSmooth() const
\sa setContentsSize()
*/
-QSize QFxImageItem::contentsSize() const
+QSize QFxPaintedItem::contentsSize() const
{
- Q_D(const QFxImageItem);
+ Q_D(const QFxPaintedItem);
return d->contentsSize;
}
@@ -151,9 +151,9 @@ QSize QFxImageItem::contentsSize() const
\sa isSmooth()
*/
-void QFxImageItem::setSmooth(bool smooth)
+void QFxPaintedItem::setSmooth(bool smooth)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
if (d->smooth == smooth) return;
d->smooth = smooth;
clearCache();
@@ -165,9 +165,9 @@ void QFxImageItem::setSmooth(bool smooth)
\sa contentsSize()
*/
-void QFxImageItem::setContentsSize(const QSize &size)
+void QFxPaintedItem::setContentsSize(const QSize &size)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
if (d->contentsSize == size) return;
d->contentsSize = size;
clearCache();
@@ -175,20 +175,20 @@ void QFxImageItem::setContentsSize(const QSize &size)
}
/*!
- Constructs a new QFxImageItem with the given \a parent.
+ Constructs a new QFxPaintedItem with the given \a parent.
*/
-QFxImageItem::QFxImageItem(QFxItem *parent)
- : QFxItem(*(new QFxImageItemPrivate), parent)
+QFxPaintedItem::QFxPaintedItem(QFxItem *parent)
+ : QFxItem(*(new QFxPaintedItemPrivate), parent)
{
init();
}
/*!
\internal
- Constructs a new QFxImageItem with the given \a parent and
+ Constructs a new QFxPaintedItem with the given \a parent and
initialized private data member \a dd.
*/
-QFxImageItem::QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent)
+QFxPaintedItem::QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent)
: QFxItem(dd, parent)
{
init();
@@ -197,14 +197,14 @@ QFxImageItem::QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent)
/*!
Destroys the image item.
*/
-QFxImageItem::~QFxImageItem()
+QFxPaintedItem::~QFxPaintedItem()
{
}
/*!
\internal
*/
-void QFxImageItem::init()
+void QFxPaintedItem::init()
{
connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
@@ -215,17 +215,17 @@ void QFxImageItem::init()
/*!
\reimp
*/
-void QFxImageItem::paintContents(QPainter &p)
+void QFxPaintedItem::paintContents(QPainter &p)
#elif defined(QFX_RENDER_OPENGL)
/*!
\reimp
*/
-void QFxImageItem::paintGLContents(GLPainter &p)
+void QFxPaintedItem::paintGLContents(GLPainter &p)
#else
#error "What render?"
#endif
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
const QRect content(QPoint(0,0),d->contentsSize);
if (content.width() <= 0 || content.height() <= 0)
return;
@@ -316,7 +316,7 @@ void QFxImageItem::paintGLContents(GLPainter &p)
qp.translate(-r.x(),-r.y());
drawContents(&qp, r);
}
- QFxImageItemPrivate::ImageCacheItem *newitem = new QFxImageItemPrivate::ImageCacheItem;
+ QFxPaintedItemPrivate::ImageCacheItem *newitem = new QFxPaintedItemPrivate::ImageCacheItem;
newitem->area = r;
#if defined(QFX_RENDER_QPAINTER)
newitem->image = QSimpleCanvasConfig::Image(QSimpleCanvasConfig::toImage(img));
diff --git a/src/declarative/fx/qfximageitem.h b/src/declarative/fx/qfxpainteditem.h
index 9ffd44e..015a035 100644
--- a/src/declarative/fx/qfximageitem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -51,17 +51,14 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-/*
-WARNING: SHORT TERM CLASS. INTENDED TO MERGE INTO QFxPainted
-*/
-class QFxImageItemPrivate;
-class Q_DECLARATIVE_EXPORT QFxImageItem : public QFxItem
+class QFxPaintedItemPrivate;
+class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
{
Q_OBJECT
public:
- QFxImageItem(QFxItem *parent=0);
- ~QFxImageItem();
+ QFxPaintedItem(QFxItem *parent=0);
+ ~QFxPaintedItem();
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize);
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth);
@@ -78,7 +75,7 @@ public:
void setSmooth(bool);
void setContentsSize(const QSize &);
protected:
- QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent);
+ QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
virtual void drawContents(QPainter *p, const QRect &) = 0;
@@ -88,10 +85,10 @@ protected Q_SLOTS:
private:
void init();
- Q_DISABLE_COPY(QFxImageItem)
- Q_DECLARE_PRIVATE(QFxImageItem)
+ Q_DISABLE_COPY(QFxPaintedItem)
+ Q_DECLARE_PRIVATE(QFxPaintedItem)
};
-QML_DECLARE_TYPE(QFxImageItem);
+QML_DECLARE_TYPE(QFxPaintedItem);
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximageitem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 80450ec..b0432ac 100644
--- a/src/declarative/fx/qfximageitem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -62,12 +62,12 @@
QT_BEGIN_NAMESPACE
-class QFxImageItemPrivate : public QFxItemPrivate
+class QFxPaintedItemPrivate : public QFxItemPrivate
{
- Q_DECLARE_PUBLIC(QFxImageItem)
+ Q_DECLARE_PUBLIC(QFxPaintedItem)
public:
- QFxImageItemPrivate()
+ QFxPaintedItemPrivate()
: max_imagecache_size(1000*1000), smooth(false)
{
}
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 45de1a3..b1f4f56 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -116,6 +116,10 @@ QML_DEFINE_TYPE(QFxParticleMotion,ParticleMotion);
\sa QFxParticles
*/
+
+/*!
+ Constructs a QFxParticleMotion with parent object \a parent.
+*/
QFxParticleMotion::QFxParticleMotion(QObject *parent) :
QObject(parent)
{
@@ -251,7 +255,7 @@ Rect {
y: 0
width: parent.width
height: 30
- src: "star.png"
+ source: "star.png"
lifeSpan: 5000
count: 50
angle: 70
@@ -543,7 +547,7 @@ Rect {
y: 0
width: parent.width
height: 30
- src: "star.png"
+ source: "star.png"
lifeSpan: 5000
count: 50
angle: 70
@@ -560,7 +564,7 @@ Rect {
x: 120
width: 1
height: 1
- src: "star.png"
+ source: "star.png"
lifeSpan: 5000
count: 200
angle: 270
@@ -698,7 +702,7 @@ void QFxParticles::setCount(int cnt)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
lifeSpan: 200
lifeSpanDeviation: 100
}
@@ -735,7 +739,7 @@ void QFxParticles::setLifeSpan(int ls)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
lifeSpan: 200
lifeSpanDeviation: 100
}
@@ -813,7 +817,7 @@ void QFxParticles::setFadeOutDuration(int dur)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
angle: 60
angleDeviation: 90
}
@@ -848,7 +852,7 @@ void QFxParticles::setAngle(qreal angle)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
angle: 60
angleDeviation: 90
}
@@ -880,7 +884,7 @@ void QFxParticles::setAngleDeviation(qreal dev)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
velocity: 50
velocityDeviation: 20
}
@@ -915,7 +919,7 @@ void QFxParticles::setVelocity(qreal velocity)
\qml
Particles {
- src: "star.png"
+ source: "star.png"
velocity: 50
velocityDeviation: 20
}
diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp
index a55f374..0bc01a7 100644
--- a/src/declarative/fx/qfxreflectionfilter.cpp
+++ b/src/declarative/fx/qfxreflectionfilter.cpp
@@ -72,23 +72,23 @@ public:
\qml
HorizontalLayout {
Image {
- src: "icon.png"
+ source: "icon.png"
filter: Reflection { }
}
Image {
- src: "icon.png"
+ source: "icon.png"
filter: Reflection { offset: 1 }
}
Image {
- src: "icon.png"
+ source: "icon.png"
filter: Reflection { offset: 1; alpha: 0.5 }
}
Image {
- src: "icon.png"
+ source: "icon.png"
filter: Reflection { offset: 1; alpha: 0.5; height: 50 }
}
Image {
- src: "icon.png"
+ source: "icon.png"
filter: Reflection { offset: 1; alpha: 0.5; height: 50; scale: 0.5 }
}
}
@@ -147,7 +147,7 @@ void QFxReflectionFilter::setAlpha(qreal a)
\qml
Image {
id: myImage
- src: "album.png"
+ source: "album.png"
filter: Reflection {
height: myImage.height * 0.5
}
diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp
index 4d34f74..83c1b47 100644
--- a/src/declarative/fx/qfxshadowfilter.cpp
+++ b/src/declarative/fx/qfxshadowfilter.cpp
@@ -86,7 +86,7 @@ Rect {
}
Image {
- src: "pics/qtlogo.png"
+ source: "pics/qtlogo.png"
filter: Shadow {
yOffset: 8
xOffset: 8
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 84e209b..a1b5484 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -103,7 +103,7 @@ TextEdit {
Constructs a new QFxTextEdit.
*/
QFxTextEdit::QFxTextEdit(QFxItem *parent)
-: QFxImageItem(*(new QFxTextEditPrivate), parent)
+: QFxPaintedItem(*(new QFxTextEditPrivate), parent)
{
Q_D(QFxTextEdit);
d->init();
@@ -113,7 +113,7 @@ QFxTextEdit::QFxTextEdit(QFxItem *parent)
\internal
*/
QFxTextEdit::QFxTextEdit(QFxTextEditPrivate &dd, QFxItem *parent)
- : QFxImageItem(dd, parent)
+ : QFxPaintedItem(dd, parent)
{
Q_D(QFxTextEdit);
d->init();
@@ -383,7 +383,7 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
{
if (newGeometry.width() != oldGeometry.width())
updateSize();
- QFxImageItem::geometryChanged(newGeometry, oldGeometry);
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
}
/*!
@@ -393,7 +393,7 @@ void QFxTextEdit::dump(int depth)
{
QByteArray ba(depth * 4, ' ');
qWarning() << ba.constData() << propertyInfo();
- QFxImageItem::dump(depth);
+ QFxPaintedItem::dump(depth);
}
/*!
@@ -412,7 +412,7 @@ QString QFxTextEdit::propertyInfo() const
void QFxTextEdit::componentComplete()
{
Q_D(QFxTextEdit);
- QFxImageItem::componentComplete();
+ QFxPaintedItem::componentComplete();
if (d->dirty) {
updateSize();
d->dirty = false;
@@ -588,7 +588,7 @@ Handles the given focus \a event.
void QFxTextEdit::focusInEvent(QFocusEvent *event)
{
Q_D(QFxTextEdit);
- QFxImageItem::focusInEvent(event);
+ QFxPaintedItem::focusInEvent(event);
d->control->processEvent(event, QPointF(0, 0));
}
@@ -599,7 +599,7 @@ Handles the given focus \a event.
void QFxTextEdit::focusOutEvent(QFocusEvent *event)
{
Q_D(QFxTextEdit);
- QFxImageItem::focusOutEvent(event);
+ QFxPaintedItem::focusOutEvent(event);
d->control->processEvent(event, QPointF(0, 0));
}
@@ -638,7 +638,7 @@ void QFxTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
@@ -653,7 +653,7 @@ void QFxTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
@@ -668,7 +668,7 @@ void QFxTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index be84a3c..b017635 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -43,7 +43,7 @@
#define QFXTEXTEDIT_H
#include <qfxtext.h>
-#include <qfximageitem.h>
+#include <qfxpainteditem.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
@@ -60,7 +60,7 @@ QT_MODULE(Declarative)
WARNING: SHORT TERM CLASS. INTENDED TO MERGE INTO QFxTextItem
*/
class QFxTextEditPrivate;
-class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxImageItem
+class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
{
Q_OBJECT
Q_ENUMS(VAlignment)
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index aa07484..b583dbe 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -54,7 +54,7 @@
//
#include "qfxitem.h"
-#include "qfximageitem_p.h"
+#include "qfxpainteditem_p.h"
#include "qml.h"
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QTextLayout;
class QTextDocument;
class QTextControl;
-class QFxTextEditPrivate : public QFxImageItemPrivate
+class QFxTextEditPrivate : public QFxPaintedItemPrivate
{
Q_DECLARE_PUBLIC(QFxTextEdit)
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 1fe02d1..71ca716 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -322,7 +322,7 @@ void QFxRotation3D::update()
The following example translates the image to 10, 3.
\qml
Image {
- src: "logo.png"
+ source: "logo.png"
transform: [
Translation3D {
axis.startX: 0
@@ -520,9 +520,9 @@ QMatrix4x4 QFxPerspective::transform() const
HorizontalLayout {
margin: 10
spacing: 10
- Image { src: "qt.png" }
+ Image { source: "qt.png" }
Image {
- src: "qt.png"
+ source: "qt.png"
transform: Squish {
x:0; y:0; width:60; height:60
topLeftX:0; topLeftY:0
@@ -532,7 +532,7 @@ QMatrix4x4 QFxPerspective::transform() const
}
}
Image {
- src: "qt.png"
+ source: "qt.png"
transform: Squish {
x:0; y:0; width:60; height:60
topLeftX:0; topLeftY:0
@@ -542,7 +542,7 @@ QMatrix4x4 QFxPerspective::transform() const
}
}
Image {
- src: "qt.png"
+ source: "qt.png"
transform: Squish {
x:0; y:0; width:60; height:60
topLeftX:0; topLeftY:10
@@ -552,7 +552,7 @@ QMatrix4x4 QFxPerspective::transform() const
}
}
Image {
- src: "qt.png"
+ source: "qt.png"
transform: Squish {
x:0; y:0; width:60; height:60
topLeftX:10; topLeftY:0
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index dac8ced..3f05846 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -68,7 +68,7 @@
#include "qfxwebview.h"
#include <qsimplecanvasfilter.h>
-#include <private/qfxitem_p.h>
+#include <private/qfxpainteditem_p.h>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxWebView,WebView);
@@ -142,14 +142,14 @@ public:
};
-class QFxWebViewPrivate : public QFxItemPrivate
+class QFxWebViewPrivate : public QFxPaintedItemPrivate
{
Q_DECLARE_PUBLIC(QFxWebView)
public:
QFxWebViewPrivate()
- : page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0),
- smooth(true), max_imagecache_size(100000), progress(1.0), pending(PendingNone)
+ : QFxPaintedItemPrivate(), page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0),
+ max_imagecache_size(100000), progress(1.0), pending(PendingNone)
{
}
@@ -189,7 +189,6 @@ public:
bool interactive;
QMouseEvent *lastPress, *lastRelease;
int mouseX, mouseY;
- bool smooth;
int max_imagecache_size;
qreal progress;
QBasicTimer dcTimer;
@@ -254,13 +253,13 @@ public:
*/
QFxWebView::QFxWebView(QFxItem *parent)
- : QFxItem(*(new QFxWebViewPrivate), parent)
+ : QFxPaintedItem(*(new QFxWebViewPrivate), parent)
{
init();
}
QFxWebView::QFxWebView(QFxWebViewPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
+ : QFxPaintedItem(dd, parent)
{
init();
}
@@ -284,7 +283,7 @@ void QFxWebView::init()
void QFxWebView::componentComplete()
{
- QFxItem::componentComplete();
+ QFxPaintedItem::componentComplete();
Q_D(QFxWebView);
switch (d->pending) {
case QFxWebViewPrivate::PendingUrl:
@@ -460,28 +459,6 @@ void QFxWebView::setInteractive(bool i)
emit interactiveChanged();
}
-/*!
- \qmlproperty bool WebView::smooth
- This property holds hints as to whether the item should be drawn anti-aliased.
-*/
-/*!
- \property QFxWebView::smooth
- \brief hints as to whether the item should be drawn anti-aliased.
-*/
-bool QFxWebView::smooth() const
-{
- Q_D(const QFxWebView);
- return d->smooth;
-}
-
-void QFxWebView::setSmooth(bool i)
-{
- Q_D(QFxWebView);
- if (d->smooth == i) return;
- d->smooth = i;
- update();
-}
-
void QFxWebView::updateCacheForVisibility()
{
Q_D(QFxWebView);
@@ -514,13 +491,15 @@ void QFxWebView::geometryChanged(const QRectF &newGeometry,
{
if (newGeometry.size() != oldGeometry.size())
expandToWebPage();
- QFxItem::geometryChanged(newGeometry, oldGeometry);
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
}
void QFxWebView::paintPage(const QRect& r)
{
Q_D(QFxWebView);
- d->dirtyCache(r);
+ if (d->page->mainFrame()->contentsSize() != contentsSize())
+ setContentsSize(d->page->mainFrame()->contentsSize());
+ dirtyCache(r);
update();
}
@@ -575,96 +554,12 @@ void QFxWebView::dump(int depth)
{
QByteArray ba(depth * 4, ' ');
qWarning() << ba.constData() << "url:" << url();
- QFxItem::dump(depth);
+ QFxPaintedItem::dump(depth);
}
-#if defined(QFX_RENDER_QPAINTER)
-void QFxWebView::paintContents(QPainter &p)
-#elif defined(QFX_RENDER_OPENGL)
-void QFxWebView::paintGLContents(GLPainter &p)
-#else
-#error "What render?"
-#endif
+void QFxWebView::drawContents(QPainter *p, const QRect &r)
{
- Q_D(QFxWebView);
- QWebFrame *frame = page()->mainFrame();
- const QRect content(QPoint(0,0),frame->contentsSize());
-
- if (content.width() <= 0 || content.height() <= 0)
- return;
-
-#if defined(QFX_RENDER_QPAINTER)
- bool wasAA = p.testRenderHint(QPainter::Antialiasing);
- bool wasSM = p.testRenderHint(QPainter::SmoothPixmapTransform);
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- QRectF clipf = p.clipRegion().boundingRect();
- const QRect clip = p.clipRegion().isEmpty() ? content : clipf.toRect();
-#elif defined(QFX_RENDER_OPENGL)
- const QRectF clipf = p.sceneClipRect;
- const QRect clip = mapFromScene(clipf).toRect();
-#endif
-
- QRegion topaint(clip);
- topaint &= content;
- QRegion uncached(content);
-
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- if (topaint.contains(area)) {
- p.drawImage(area, d->imagecache[i]->image);
- topaint -= area;
- d->imagecache[i]->age=0;
- } else {
- d->imagecache[i]->age++;
- }
- cachesize += area.width()*area.height();
- uncached -= area;
- }
-
- if (!topaint.isEmpty()) {
- // Find a sensible larger area, otherwise will paint lots of tiny images.
- QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128);
- cachesize += biggerrect.width() * biggerrect.height();
- while (d->imagecache.count() && cachesize > d->max_imagecache_size) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- uncached += d->imagecache[oldest]->area;
- d->imagecache.removeAt(oldest);
- }
- const QRegion bigger = QRegion(biggerrect) & uncached;
- const QVector<QRect> rects = bigger.rects();
- foreach (QRect r, rects) {
- QImage img(r.size(),QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- {
- QPainter qp(&img);
- qp.translate(-r.x(),-r.y());
- frame->render(&qp,r);
- }
- QFxWebViewPrivate::ImageCacheItem *newitem = new QFxWebViewPrivate::ImageCacheItem;
- newitem->area = r;
-#if defined(QFX_RENDER_QPAINTER)
- newitem->image = QSimpleCanvasConfig::Image(QSimpleCanvasConfig::toImage(img));
-#else
- newitem->image.setImage(img);
-#endif
- d->imagecache.append(newitem);
- p.drawImage(r, newitem->image);
- }
- }
-#if defined(QFX_RENDER_QPAINTER)
- p.setRenderHints(QPainter::Antialiasing, wasAA);
- p.setRenderHints(QPainter::SmoothPixmapTransform, wasSM);
-#endif
+ page()->mainFrame()->render(p,r);
}
QString QFxWebView::propertyInfo() const
@@ -761,7 +656,7 @@ void QFxWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
void QFxWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@@ -775,7 +670,7 @@ void QFxWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mouseReleaseEvent(event);
+ QFxPaintedItem::mouseReleaseEvent(event);
}
void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -796,7 +691,7 @@ void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mouseMoveEvent(event);
+ QFxPaintedItem::mouseMoveEvent(event);
}
void QFxWebView::keyPressEvent(QKeyEvent* event)
@@ -805,7 +700,7 @@ void QFxWebView::keyPressEvent(QKeyEvent* event)
if (d->interactive)
page()->event(event);
if (!event->isAccepted())
- QFxItem::keyPressEvent(event);
+ QFxPaintedItem::keyPressEvent(event);
}
void QFxWebView::keyReleaseEvent(QKeyEvent* event)
@@ -814,7 +709,7 @@ void QFxWebView::keyReleaseEvent(QKeyEvent* event)
if (d->interactive)
page()->event(event);
if (!event->isAccepted())
- QFxItem::keyReleaseEvent(event);
+ QFxPaintedItem::keyReleaseEvent(event);
}
/*!
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 6ba4601..afd5b0f 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -45,7 +45,7 @@
#include <QAction>
#include <QUrl>
#include <qfxglobal.h>
-#include <qfxitem.h>
+#include <qfxpainteditem.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QWebPage>
@@ -74,7 +74,7 @@ private:
};
-class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
+class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem
{
Q_OBJECT
@@ -91,7 +91,6 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
Q_PROPERTY(int idealWidth READ idealWidth WRITE setIdealWidth NOTIFY idealWidthChanged)
Q_PROPERTY(int idealHeight READ idealHeight WRITE setIdealHeight NOTIFY idealHeightChanged)
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
@@ -128,9 +127,6 @@ public:
int mouseX() const;
int mouseY() const;
- bool smooth() const;
- void setSmooth(bool);
-
int idealWidth() const;
void setIdealWidth(int);
int idealHeight() const;
@@ -146,11 +142,6 @@ public:
virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
QWebPage *page() const;
void setPage(QWebPage *page);
@@ -197,6 +188,9 @@ private Q_SLOTS:
protected:
QFxWebView(QFxWebViewPrivate &dd, QFxItem *parent);
+
+ void drawContents(QPainter *, const QRect &);
+
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/javascript.g
index 0da7571..5482392 100644
--- a/src/declarative/qml/parser/javascript.g
+++ b/src/declarative/qml/parser/javascript.g
@@ -688,7 +688,8 @@ UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER ;
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
node->isDefaultMember = true;
- node->propertyToken = loc(1);
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
sym(1).Node = node;
@@ -714,7 +715,8 @@ case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).Expression);
node->isDefaultMember = true;
- node->propertyToken = loc(1);
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
diff --git a/src/declarative/qml/parser/javascriptast_p.h b/src/declarative/qml/parser/javascriptast_p.h
index 3a22fff..ad317e8 100644
--- a/src/declarative/qml/parser/javascriptast_p.h
+++ b/src/declarative/qml/parser/javascriptast_p.h
@@ -2336,7 +2336,12 @@ public:
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
- { return propertyToken; }
+ {
+ if (defaultToken.isValid())
+ return defaultToken;
+
+ return propertyToken;
+ }
virtual SourceLocation lastSourceLocation() const
{
@@ -2359,6 +2364,7 @@ public:
JavaScriptNameIdImpl *name;
ExpressionNode *expression;
bool isDefaultMember;
+ SourceLocation defaultToken;
SourceLocation propertyToken;
SourceLocation typeToken;
SourceLocation identifierToken;
diff --git a/src/declarative/qml/parser/javascriptparser.cpp b/src/declarative/qml/parser/javascriptparser.cpp
index b241297..185a824 100644
--- a/src/declarative/qml/parser/javascriptparser.cpp
+++ b/src/declarative/qml/parser/javascriptparser.cpp
@@ -298,7 +298,8 @@ case 30: {
case 31: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
node->isDefaultMember = true;
- node->propertyToken = loc(1);
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
sym(1).Node = node;
@@ -318,7 +319,8 @@ case 33: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).Expression);
node->isDefaultMember = true;
- node->propertyToken = loc(1);
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 9067039..5198264 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -8,7 +8,6 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlcontext.cpp \
qml/qmlcustomparser.cpp \
qml/qmlpropertyvaluesource.cpp \
- qml/qmlxmlparser.cpp \
qml/qmlproxymetaobject.cpp \
qml/qmlvme.cpp \
qml/qmlcompiler.cpp \
@@ -22,7 +21,8 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlclassfactory.cpp \
qml/qmlparserstatus.cpp \
qml/qmlcompositetypemanager.cpp \
- qml/qmlinfo.cpp
+ qml/qmlinfo.cpp \
+ qml/qmlerror.cpp
HEADERS += qml/qmlparser_p.h \
qml/qmlinstruction_p.h \
@@ -36,7 +36,6 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlcustomparser_p_p.h \
qml/qmlpropertyvaluesource.h \
qml/qmlboundsignal_p.h \
- qml/qmlxmlparser_p.h \
qml/qmlparserstatus.h \
qml/qmlproxymetaobject_p.h \
qml/qmlcompiledcomponent_p.h \
@@ -58,7 +57,8 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlcontext_p.h \
qml/qmlcompositetypemanager_p.h \
qml/qmllist.h \
- qml/qmldeclarativedata_p.h
+ qml/qmldeclarativedata_p.h \
+ qml/qmlerror.h
# for qtscript debugger
QT += scripttools
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index c9bdfec..d4003ab 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -64,17 +64,6 @@
#include "qmlscriptparser_p.h"
QT_BEGIN_NAMESPACE
-/*
- New properties and signals can be added to any QObject type from QML.
- <QObject>
- <properties><Property name="myProperty" /></properties>
- <signals><Signal name="mySignal" /></signals>
- </QObject
- The special names used as magical properties (in the above case "properties"
- and "signals") are defined here.
-*/
-#define PROPERTIES_NAME "properties"
-#define SIGNALS_NAME "signals"
using namespace QmlParser;
@@ -147,7 +136,7 @@ int QmlCompiledData::indexForInt(int *data, int count)
}
QmlCompiler::QmlCompiler()
-: exceptionLine(-1), output(0)
+: exceptionLine(-1), exceptionColumn(-1), output(0)
{
}
@@ -156,14 +145,19 @@ bool QmlCompiler::isError() const
return exceptionLine != -1;
}
-qint64 QmlCompiler::errorLine() const
+QList<QmlError> QmlCompiler::errors() const
{
- return exceptionLine;
-}
+ QList<QmlError> rv;
+
+ if(isError()) {
+ QmlError error;
+ error.setDescription(exceptionDescription);
+ error.setLine(exceptionLine);
+ error.setColumn(exceptionColumn);
+ rv << error;
+ }
-QString QmlCompiler::errorDescription() const
-{
- return exceptionDescription;
+ return rv;
}
bool QmlCompiler::isValidId(const QString &val)
@@ -437,9 +431,19 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory)
cc->bytecode.clear();
}
+#define COMPILE_EXCEPTION2(token, desc) \
+ { \
+ exceptionLine = token->line; \
+ exceptionColumn = token->column; \
+ QDebug d(&exceptionDescription); \
+ d << desc; \
+ return false; \
+ }
+
#define COMPILE_EXCEPTION(desc) \
{ \
exceptionLine = obj->line; \
+ exceptionColumn = obj->column; \
QDebug d(&exceptionDescription); \
d << desc; \
return false; \
@@ -532,49 +536,16 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt)
ctxt = 0;
- // Only use magical "properties" and "signals" properties if the type
- // doesn't have already have them
- bool ignoreProperties = false;
- bool ignoreSignals = false;
- if (obj->metatype && obj->metatype->indexOfProperty(PROPERTIES_NAME) != -1)
- ignoreProperties = true;
- if (obj->metatype && obj->metatype->indexOfProperty(SIGNALS_NAME) != -1)
- ignoreSignals = true;
-
- Property *propertiesProperty = ignoreProperties?0:obj->getProperty(PROPERTIES_NAME, false);
- Property *signalsProperty = ignoreSignals?0:obj->getProperty(SIGNALS_NAME, false);
-
- if (propertiesProperty) {
- obj->dynamicPropertiesProperty = propertiesProperty;
- obj->properties.remove(PROPERTIES_NAME);
- }
- if (signalsProperty) {
- obj->dynamicSignalsProperty = signalsProperty;
- obj->properties.remove(SIGNALS_NAME);
- }
-
int createInstrIdx = output->bytecode.count();
- if (obj->type != -1 && output->types.at(obj->type).parser) {
- QByteArray data = obj->custom;
- int ref = output->indexForByteArray(data);
-
- QmlInstruction create;
- create.type = QmlInstruction::CreateCustomObject;
- create.line = obj->line;
- create.createCustom.type = obj->type;
- create.createCustom.data = ref;
- output->bytecode << create;
- } else {
- // Create the object
- QmlInstruction create;
- create.type = QmlInstruction::CreateObject;
- create.line = obj->line;
- create.create.data = -1;
- create.create.type = obj->type;
- output->bytecode << create;
- }
+ // Create the object
+ QmlInstruction create;
+ create.type = QmlInstruction::CreateObject;
+ create.line = obj->line;
+ create.create.data = -1;
+ create.create.type = obj->type;
+ output->bytecode << create;
- COMPILE_CHECK(compileDynamicPropertiesAndSignals(obj));
+ COMPILE_CHECK(compileDynamicMeta(obj));
if (obj->type != -1) {
if (output->types.at(obj->type).component) {
@@ -599,9 +570,7 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt)
QList<QmlCustomParserProperty> customProps;
foreach(Property *prop, obj->properties) {
- if (!ignoreProperties && prop->name == PROPERTIES_NAME) {
- } else if (!ignoreSignals && prop->name == SIGNALS_NAME) {
- } else if (prop->name.length() >= 3 && prop->name.startsWith("on") &&
+ if (prop->name.length() >= 3 && prop->name.startsWith("on") &&
('A' <= prop->name.at(2) && 'Z' >= prop->name.at(2))) {
if (!isCustomParser) {
COMPILE_CHECK(compileSignal(prop, obj));
@@ -1215,10 +1184,10 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop,
//### we are restricted to a rather generic message here. If we can find a way to move
// the exception into generateStoreInstruction we could potentially have better messages.
// (the problem is that both compile and run exceptions can be generated, though)
- COMPILE_EXCEPTION("Cannot assign value" << v->primitive << "to property" << obj->metaObject()->property(prop->index).name());
+ COMPILE_EXCEPTION2(v, "Cannot assign value" << v->primitive << "to property" << obj->metaObject()->property(prop->index).name());
doassign = false;
} else if (r == ReadOnly) {
- COMPILE_EXCEPTION("Cannot assign value" << v->primitive << "to the read-only property" << obj->metaObject()->property(prop->index).name());
+ COMPILE_EXCEPTION2(v, "Cannot assign value" << v->primitive << "to the read-only property" << obj->metaObject()->property(prop->index).name());
} else {
doassign = true;
}
@@ -1243,210 +1212,12 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop,
return true;
}
-bool QmlCompiler::findDynamicProperties(QmlParser::Property *prop,
- QmlParser::Object *obj)
-{
- QList<Object::DynamicProperty> definedProperties;
-
- struct TypeNameToType {
- const char *name;
- Object::DynamicProperty::Type type;
- } propTypeNameToTypes[] = {
- { "", Object::DynamicProperty::Variant },
- { "int", Object::DynamicProperty::Int },
- { "bool", Object::DynamicProperty::Bool },
- { "double", Object::DynamicProperty::Real },
- { "real", Object::DynamicProperty::Real },
- { "string", Object::DynamicProperty::String },
- { "color", Object::DynamicProperty::Color },
- { "date", Object::DynamicProperty::Date },
- { "variant", Object::DynamicProperty::Variant }
- };
- const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
- sizeof(propTypeNameToTypes[0]);
-
-
- if (prop->value)
- COMPILE_EXCEPTION("Invalid property specification");
-
- bool seenDefault = false;
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- QmlParser::Value *val = prop->values.at(ii);
- if (!val->object)
- COMPILE_EXCEPTION("Invalid property specification");
-
- QmlParser::Object *obj = val->object;
- if (obj->type == -1 || output->types.at(obj->type).className != "Property")
- COMPILE_EXCEPTION("Use Property tag to specify properties");
-
-
- enum Seen { None = 0, Name = 0x01,
- Type = 0x02, Value = 0x04,
- ValueChanged = 0x08,
- Default = 0x10 } seen = None;
-
- Object::DynamicProperty propDef;
-
- for (QHash<QByteArray, QmlParser::Property *>::ConstIterator iter =
- obj->properties.begin();
- iter != obj->properties.end();
- ++iter) {
-
- QmlParser::Property *property = *iter;
- if (property->name == "name") {
- if (seen & Name)
- COMPILE_EXCEPTION("May only specify Property name once");
- seen = (Seen)(seen | Name);
-
- if (property->value || property->values.count() != 1 ||
- property->values.at(0)->object)
- COMPILE_EXCEPTION("Invalid Property name");
-
- propDef.name = property->values.at(0)->primitive.toLatin1();
-
- } else if (property->name == "type") {
- if (seen & Type)
- COMPILE_EXCEPTION("May only specify Property type once");
- seen = (Seen)(seen | Type);
-
- if (property->value || property->values.count() != 1 ||
- property->values.at(0)->object)
- COMPILE_EXCEPTION("Invalid Property type");
-
- QString type = property->values.at(0)->primitive.toLower();
- bool found = false;
- for (int ii = 0; !found && ii < propTypeNameToTypesCount; ++ii) {
- if (type == QLatin1String(propTypeNameToTypes[ii].name)){
- found = true;
- propDef.type = propTypeNameToTypes[ii].type;
- }
-
- }
-
- if (!found)
- COMPILE_EXCEPTION("Invalid Property type");
-
- } else if (property->name == "value") {
- if (seen & Value)
- COMPILE_EXCEPTION("May only specify Property value once");
- seen = (Seen)(seen | Value);
-
- propDef.defaultValue = property;
- } else if (property->name == "onValueChanged") {
- if (seen & ValueChanged)
- COMPILE_EXCEPTION("May only specify Property onValueChanged once");
- seen = (Seen)(seen | ValueChanged);
-
- if (property->value || property->values.count() != 1 ||
- property->values.at(0)->object)
- COMPILE_EXCEPTION("Invalid Property onValueChanged");
-
- propDef.onValueChanged = property->values.at(0)->primitive;
-
- } else if (property->name == "default") {
- if (seen & Default)
- COMPILE_EXCEPTION("May only specify Property default once");
- seen = (Seen)(seen | Default);
- if (property->value || property->values.count() != 1 ||
- property->values.at(0)->object)
- COMPILE_EXCEPTION("Invalid Property default");
-
- bool defaultValue =
- QmlStringConverters::boolFromString(property->values.at(0)->primitive);
- propDef.isDefaultProperty = defaultValue;
- if (defaultValue) {
- if (seenDefault)
- COMPILE_EXCEPTION("Only one property may be the default");
- seenDefault = true;
- }
-
- } else {
- COMPILE_EXCEPTION("Invalid Property property");
- }
-
- }
- if (obj->defaultProperty) {
- if (seen & Value)
- COMPILE_EXCEPTION("May only specify Property value once");
-
- seen = (Seen)(seen | Value);
- propDef.defaultValue = obj->defaultProperty;
- }
-
- if (!(seen & Name))
- COMPILE_EXCEPTION("Must specify Property name");
-
- definedProperties << propDef;
- }
-
- obj->dynamicProperties << definedProperties;
- return true;
-}
-
-bool QmlCompiler::findDynamicSignals(QmlParser::Property *sigs,
- QmlParser::Object *obj)
-{
- QList<Object::DynamicSignal> definedSignals;
-
- if (sigs->value)
- COMPILE_EXCEPTION("Invalid signal specification");
-
- for (int ii = 0; ii < sigs->values.count(); ++ii) {
- QmlParser::Value *val = sigs->values.at(ii);
- if (!val->object)
- COMPILE_EXCEPTION("Invalid signal specification");
-
- QmlParser::Object *obj = val->object;
- if (obj->type == -1 || output->types.at(obj->type).className != "Signal")
- COMPILE_EXCEPTION("Use Signal tag to specify signals");
-
- enum Seen { None = 0, Name = 0x01 } seen = None;
- Object::DynamicSignal sigDef;
-
- for (QHash<QByteArray, QmlParser::Property *>::ConstIterator iter =
- obj->properties.begin();
- iter != obj->properties.end();
- ++iter) {
-
- QmlParser::Property *property = *iter;
- if (property->name == "name") {
- if (seen & Name)
- COMPILE_EXCEPTION("May only specify Signal name once");
- seen = (Seen)(seen | Name);
-
- if (property->value || property->values.count() != 1 ||
- property->values.at(0)->object)
- COMPILE_EXCEPTION("Invalid Signal name");
-
- sigDef.name = property->values.at(0)->primitive.toLatin1();
-
- } else {
- COMPILE_EXCEPTION("Invalid Signal property");
- }
-
- }
-
- if (obj->defaultProperty)
- COMPILE_EXCEPTION("Invalid Signal property");
-
- if (!(seen & Name))
- COMPILE_EXCEPTION("Must specify Signal name");
-
- definedSignals << sigDef;
- }
-
- obj->dynamicSignals << definedSignals;
- return true;
-}
-
-bool QmlCompiler::compileDynamicPropertiesAndSignals(QmlParser::Object *obj)
+bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj)
{
- if (obj->dynamicPropertiesProperty)
- findDynamicProperties(obj->dynamicPropertiesProperty, obj);
- if (obj->dynamicSignalsProperty)
- findDynamicSignals(obj->dynamicSignalsProperty, obj);
-
- if (obj->dynamicProperties.isEmpty() && obj->dynamicSignals.isEmpty())
+ // ### FIXME - Check that there is only one default property etc.
+ if (obj->dynamicProperties.isEmpty() &&
+ obj->dynamicSignals.isEmpty() &&
+ obj->dynamicSlots.isEmpty())
return true;
QMetaObjectBuilder builder;
@@ -1494,6 +1265,14 @@ bool QmlCompiler::compileDynamicPropertiesAndSignals(QmlParser::Object *obj)
builder.addSignal(s.name + "()");
}
+ int slotStart = obj->dynamicSlots.isEmpty()?-1:output->primitives.count();
+
+ for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
+ const Object::DynamicSlot &s = obj->dynamicSlots.at(ii);
+ builder.addSlot(s.name + "()");
+ output->primitives << s.body;
+ }
+
if (obj->metatype)
builder.setSuperClass(obj->metatype);
@@ -1503,6 +1282,7 @@ bool QmlCompiler::compileDynamicPropertiesAndSignals(QmlParser::Object *obj)
QmlInstruction store;
store.type = QmlInstruction::StoreMetaObject;
store.storeMeta.data = output->mos.count() - 1;
+ store.storeMeta.slotData = slotStart;
store.line = obj->line;
output->bytecode << store;
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index 9a0ce1c..e2b8388 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -45,6 +45,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qset.h>
#include <qml.h>
+#include <qmlerror.h>
#include <private/qmlinstruction_p.h>
#include <private/qmlcompositetypemanager_p.h>
class QStringList;
@@ -115,8 +116,7 @@ public:
bool compile(QmlEngine *, QmlCompositeTypeData *, QmlCompiledComponent *);
bool isError() const;
- qint64 errorLine() const;
- QString errorDescription() const;
+ QList<QmlError> errors() const;
static bool isValidId(const QString &);
static bool isBinding(const QString &);
@@ -163,12 +163,7 @@ private:
QmlParser::Value *value,
int ctxt);
- bool findDynamicProperties(QmlParser::Property *prop,
- QmlParser::Object *obj);
- bool findDynamicSignals(QmlParser::Property *sigs,
- QmlParser::Object *obj);
-
- bool compileDynamicPropertiesAndSignals(QmlParser::Object *obj);
+ bool compileDynamicMeta(QmlParser::Object *obj);
void compileBinding(const QString &, QmlParser::Property *prop,
int ctxt, const QMetaObject *, qint64);
@@ -176,6 +171,7 @@ private:
QSet<QString> ids;
qint64 exceptionLine;
+ qint64 exceptionColumn;
QString exceptionDescription;
QmlCompiledData *output;
};
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index c316f03..72d4e08 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -60,17 +60,6 @@
QT_BEGIN_NAMESPACE
class QByteArray;
-bool QmlComponentPrivate::isXml(const QByteArray &ba)
-{
- for (int i = 0; i < ba.size(); ++i) {
- char c = ba.at(i);
- if (c == ' ' || c == '\n' || c == '\r' || c == '\t')
- continue;
- return (c == '<');
- }
- return true;
-}
-
/*!
\class QmlComponent
\brief The QmlComponent class encapsulates a QML component description.
@@ -137,9 +126,7 @@ void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data)
if (!c) {
Q_ASSERT(data->status == QmlCompositeTypeData::Error);
- errorDescription = data->errorDescription;
- qWarning().nospace() << "QmlComponent: "
- << data->errorDescription.toLatin1().constData();
+ errors = data->errors;
} else {
@@ -192,10 +179,10 @@ QmlComponent::Status QmlComponent::status() const
if (d->typeData)
return Loading;
+ else if (!d->errors.isEmpty())
+ return Error;
else if (d->engine && d->cc)
return Ready;
- else if (!d->errorDescription.isEmpty())
- return Error;
else
return Null;
}
@@ -269,7 +256,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, const QUrl &url, QObject *parent)
}
/*!
- Create a QmlComponent from the given XML \a data. If provided, \a filename
+ Create a QmlComponent from the given QML \a data. If provided, \a url
is used to set the component name, and to provide a base path for items
resolved by this component.
*/
@@ -296,8 +283,8 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int star
}
/*!
- Sets the QmlComponent to use the given XML \a data. If provided,
- \a filename is used to set the component name, and to provide a base path
+ Sets the QmlComponent to use the given QML \a data. If provided,
+ \a url is used to set the component name, and to provide a base path
for items resolved by this component.
*/
void QmlComponent::setData(const QByteArray &data, const QUrl &url)
@@ -353,13 +340,17 @@ void QmlComponent::loadUrl(const QUrl &url)
emit statusChanged(status());
}
-QString QmlComponent::errorDescription() const
+/*!
+ Return the list of errors that occured during the last compile or create
+ operation. An empty list is returned if isError() is not set.
+*/
+QList<QmlError> QmlComponent::errors() const
{
Q_D(const QmlComponent);
if (isError())
- return d->errorDescription;
+ return d->errors;
else
- return QString();
+ return QList<QmlError>();
}
/*!
@@ -448,7 +439,7 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
}
if (!isReady()) {
- qWarning("QmlComponent: Cannot create un-ready component");
+ qWarning("QmlComponent: Component is not ready");
return 0;
}
@@ -466,15 +457,9 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
QmlVME vme;
QObject *rv = vme.run(ctxt, d->cc, d->start, d->count);
- if (vme.isError()) {
- qWarning().nospace()
-#ifdef QML_VERBOSEERRORS_ENABLED
- << "QmlComponent: "
-#endif
- << vme.errorDescription().toLatin1().constData() << " @"
- << d->url.toString().toLatin1().constData() << ":" << vme.errorLine();
- }
+ if (vme.isError())
+ d->errors = vme.errors();
ctxt->deactivate();
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 0493c1f..90f7467 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -46,7 +46,7 @@
#include <QtCore/qstring.h>
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
-
+#include <QtDeclarative/qmlerror.h>
QT_BEGIN_HEADER
@@ -77,7 +77,8 @@ public:
bool isReady() const;
bool isError() const;
bool isLoading() const;
- QString errorDescription() const;
+
+ QList<QmlError> errors() const;
QUrl url() const;
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
index bb5f7bb..6a5345e 100644
--- a/src/declarative/qml/qmlcomponent_p.h
+++ b/src/declarative/qml/qmlcomponent_p.h
@@ -47,6 +47,7 @@
#include <QList>
#include "private/qobject_p.h"
#include "private/qmlcompositetypemanager_p.h"
+#include <qmlerror.h>
#include "qmlcomponent.h"
class QmlComponent;
class QmlEngine;
@@ -68,7 +69,7 @@ public:
void fromTypeData(QmlCompositeTypeData *data);
- QString errorDescription;
+ QList<QmlError> errors;
QUrl url;
int start;
@@ -81,7 +82,6 @@ public:
QmlEngine *engine;
void clear();
- static bool isXml(const QByteArray &);
};
#endif // QMLCOMPONENT_P_H
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 7f2cc58..fbe40bf 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -105,10 +105,9 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine)
QmlCompiler compiler;
if (!compiler.compile(engine, this, compiledComponent)) {
status = Error;
- errorDescription = compiler.errorDescription() +
- QLatin1String("@") +
- url + QLatin1String(":") +
- QString::number(compiler.errorLine());
+ errors = compiler.errors();
+ for(int ii = 0; ii < errors.count(); ++ii)
+ errors[ii].setUrl(url);
compiledComponent->release();
compiledComponent = 0;
}
@@ -188,7 +187,10 @@ void QmlCompositeTypeManager::replyFinished()
reply->url().toString();
unit->status = QmlCompositeTypeData::Error;
- unit->errorDescription = errorDescription;
+ // ### FIXME
+ QmlError error;
+ error.setDescription(errorDescription);
+ unit->errors << error;
doComplete(unit);
} else {
@@ -215,7 +217,10 @@ void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit)
// ### - Fill in error
errorDescription = QLatin1String("File error for URL ") + url.toString();
unit->status = QmlCompositeTypeData::Error;
- unit->errorDescription = errorDescription;
+ // ### FIXME
+ QmlError error;
+ error.setDescription(errorDescription);
+ unit->errors << error;
doComplete(unit);
}
@@ -234,7 +239,7 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
if (!unit->data.parse(data, url)) {
unit->status = QmlCompositeTypeData::Error;
- unit->errorDescription = unit->data.errorDescription();
+ unit->errors << unit->data.errors();
doComplete(unit);
} else {
@@ -273,7 +278,7 @@ void QmlCompositeTypeManager::checkComplete(QmlCompositeTypeData *unit)
if (u->status == QmlCompositeTypeData::Error) {
unit->status = QmlCompositeTypeData::Error;
- unit->errorDescription = u->errorDescription;
+ unit->errors = u->errors;
doComplete(unit);
return;
} else if (u->status == QmlCompositeTypeData::Waiting) {
@@ -334,7 +339,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit)
case QmlCompositeTypeData::Invalid:
case QmlCompositeTypeData::Error:
unit->status = QmlCompositeTypeData::Error;
- unit->errorDescription = urlUnit->errorDescription;
+ unit->errors = urlUnit->errors;
doComplete(unit);
return;
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index bc86fcf..e4028d5 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -45,6 +45,7 @@
#include <qglobal.h>
#include <private/qmlscriptparser_p.h>
#include <private/qmlrefcount_p.h>
+#include <qmlerror.h>
QT_BEGIN_NAMESPACE
@@ -65,7 +66,8 @@ struct QmlCompositeTypeData : public QmlRefCount
Waiting
};
Status status;
- QString errorDescription;
+
+ QList<QmlError> errors;
QString url;
QList<QmlCompositeTypeData *> dependants;
diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h
index 0e6a619..e4e6089 100644
--- a/src/declarative/qml/qmlcustomparser_p.h
+++ b/src/declarative/qml/qmlcustomparser_p.h
@@ -98,26 +98,9 @@ class Q_DECLARATIVE_EXPORT QmlCustomParser
public:
virtual ~QmlCustomParser() {}
- virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0;
virtual QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
- virtual QVariant create(const QByteArray &)=0;
virtual void setCustomData(QObject *, const QByteArray &);
-
- struct Register {
- Register(const char *name, QmlCustomParser *parser) {
- qmlRegisterCustomParser(name, parser);
- }
- };
- template<typename T>
- struct Define {
- static Register instance;
- };
};
-#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \
- template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(# name, new parserClass);
-#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \
- template<> QmlCustomParser::Register QmlCustomParser::Define<parserClass>::instance(namespacestring "/" # name, new parserClass);
-
#define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterCustomType<TYPE>(#NAME, #TYPE, new CUSTOMTYPE));
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index e1c4c28..08755b1 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -70,6 +70,7 @@ QmlDomDocumentPrivate::~QmlDomDocumentPrivate()
/*!
\class QmlDomDocument
+ \internal
\brief The QmlDomDocument class represents the root of a QML document
A QML document is a self-contained snippet of QML, usually contained in a
@@ -152,7 +153,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data)
{
Q_UNUSED(engine);
- d->error = QString();
+ d->errors.clear();
QmlCompiledComponent component;
QmlCompiler compiler;
@@ -160,11 +161,13 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data)
QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, QUrl());;
if(td->status == QmlCompositeTypeData::Error) {
- d->error = td->errorDescription;
+ d->errors = td->errors;
td->release();
return false;
} else if(td->status == QmlCompositeTypeData::Waiting) {
- d->error = QLatin1String("QmlDomDocument supports local types only");
+ QmlError error;
+ error.setDescription(QLatin1String("QmlDomDocument supports local types only"));
+ d->errors << error;
td->release();
return false;
}
@@ -172,7 +175,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data)
compiler.compile(engine, td, &component);
if (compiler.isError()) {
- d->error = compiler.errorDescription();
+ d->errors = compiler.errors();
td->release();
return false;
}
@@ -188,14 +191,14 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data)
/*!
- Returns the last load error. The load error will be reset after a
+ Returns the last load errors. The load errors will be reset after a
successful call to load().
\sa load()
*/
-QString QmlDomDocument::loadError() const
+QList<QmlError> QmlDomDocument::errors() const
{
- return d->error;
+ return d->errors;
}
/*!
@@ -249,6 +252,7 @@ QmlDomPropertyPrivate::~QmlDomPropertyPrivate()
/*!
\class QmlDomProperty
+ \internal
\brief The QmlDomProperty class represents one property assignment in the
QML DOM tree
@@ -450,6 +454,7 @@ QmlDomObjectPrivate::properties(QmlParser::Property *property) const
/*!
\class QmlDomObject
+ \internal
\brief The QmlDomObject class represents an object instantiation.
Each object instantiated in a QML file has a corresponding QmlDomObject
@@ -734,6 +739,7 @@ QmlDomBasicValuePrivate::~QmlDomBasicValuePrivate()
/*!
\class QmlDomValueLiteral
+ \internal
\brief The QmlDomValueLiteral class represents a literal value.
A literal value is a simple value, written inline with the QML. In the
@@ -806,6 +812,7 @@ void QmlDomValueLiteral::setLiteral(const QString &value)
/*!
\class QmlDomValueBinding
+ \internal
\brief The QmlDomValueBinding class represents a property binding.
A property binding is an ECMAScript expression assigned to a property. In
@@ -875,6 +882,7 @@ void QmlDomValueBinding::setBinding(const QString &expression)
/*!
\class QmlDomValueValueSource
+ \internal
\brief The QmlDomValueValueSource class represents a value source assignment value.
In QML, value sources are special value generating types that may be
@@ -949,7 +957,7 @@ QmlDomObject QmlDomValueValueSource::object() const
rv.d->object = d->value->object;
rv.d->object->addref();
}
- return QmlDomObject();
+ return rv;
}
/*!
@@ -983,6 +991,7 @@ QmlDomValuePrivate::~QmlDomValuePrivate()
/*!
\class QmlDomValue
+ \internal
\brief The QmlDomValue class represents a generic Qml value.
QmlDomValue's can be assigned to QML \l {QmlDomProperty}{properties}. In
@@ -1234,6 +1243,7 @@ QmlDomList QmlDomValue::toList() const
/*!
\class QmlDomList
+ \internal
\brief The QmlDomList class represents a list of values assigned to a QML property.
Lists of values can be assigned to properties. For example, the following
@@ -1323,6 +1333,7 @@ void QmlDomList::setValues(const QList<QmlDomValue> &values)
/*!
\class QmlDomComponent
+ \internal
\brief The QmlDomComponent class represents sub-component within a QML document.
Sub-components are QmlComponents defined within a QML document. The
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 47a89d9..74ed27c 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -44,6 +44,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qshareddata.h>
+#include <QtDeclarative/qmlerror.h>
QT_BEGIN_HEADER
@@ -71,6 +72,7 @@ public:
int version() const;
+ QList<QmlError> errors() const;
QString loadError() const;
bool load(QmlEngine *, const QByteArray &);
QByteArray save() const;
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 8ea56bf..4c3ca44 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -57,7 +57,7 @@ public:
QmlDomDocumentPrivate(const QmlDomDocumentPrivate &);
~QmlDomDocumentPrivate();
- QString error;
+ QList<QmlError> errors;
QmlParser::Object *root;
};
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 30848c1..f8b7ad6 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -373,7 +373,7 @@ bool QmlEnginePrivate::loadCache(QmlBasicScriptNodeCache &cache, const QString &
\code
QmlEngine engine;
- QmlComponent component("<Text text=\"Hello world!\"/>");
+ QmlComponent component("Text { text: \"Hello world!\" }");
QFxItem *item = qobject_cast<QFxItem *>(component.create(&engine));
//add item to view, etc
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp
new file mode 100644
index 0000000..2ed3500
--- /dev/null
+++ b/src/declarative/qml/qmlerror.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlerror.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QmlError
+ \brief The QmlError class encapsulates a QML error
+*/
+class QmlErrorPrivate
+{
+public:
+ QmlErrorPrivate();
+
+ QUrl url;
+ QString description;
+ int line;
+ int column;
+};
+
+QmlErrorPrivate::QmlErrorPrivate()
+: line(-1), column(-1)
+{
+}
+
+/*!
+ Create an empty error object.
+*/
+QmlError::QmlError()
+: d(new QmlErrorPrivate)
+{
+}
+
+/*!
+ Create a copy of \a other.
+*/
+QmlError::QmlError(const QmlError &other)
+: d(new QmlErrorPrivate)
+{
+ *this = other;
+}
+
+/*!
+ Assign \a other to this error object.
+*/
+QmlError &QmlError::operator=(const QmlError &other)
+{
+ d->url = other.d->url;
+ d->description = other.d->description;
+ d->line = other.d->line;
+ d->column = other.d->column;
+ return *this;
+}
+
+/*!
+ \internal
+*/
+QmlError::~QmlError()
+{
+ delete d; d = 0;
+}
+
+/*!
+ Return the url for the file that caused this error.
+*/
+QUrl QmlError::url() const
+{
+ return d->url;
+}
+
+/*!
+ Set the \a url for the file that caused this error.
+*/
+void QmlError::setUrl(const QUrl &url)
+{
+ d->url = url;
+}
+
+/*!
+ Return the error description.
+*/
+QString QmlError::description() const
+{
+ return d->description;
+}
+
+/*!
+ Set the error \a description.
+*/
+void QmlError::setDescription(const QString &description)
+{
+ d->description = description;
+}
+
+/*!
+ Return the error line number.
+*/
+int QmlError::line() const
+{
+ return d->line;
+}
+
+/*!
+ Set the error \a line number.
+*/
+void QmlError::setLine(int line)
+{
+ d->line = line;
+}
+
+/*!
+ Return the error column number.
+*/
+int QmlError::column() const
+{
+ return d->column;
+}
+
+/*!
+ Set the error \a column number.
+*/
+void QmlError::setColumn(int column)
+{
+ d->column = column;
+}
+
+/*!
+ \relates QmlError
+ \fn QDebug operator<<(QDebug debug, const QmlError &error)
+
+ Output a human readable version of \a error to \a debug.
+*/
+
+QDebug operator<<(QDebug debug, const QmlError &error)
+{
+ QUrl url = error.url();
+
+ QString output;
+
+ output = url.toString() + QLatin1String(":") +
+ QString::number(error.line());
+
+ if(error.column() != -1)
+ output += QLatin1String(":") + QString::number(error.column());
+
+ output += QLatin1String(": ") + error.description();
+
+ debug << qPrintable(output) << "\n";
+
+ if (error.line() > 0 && error.column() > 0 &&
+ url.scheme() == QLatin1String("file")) {
+ QString file = url.toLocalFile();
+ QFile f(file);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QTextStream stream(data, QIODevice::ReadOnly);
+ const QString code = stream.readAll();
+ const QStringList lines = code.split(QLatin1Char('\n'));
+
+ if (lines.count() >= error.line()) {
+ const QString &line = lines.at(error.line() - 1);
+ debug << qPrintable(line) << "\n";
+
+ int column = qMax(0, error.column() - 1);
+ column = qMin(column, line.length());
+
+ QByteArray ind;
+ ind.reserve(column);
+ for (int i = 0; i < column; ++i) {
+ const QChar ch = line.at(i);
+ if (ch.isSpace())
+ ind.append(ch.unicode());
+ else
+ ind.append(' ');
+ }
+ ind.append('^');
+ debug << ind.constData();
+ }
+ }
+ }
+ return debug;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlxmlparser_p.h b/src/declarative/qml/qmlerror.h
index 9b45e28..57d2f8f 100644
--- a/src/declarative/qml/qmlxmlparser_p.h
+++ b/src/declarative/qml/qmlerror.h
@@ -39,12 +39,11 @@
**
****************************************************************************/
-#ifndef QMLXMLPARSER_P_H
-#define QMLXMLPARSER_P_H
+#ifndef QMLERROR_H
+#define QMLERROR_H
-#include <QList>
-#include <QUrl>
-#include <qml.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
QT_BEGIN_HEADER
@@ -52,38 +51,32 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-namespace QmlParser {
- class Object;
-}
-
-class QByteArray;
-class QmlXmlParser
+class QDebug;
+class QmlErrorPrivate;
+class Q_DECLARATIVE_EXPORT QmlError
{
public:
- QmlXmlParser();
- ~QmlXmlParser();
-
- bool parse(const QByteArray &data, const QUrl &url=QUrl());
- QString errorDescription() const;
-
- QMap<QString,QString> nameSpacePaths() const;
- QStringList types() const;
-
- QmlParser::Object *tree() const;
- QmlParser::Object *takeTree();
-
- void clear();
-
+ QmlError();
+ QmlError(const QmlError &);
+ QmlError &operator=(const QmlError &);
+ ~QmlError();
+
+ QUrl url() const;
+ void setUrl(const QUrl &);
+ QString description() const;
+ void setDescription(const QString &);
+ int line() const;
+ void setLine(int);
+ int column() const;
+ void setColumn(int);
private:
- QMap<QString,QString> _nameSpacePaths;
- QmlParser::Object *root;
- QStringList _typeNames;
- QString _error;
+ QmlErrorPrivate *d;
};
+QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, const QmlError &error);
+
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QMLXMLPARSER_P_H
-
+#endif // QMLERROR_H
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index 82924c8..0617913 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -58,9 +58,6 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::CreateObject:
qWarning() << idx << "\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
break;
- case QmlInstruction::CreateCustomObject:
- qWarning() << idx << "\t" << line << "\t" << "CREATE_CUSTOM\t\t" << instr->createCustom.type << "\t" << instr->createCustom.data << "\t\t" << types.at(instr->create.type).className;
- break;
case QmlInstruction::SetId:
qWarning() << idx << "\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t" << instr->setId.save << "\t\t" << primitives.at(instr->setId.value);
break;
@@ -71,7 +68,7 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
qWarning() << idx << "\t" << line << "\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
break;
case QmlInstruction::StoreMetaObject:
- qWarning() << idx << "\t" << line << "\t" << "STORE_META\t\t" << instr->storeMeta.data;
+ qWarning() << idx << "\t" << line << "\t" << "STORE_META\t\t" << instr->storeMeta.data << "\t" << instr->storeMeta.slotData;
break;
case QmlInstruction::StoreReal:
qWarning() << idx << "\t" << line << "\t" << "STORE_REAL\t\t" << instr->storeReal.propertyIndex << "\t" << instr->storeReal.value;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 922fc61..01bdfdd 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -63,7 +63,6 @@ public:
// top of the stack.
Init, /* init */
CreateObject, /* create */
- CreateCustomObject, /* createCustom */
SetId, /* setId */
SetDefault,
CreateComponent, /* createComponent */
@@ -178,12 +177,9 @@ public:
} create;
struct {
int data;
+ int slotData;
} storeMeta;
struct {
- int type;
- int data;
- } createCustom;
- struct {
int value;
int save;
} setId;
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index ecb6f0b..a943c4d 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -63,8 +63,7 @@ QT_BEGIN_NAMESPACE
using namespace QmlParser;
QmlParser::Object::Object()
-: type(-1), metatype(0), extObject(0), defaultProperty(0), line(-1),
- dynamicPropertiesProperty(0), dynamicSignalsProperty(0)
+: type(-1), metatype(0), extObject(0), defaultProperty(0), line(-1), column(-1)
{
}
@@ -73,8 +72,6 @@ QmlParser::Object::~Object()
if (defaultProperty) defaultProperty->release();
foreach(Property *prop, properties)
prop->release();
- if (dynamicPropertiesProperty) dynamicPropertiesProperty->release();
- if (dynamicSignalsProperty) dynamicSignalsProperty->release();
}
const QMetaObject *Object::metaObject() const
@@ -126,13 +123,22 @@ QmlParser::Object::DynamicSignal::DynamicSignal(const DynamicSignal &o)
{
}
+QmlParser::Object::DynamicSlot::DynamicSlot()
+{
+}
+
+QmlParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o)
+: name(o.name), body(o.body)
+{
+}
+
QmlParser::Property::Property()
-: type(0), index(-1), value(0), isDefault(true), line(-1)
+: type(0), index(-1), value(0), isDefault(true), line(-1), column(-1)
{
}
QmlParser::Property::Property(const QByteArray &n)
-: type(0), index(-1), value(0), name(n), isDefault(false), line(-1)
+: type(0), index(-1), value(0), name(n), isDefault(false), line(-1), column(-1)
{
}
@@ -161,7 +167,7 @@ void QmlParser::Property::addValue(Value *v)
}
QmlParser::Value::Value()
-: type(Unknown), object(0), line(-1)
+: type(Unknown), object(0), line(-1), column(-1)
{
}
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index e29cdbf..676e25e 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -103,6 +103,7 @@ namespace QmlParser
QHash<QByteArray, Property *> properties;
qint64 line;
+ qint64 column;
struct DynamicProperty {
DynamicProperty();
@@ -122,15 +123,20 @@ namespace QmlParser
QByteArray name;
};
+ struct DynamicSlot {
+ DynamicSlot();
+ DynamicSlot(const DynamicSlot &);
- // The "properties" property
- Property *dynamicPropertiesProperty;
- // The "signals" property
- Property *dynamicSignalsProperty;
- // The list of dynamic properties described in the "properties" property
+ QByteArray name;
+ QString body;
+ };
+
+ // The list of dynamic properties
QList<DynamicProperty> dynamicProperties;
- // The list of dynamic signals described in the "signals" property
+ // The list of dynamic signals
QList<DynamicSignal> dynamicSignals;
+ // The list of dynamic slots
+ QList<DynamicSlot> dynamicSlots;
};
class Value : public QmlRefCount
@@ -167,6 +173,7 @@ namespace QmlParser
Object *object;
qint64 line;
+ qint64 column;
};
class Property : public QmlRefCount
@@ -197,6 +204,7 @@ namespace QmlParser
bool isDefault;
qint64 line;
+ qint64 column;
};
}
diff --git a/src/declarative/qml/qmlparserstatus.cpp b/src/declarative/qml/qmlparserstatus.cpp
index 1f49553..71b7adf 100644
--- a/src/declarative/qml/qmlparserstatus.cpp
+++ b/src/declarative/qml/qmlparserstatus.cpp
@@ -49,6 +49,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ Destroys the parser status instance.
+*/
+QmlParserStatus::~QmlParserStatus()
+{
+}
+
+/*!
Invoked after class creation, but before any properties have been set.
*/
void QmlParserStatus::classBegin()
diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h
index 1ec50ba..bb3691c 100644
--- a/src/declarative/qml/qmlparserstatus.h
+++ b/src/declarative/qml/qmlparserstatus.h
@@ -53,7 +53,7 @@ QT_MODULE(Declarative)
class Q_DECLARATIVE_EXPORT QmlParserStatus
{
public:
- virtual ~QmlParserStatus() {}
+ virtual ~QmlParserStatus();
virtual void classBegin();
virtual void classComplete();
diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp
index 78b0495..44e1952 100644
--- a/src/declarative/qml/qmlpropertyvaluesource.cpp
+++ b/src/declarative/qml/qmlpropertyvaluesource.cpp
@@ -50,6 +50,9 @@ QT_BEGIN_NAMESPACE
*/
QML_DEFINE_NOCREATE_TYPE(QmlPropertyValueSource);
+/*!
+ Constructs a QmlPropertyValueSource with parent \a parent.
+*/
QmlPropertyValueSource::QmlPropertyValueSource(QObject *parent)
: QObject(parent)
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 8039b5c..22ff4a5 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -1,6 +1,5 @@
#include "qmlscriptparser_p.h"
-#include "qmlxmlparser_p.h"
#include "qmlparser_p.h"
#include "parser/javascriptengine_p.h"
@@ -65,10 +64,12 @@ protected:
Object *defineObjectBinding(int line,
AST::UiQualifiedId *propertyName,
const QString &objectType,
+ AST::SourceLocation typeLocation,
AST::UiObjectInitializer *initializer = 0);
Object *defineObjectBinding_helper(int line,
AST::UiQualifiedId *propertyName,
const QString &objectType,
+ AST::SourceLocation typeLocation,
AST::UiObjectInitializer *initializer = 0);
QString getPrimitive(const QByteArray &propertyName, AST::ExpressionNode *expr);
void defineProperty(const QString &propertyName, int line, const QString &primitive);
@@ -194,11 +195,17 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
Object *ProcessAST::defineObjectBinding_helper(int line,
AST::UiQualifiedId *propertyName,
const QString &objectType,
+ AST::SourceLocation typeLocation,
AST::UiObjectInitializer *initializer)
{
bool isType = !objectType.isEmpty() && objectType.at(0).isUpper() && !objectType.contains(QLatin1Char('.'));
+
if (!isType) {
- qWarning() << "bad name for a class"; // ### FIXME
+ QmlError error;
+ error.setDescription("Expected type name");
+ error.setLine(typeLocation.startLine);
+ error.setColumn(typeLocation.startColumn);
+ _parser->_errors << error;
return false;
}
@@ -235,7 +242,7 @@ Object *ProcessAST::defineObjectBinding_helper(int line,
if (!_parser->scriptFile().isEmpty()) {
_stateStack.pushObject(obj);
- Object *scriptObject= defineObjectBinding(line, 0, QLatin1String("Script"));
+ Object *scriptObject= defineObjectBinding(line, 0, QLatin1String("Script"), AST::SourceLocation());
_stateStack.pushObject(scriptObject);
defineProperty(QLatin1String("src"), line, _parser->scriptFile());
_stateStack.pop(); // scriptObject
@@ -264,11 +271,12 @@ Object *ProcessAST::defineObjectBinding_helper(int line,
Object *ProcessAST::defineObjectBinding(int line,
AST::UiQualifiedId *qualifiedId,
const QString &objectType,
+ AST::SourceLocation typeLocation,
AST::UiObjectInitializer *initializer)
{
if (objectType == QLatin1String("Connection")) {
- Object *obj = defineObjectBinding_helper(line, 0, QLatin1String("Connection"));
+ Object *obj = defineObjectBinding_helper(line, 0, objectType, typeLocation);
_stateStack.pushObject(obj);
@@ -297,7 +305,7 @@ Object *ProcessAST::defineObjectBinding(int line,
return obj;
}
- return defineObjectBinding_helper(line, qualifiedId, objectType, initializer);
+ return defineObjectBinding_helper(line, qualifiedId, objectType, typeLocation, initializer);
}
void ProcessAST::defineProperty(const QString &propertyName, int line, const QString &primitive)
@@ -372,7 +380,11 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
}
if(!typeFound) {
- qWarning() << "Unknown property type" << memberType; // ### FIXME
+ QmlError error;
+ error.setDescription("Expected property type");
+ error.setLine(node->typeToken.startLine);
+ error.setColumn(node->typeToken.startColumn);
+ _parser->_errors << error;
return false;
}
@@ -402,6 +414,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node)
defineObjectBinding(node->identifierToken.startLine,
0,
node->name->asString(),
+ node->identifierToken,
node->initializer);
return false;
@@ -414,6 +427,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node)
defineObjectBinding(node->identifierToken.startLine,
node->qualifiedId,
node->name->asString(),
+ node->identifierToken,
node->initializer);
return false;
@@ -476,7 +490,8 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
Value *v = new Value;
v->primitive = primitive;
- v->line = node->colonToken.startLine;
+ v->line = node->statement->firstSourceLocation().startLine;
+ v->column = node->statement->firstSourceLocation().startColumn;
prop->addValue(v);
while (propertyCount--)
@@ -506,27 +521,54 @@ bool ProcessAST::visit(AST::UiArrayBinding *node)
bool ProcessAST::visit(AST::UiSourceElement *node)
{
QmlParser::Object *obj = currentObject();
- if (! (obj && obj->typeName == "Script")) {
- // ### warning
- return false;
- }
- QString source;
+ bool isScript = (obj && obj->typeName == "Script");
- int line = 0;
- if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
- line = funDecl->functionToken.startLine;
- source = asString(funDecl);
- } else if (AST::VariableStatement *varStmt = AST::cast<AST::VariableStatement *>(node->sourceElement)) {
- // ignore variable declarations
- line = varStmt->declarationKindToken.startLine;
- }
+ if (!isScript) {
- Value *value = new Value;
- value->primitive = source;
- value->line = line;
+ if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+
+ if(funDecl->formals) {
+ QmlError error;
+ error.setDescription("Slot declarations must be parameterless");
+ error.setLine(funDecl->lparenToken.startLine);
+ error.setColumn(funDecl->lparenToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+
+ QString body = textAt(funDecl->lbraceToken, funDecl->rbraceToken);
+ Object::DynamicSlot slot;
+ slot.name = funDecl->name->asString().toUtf8();
+ slot.body = body;
+ obj->dynamicSlots << slot;
+ } else {
+ QmlError error;
+ error.setDescription("JavaScript declaration outside Script element");
+ error.setLine(node->firstSourceLocation().startLine);
+ error.setColumn(node->firstSourceLocation().startColumn);
+ _parser->_errors << error;
+ }
+ return false;
+
+ } else {
+ QString source;
+
+ int line = 0;
+ if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+ line = funDecl->functionToken.startLine;
+ source = asString(funDecl);
+ } else if (AST::VariableStatement *varStmt = AST::cast<AST::VariableStatement *>(node->sourceElement)) {
+ // ignore variable declarations
+ line = varStmt->declarationKindToken.startLine;
+ }
- obj->getDefaultProperty()->addValue(value);
+ Value *value = new Value;
+ value->primitive = source;
+ value->line = line;
+
+ obj->getDefaultProperty()->addValue(value);
+ }
return false;
}
@@ -535,7 +577,7 @@ bool ProcessAST::visit(AST::UiSourceElement *node)
QmlScriptParser::QmlScriptParser()
- : root(0), _errorLine(-1)
+: root(0)
{
}
@@ -546,21 +588,6 @@ QmlScriptParser::~QmlScriptParser()
bool QmlScriptParser::parse(const QByteArray &data, const QUrl &url)
{
- if (QmlComponentPrivate::isXml(data)) {
- // parse using the XML parser.
- QmlXmlParser xmlParser;
- if (xmlParser.parse(data, url)) {
- _nameSpacePaths = xmlParser.nameSpacePaths();
- root = xmlParser.takeTree();
- _typeNames = xmlParser.types();
- return true;
- }
-
- _error = xmlParser.errorDescription();
- _errorLine = 0; // ### FIXME
- return false;
- }
-
const QString fileName = url.toString();
QTextStream stream(data, QIODevice::ReadOnly);
@@ -576,61 +603,34 @@ bool QmlScriptParser::parse(const QByteArray &data, const QUrl &url)
lexer.setCode(code, /*line = */ 1);
driver.setLexer(&lexer);
- if (! parser.parse(&driver)) {
- _error = parser.errorMessage();
- _errorLine = parser.errorLineNumber();
-
- const QStringList lines = code.split(QLatin1Char('\n'));
+ if (! parser.parse(&driver) || !_errors.isEmpty()) {
+ // Extract errors from the parser
foreach (const JavaScriptParser::DiagnosticMessage &m, parser.diagnosticMessages()) {
if (m.isWarning())
continue;
- qWarning().nospace() << qPrintable(fileName) << ":"
- << m.line << ":"
- << m.column << ": "
- << "error: "
- << qPrintable(m.message);
-
- const QString textLine = lines.at(m.line - 1);
-
- qWarning() << qPrintable(textLine);
+ QmlError error;
+ error.setUrl(url);
+ error.setDescription(m.message);
+ error.setLine(m.line);
+ error.setColumn(m.column);
+ _errors << error;
- int column = qMax(0, m.column - 1);
- column = qMin(column, textLine.length()); // paranoia check
-
- QByteArray ind;
- ind.reserve(column);
-
- for (int i = 0; i < column; ++i) {
- const QChar ch = textLine.at(i);
- if (ch.isSpace())
- ind.append(ch.unicode());
- else
- ind.append(' ');
- }
- ind.append('^');
- qWarning() << ind.constData();
}
-
- return false;
}
- ProcessAST process(this);
- process(code, parser.ast());
+ if (_errors.isEmpty()) {
+ ProcessAST process(this);
+ process(code, parser.ast());
- return true;
-}
-
-QString QmlScriptParser::errorDescription() const
-{
- return _error;
-}
+ // Set the url for process errors
+ for(int ii = 0; ii < _errors.count(); ++ii)
+ _errors[ii].setUrl(url);
+ }
-int QmlScriptParser::errorLine() const
-{
- return _errorLine;
+ return _errors.isEmpty();
}
QMap<QString,QString> QmlScriptParser::nameSpacePaths() const
@@ -648,6 +648,11 @@ Object *QmlScriptParser::tree() const
return root;
}
+QList<QmlError> QmlScriptParser::errors() const
+{
+ return _errors;
+}
+
void QmlScriptParser::clear()
{
if (root) {
@@ -656,9 +661,8 @@ void QmlScriptParser::clear()
}
_nameSpacePaths.clear();
_typeNames.clear();
- _error.clear();
+ _errors.clear();
_scriptFile.clear();
- _errorLine = 0;
}
int QmlScriptParser::findOrCreateTypeId(const QString &name)
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
index 0d89268..4155bba 100644
--- a/src/declarative/qml/qmlscriptparser_p.h
+++ b/src/declarative/qml/qmlscriptparser_p.h
@@ -3,6 +3,7 @@
#include <QtCore/QList>
#include <QtCore/QUrl>
+#include <QtDeclarative/qmlerror.h>
#include <qml.h>
QT_BEGIN_HEADER
@@ -23,8 +24,6 @@ public:
~QmlScriptParser();
bool parse(const QByteArray &data, const QUrl &url = QUrl());
- QString errorDescription() const;
- int errorLine() const;
QMap<QString,QString> nameSpacePaths() const;
QStringList types() const;
@@ -33,6 +32,8 @@ public:
void clear();
+ QList<QmlError> errors() const;
+
// ### private:
int findOrCreateTypeId(const QString &name);
void setTree(QmlParser::Object *tree);
@@ -42,12 +43,12 @@ public:
void addNamespacePath(const QString &path);
-private:
+// ### private:
+ QList<QmlError> _errors;
+
QMap<QString,QString> _nameSpacePaths;
QmlParser::Object *root;
QStringList _typeNames;
- QString _error;
- int _errorLine;
QString _scriptFile;
};
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index e6235e4..ee7a881 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -176,9 +176,14 @@ QmlVME::QmlVME()
#define VME_EXCEPTION(desc) \
{ \
- exceptionLine = instr.line; \
- QDebug d(&exceptionDescription); \
- d << desc; \
+ QString str; \
+ QDebug d(&str); \
+ d << desc; \
+ QmlError error; \
+ error.setDescription(str); \
+ error.setLine(instr.line); \
+ error.setUrl(comp->url); \
+ vmeErrors << error; \
break; \
}
@@ -224,6 +229,8 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QStack<QmlMetaProperty> pushedProperties;
QObject **savedObjects = 0;
+ vmeErrors.clear();
+
if (start == -1) start = 0;
if (count == -1) count = comp->bytecode.count();
@@ -270,27 +277,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
- case QmlInstruction::CreateCustomObject:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrCreateCustomObject> cc;
-#endif
- QVariant v =
- types.at(instr.createCustom.type).parser->create(datas.at(instr.createCustom.data));
- // XXX
- QObject *o = QmlMetaType::toQObject(v);
- if (!o)
- VME_EXCEPTION("Unable to create" << types.at(instr.create.type).className);
- QmlEngine::setContextForObject(o, QmlContext::activeContext());
-
- if (!stack.isEmpty()) {
- QObject *parent = stack.top();
- o->setParent(parent);
- }
- stack.push(o);
- }
- break;
-
case QmlInstruction::SetId:
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -334,7 +320,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QFxCompilerTimer<QFxCompiler::InstrStoreMetaObject> cc;
#endif
QObject *target = stack.top();
- new QmlVMEMetaObject(target, mos.at(instr.storeMeta.data), comp);
+ new QmlVMEMetaObject(target, mos.at(instr.storeMeta.data), &comp->primitives, instr.storeMeta.slotData, comp);
}
break;
@@ -1072,17 +1058,12 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
bool QmlVME::isError() const
{
- return exceptionLine != -1;
-}
-
-qint64 QmlVME::errorLine() const
-{
- return exceptionLine;
+ return !vmeErrors.isEmpty();
}
-QString QmlVME::errorDescription() const
+QList<QmlError> QmlVME::errors() const
{
- return exceptionDescription;
+ return vmeErrors;
}
void QmlVME::runStoreInstruction(QStack<QObject *> &stack,
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
index 2a3be06..86cd040 100644
--- a/src/declarative/qml/qmlvme_p.h
+++ b/src/declarative/qml/qmlvme_p.h
@@ -44,6 +44,7 @@
#include <QString>
#include <QStack>
+#include <qmlerror.h>
class QObject;
QT_BEGIN_NAMESPACE
@@ -60,13 +61,13 @@ public:
QObject *run(QmlContext *, QmlCompiledComponent *, int start = -1, int end = -1);
bool isError() const;
- qint64 errorLine() const;
- QString errorDescription() const;
+ QList<QmlError> errors() const;
private:
void runStoreInstruction(QStack<QObject *> &stack,
QmlInstruction &, QmlCompiledData *);
+ QList<QmlError> vmeErrors;
qint64 exceptionLine;
QString exceptionDescription;
};
diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp
index f7d2635..58708cf 100644
--- a/src/declarative/qml/qmlvmemetaobject.cpp
+++ b/src/declarative/qml/qmlvmemetaobject.cpp
@@ -44,13 +44,18 @@
#include <private/qmlrefcount_p.h>
#include <QColor>
#include <QDate>
+#include <QtCore/qlist.h>
+#include <QtCore/qdebug.h>
+#include <qmlexpression.h>
QT_BEGIN_NAMESPACE
QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
- const QMetaObject *other,
- QmlRefCount *rc)
-: object(obj), ref(rc)
+ const QMetaObject *other,
+ QList<QString> *strData,
+ int slotData,
+ QmlRefCount *rc)
+: object(obj), ref(rc), slotData(strData), slotDataIdx(slotData)
{
if (ref)
ref->addref();
@@ -64,6 +69,7 @@ QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
data = new QVariant[propertyCount() - baseProp];
vTypes.resize(propertyCount() - baseProp);
+ // ### Optimize
for (int ii = baseProp; ii < propertyCount(); ++ii) {
QMetaProperty prop = property(ii);
if ((int)prop.type() != -1) {
@@ -72,6 +78,23 @@ QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
vTypes.setBit(ii - baseProp, true);
}
}
+
+ baseSlot = -1;
+ slotCount = 0;
+ for (int ii = baseSig; ii < methodCount(); ++ii) {
+ QMetaMethod m = method(ii);
+ if (m.methodType() == QMetaMethod::Slot) {
+ if (baseSlot == -1)
+ baseSlot = ii;
+ } else {
+ if (baseSlot != -1) {
+ slotCount = ii - baseSlot;
+ break;
+ }
+ }
+ }
+ if(baseSlot != -1 && !slotCount)
+ slotCount = methodCount() - baseSlot;
}
QmlVMEMetaObject::~QmlVMEMetaObject()
@@ -83,58 +106,69 @@ QmlVMEMetaObject::~QmlVMEMetaObject()
int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
{
- if (id >= baseProp) {
- int propId = id - baseProp;
- bool needActivate = false;
+ if(c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) {
+ if (id >= baseProp) {
+ int propId = id - baseProp;
+ bool needActivate = false;
- if (vTypes.testBit(propId)) {
- if (c == QMetaObject::ReadProperty) {
- *reinterpret_cast<QVariant *>(a[0]) = data[propId];
- } else if (c == QMetaObject::WriteProperty) {
- needActivate =
- (data[propId] != *reinterpret_cast<QVariant *>(a[0]));
- data[propId] = *reinterpret_cast<QVariant *>(a[0]);
- }
- } else {
- if (c == QMetaObject::ReadProperty) {
- switch(data[propId].type()) {
- case QVariant::Int:
- *reinterpret_cast<int *>(a[0]) = data[propId].toInt();
- break;
- case QVariant::Bool:
- *reinterpret_cast<bool *>(a[0]) = data[propId].toBool();
- break;
- case QVariant::Double:
- *reinterpret_cast<double *>(a[0]) = data[propId].toDouble();
- break;
- case QVariant::String:
- *reinterpret_cast<QString *>(a[0]) = data[propId].toString();
- break;
- case QVariant::Color:
- *reinterpret_cast<QColor *>(a[0]) = data[propId].value<QColor>();
- break;
- case QVariant::Date:
- *reinterpret_cast<QDate *>(a[0]) = data[propId].toDate();
- break;
- default:
- qFatal("Unknown type");
- break;
+ if (vTypes.testBit(propId)) {
+ if (c == QMetaObject::ReadProperty) {
+ *reinterpret_cast<QVariant *>(a[0]) = data[propId];
+ } else if (c == QMetaObject::WriteProperty) {
+ needActivate =
+ (data[propId] != *reinterpret_cast<QVariant *>(a[0]));
+ data[propId] = *reinterpret_cast<QVariant *>(a[0]);
}
- } else if (c == QMetaObject::WriteProperty) {
+ } else {
+ if (c == QMetaObject::ReadProperty) {
+ switch(data[propId].type()) {
+ case QVariant::Int:
+ *reinterpret_cast<int *>(a[0]) = data[propId].toInt();
+ break;
+ case QVariant::Bool:
+ *reinterpret_cast<bool *>(a[0]) = data[propId].toBool();
+ break;
+ case QVariant::Double:
+ *reinterpret_cast<double *>(a[0]) = data[propId].toDouble();
+ break;
+ case QVariant::String:
+ *reinterpret_cast<QString *>(a[0]) = data[propId].toString();
+ break;
+ case QVariant::Color:
+ *reinterpret_cast<QColor *>(a[0]) = data[propId].value<QColor>();
+ break;
+ case QVariant::Date:
+ *reinterpret_cast<QDate *>(a[0]) = data[propId].toDate();
+ break;
+ default:
+ qFatal("Unknown type");
+ break;
+ }
+ } else if (c == QMetaObject::WriteProperty) {
- QVariant value = QVariant((QVariant::Type)data[propId].type(), a[0]);
- needActivate = (data[propId] != value);
- data[propId] = value;
+ QVariant value = QVariant((QVariant::Type)data[propId].type(), a[0]);
+ needActivate = (data[propId] != value);
+ data[propId] = value;
+ }
}
- }
- if (c == QMetaObject::WriteProperty && needActivate) {
- activate(object, baseSig + propId, 0);
- }
+ if (c == QMetaObject::WriteProperty && needActivate) {
+ activate(object, baseSig + propId, 0);
+ }
- return id;
- } else {
- return object->qt_metacall(c, id, a);
+ return id;
+ }
+ } else if(c == QMetaObject::InvokeMetaMethod) {
+ if(id >= baseSlot && id < (baseSlot + slotCount)) {
+ int idx = id - baseSlot + slotDataIdx;
+ QmlContext *ctxt = qmlContext(object);
+ QmlExpression expr(ctxt, slotData->at(idx), object);
+ expr.setTrackChange(false);
+ expr.value();
+ return id;
+ }
}
+
+ return object->qt_metacall(c, id, a);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h
index 3fb1c46..d8ed242 100644
--- a/src/declarative/qml/qmlvmemetaobject_p.h
+++ b/src/declarative/qml/qmlvmemetaobject_p.h
@@ -52,7 +52,7 @@ class QmlRefCount;
class QmlVMEMetaObject : public QAbstractDynamicMetaObject
{
public:
- QmlVMEMetaObject(QObject *, const QMetaObject *, QmlRefCount * = 0);
+ QmlVMEMetaObject(QObject *, const QMetaObject *, QList<QString> *, int slotData, QmlRefCount * = 0);
~QmlVMEMetaObject();
protected:
@@ -63,8 +63,12 @@ private:
QmlRefCount *ref;
int baseProp;
int baseSig;
+ int baseSlot;
+ int slotCount;
QVariant *data;
QBitArray vTypes;
+ QList<QString> *slotData;
+ int slotDataIdx;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlxmlparser.cpp b/src/declarative/qml/qmlxmlparser.cpp
deleted file mode 100644
index 35d2c0e..0000000
--- a/src/declarative/qml/qmlxmlparser.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlxmlparser_p.h"
-#include "qmlcustomparser_p.h"
-#include <qfxperf.h>
-#include <QXmlStreamReader>
-#include <QStack>
-#include "qmlparser_p.h"
-#include <private/qmlparser_p.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-using namespace QmlParser;
-
-struct QmlXmlParserState {
- QmlXmlParserState() : object(0), property(0) {}
- QmlXmlParserState(Object *o) : object(o), property(0) {}
- QmlXmlParserState(Object *o, Property *p) : object(o), property(p) {}
-
- Object *object;
- Property *property;
-};
-
-struct QmlXmlParserStateStack : public QStack<QmlXmlParserState>
-{
- void pushObject(Object *obj)
- {
- push(QmlXmlParserState(obj));
- }
-
- void pushProperty(const QString &name, int lineNumber)
- {
- const QmlXmlParserState &state = top();
- if (state.property) {
- QmlXmlParserState s(state.property->getValue(),
- state.property->getValue()->getProperty(name.toLatin1()));
- s.property->line = lineNumber;
- push(s);
- } else {
- QmlXmlParserState s(state.object,
- state.object->getProperty(name.toLatin1()));
- s.property->line = lineNumber;
- push(s);
- }
- }
-};
-
-QmlXmlParser::~QmlXmlParser()
-{
- if (root)
- root->release();
-}
-
-QmlXmlParser::QmlXmlParser()
-: root(0)
-{
-}
-
-static QString flatXml(QXmlStreamReader& reader)
-{
- QString result;
- int depth=0;
- QStringRef ns = reader.namespaceUri();
- while (depth>=0) {
- switch (reader.tokenType()) {
- case QXmlStreamReader::StartElement:
- result += QLatin1Char('<');
- result += reader.name();
- if (reader.namespaceUri() != ns || depth==0) {
- result += QLatin1String(" xmlns=\"");
- result += reader.namespaceUri();
- result += QLatin1Char('"');
- }
- foreach(QXmlStreamAttribute attr, reader.attributes()) {
- result += QLatin1Char(' ');
- result += attr.name();
- result += QLatin1String("=\"");
- result += attr.value(); // XXX escape
- result += QLatin1Char('"');
- }
- result += QLatin1Char('>');
- ++depth;
- break;
- case QXmlStreamReader::EndElement:
- result += QLatin1String("</");
- result += reader.name();
- result += QLatin1Char('>');
- --depth;
- break;
- case QXmlStreamReader::Characters:
- result += reader.text();
- break;
- default:
- reader.raiseError(QLatin1String("Only StartElement, EndElement, and Characters permitted"));
- break;
- }
- if (depth>=0)
- reader.readNext();
- }
- return result;
-}
-
-bool QmlXmlParser::parse(const QByteArray &data, const QUrl &url)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxPerfTimer<QFxPerf::XmlParsing> pt;
-#endif
-
- QString fileDisplayName;
- if (url.isEmpty()) {
- fileDisplayName = QLatin1String("<unspecified file>");
- } else if (url.scheme() == QLatin1String("file")) {
- fileDisplayName = url.toLocalFile();
- } else {
- fileDisplayName = url.toString();
- }
- if (data.isEmpty()) {
- _error = QLatin1String("No Qml was specified for parsing @") + fileDisplayName;
- return false;
- }
-
- QmlXmlParserStateStack states;
-
- QXmlStreamReader reader;
- reader.addData(data);
-
- while(!reader.atEnd()) {
- switch(reader.readNext()) {
- case QXmlStreamReader::Invalid:
- case QXmlStreamReader::NoToken:
- case QXmlStreamReader::StartDocument:
- case QXmlStreamReader::EndDocument:
- break;
-
- case QXmlStreamReader::StartElement:
- {
- QString name = reader.name().toString();
- QString nameSpace = reader.namespaceUri().toString();
- int line = reader.lineNumber();
- bool isType = name.at(0).isUpper() && !name.contains(QLatin1Char('.'));
- QString qualifiedname;
- if (!nameSpace.isEmpty()) {
- qualifiedname = nameSpace;
- qualifiedname += QLatin1Char('/');
- }
- qualifiedname += name;
- QByteArray qualifiednameL1 = qualifiedname.toLatin1();
- QXmlStreamAttributes attrs = reader.attributes();
-
- if (isType) {
- // Class
- int typeId = _typeNames.indexOf(qualifiedname);
- if (typeId == -1) {
- typeId = _typeNames.count();
- _typeNames.append(qualifiedname);
- }
-
- Object *obj = new Object;
- obj->type = typeId;
- obj->typeName = qualifiednameL1;
- obj->line = line;
-
- QmlCustomParser *customparser = QmlMetaType::customParser(qualifiednameL1);
- if (customparser) {
- bool ok;
- obj->custom = customparser->compile(reader, &ok);
- if (reader.tokenType() != QXmlStreamReader::EndElement) {
- reader.raiseError(QLatin1String("Parser for ") + qualifiedname + QLatin1String(" did not end on end element"));
- ok = false;
- }
- if (!ok) {
- delete obj;
- break;
- }
- }
-
-
- if (!root) {
- root = obj;
- states.pushObject(obj);
- } else {
- const QmlXmlParserState &state = states.top();
- Value *v = new Value;
- v->object = obj;
- v->line = line;
- if (state.property)
- state.property->addValue(v);
- else
- state.object->getDefaultProperty()->addValue(v);
- states.pushObject(obj);
- }
- } else {
- // Property
- if (!root) {
- reader.raiseError(QLatin1String("Can't have a property with no object"));
- break;
- }
- QStringList str = name.split(QLatin1Char('.'));
- for (int ii = 0; ii < str.count(); ++ii) {
- QString s = str.at(ii);
- states.pushProperty(s, line);
- }
- if (!nameSpace.isEmpty()) {
- // Pass non-QML as flat text property value
- const QmlXmlParserState &state = states.top();
- Value *v = new Value;
- v->primitive = flatXml(reader);
- v->line = line;
- state.property->addValue(v);
- }
- }
-
- // (even custom parsed content gets properties set)
- foreach(QXmlStreamAttribute attr, attrs) {
- QStringList str = attr.name().toString().split(QLatin1Char('.'));
-
- for (int ii = 0; ii < str.count(); ++ii) {
- QString s = str.at(ii);
- states.pushProperty(s, line);
- }
-
- const QmlXmlParserState &state = states.top();
- Value *v = new Value;
- v->primitive = attr.value().toString();
- v->line = reader.lineNumber();
- state.property->addValue(v);
-
- for (int ii = str.count() - 1; ii >= 0; --ii)
- states.pop();
- }
- }
-
- // Custom parsers and namespaced properties move
- // the reader to the end element, so we handle that
- // BEFORE continuing.
- //
- if (reader.tokenType()!=QXmlStreamReader::EndElement)
- break;
- // ELSE fallthrough to EndElement...
- case QXmlStreamReader::EndElement:
- {
- QString name = reader.name().toString();
- Q_ASSERT(!name.isEmpty());
- if (name.at(0).isUpper() && !name.contains(QLatin1Char('.'))) {
- // Class
- states.pop();
- } else {
- // Property
- QStringList str = name.split(QLatin1Char('.'));
- for (int ii = 0; ii < str.count(); ++ii)
- states.pop();
- }
- }
- break;
- case QXmlStreamReader::Characters:
- if (!reader.isWhitespace()) {
- const QmlXmlParserState &state = states.top();
- Value *v = new Value;
- v->primitive = reader.text().toString();
- v->line = reader.lineNumber();
- if (state.property)
- state.property->addValue(v);
- else
- state.object->getDefaultProperty()->addValue(v);
- }
- break;
-
- case QXmlStreamReader::Comment:
- case QXmlStreamReader::DTD:
- case QXmlStreamReader::EntityReference:
- break;
- case QXmlStreamReader::ProcessingInstruction:
- if (reader.processingInstructionTarget() == QLatin1String("qtfx")) {
- QString str = reader.processingInstructionData().toString();
- QString token, data;
- int idx = str.indexOf(QLatin1Char(':'));
- if (-1 != idx) {
- token = str.left(idx);
- data = str.mid(idx + 1);
- } else {
- token = str;
- }
- token = token.trimmed();
- data = data.trimmed();
-
- // <?qtfx namespacepath: namespace=path>
-
- if (token == QLatin1String("namespacepath")) {
- int eq=data.indexOf(QLatin1Char('='));
- if (eq>=0) {
- _nameSpacePaths.insertMulti(data.left(eq),data.mid(eq+1));
- }
- } else {
- str = str.trimmed();
- qWarning().nospace() << "Unknown processing instruction " << str.toLatin1().constData() << " @" << fileDisplayName.toLatin1().constData() << ":" << reader.lineNumber();
- }
- }
- break;
- }
- }
-
- if (reader.hasError()) {
- if (root) {
- root->release();
- root = 0;
- }
- _error = reader.errorString() + QLatin1String(" @") + fileDisplayName +
- QLatin1String(":") + QString::number(reader.lineNumber());
- }
-
- return root != 0;
-}
-
-QMap<QString,QString> QmlXmlParser::nameSpacePaths() const
-{
- return _nameSpacePaths;
-}
-
-QStringList QmlXmlParser::types() const
-{
- return _typeNames;
-}
-
-QmlParser::Object *QmlXmlParser::tree() const
-{
- return root;
-}
-
-QmlParser::Object *QmlXmlParser::takeTree()
-{
- QmlParser::Object *r = root;
- root = 0;
- return r;
-}
-
-QString QmlXmlParser::errorDescription() const
-{
- return _error;
-}
-
-void QmlXmlParser::clear()
-{
- if (root) {
- root->release();
- root = 0;
- }
- _nameSpacePaths.clear();
- _typeNames.clear();
- _error.clear();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index cac73a0..f71b87e 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -233,8 +233,6 @@ QmlContext* QFxView::rootContext()
*/
void QFxView::execute()
{
- rootContext()->activate();
-
if (d->qml.isEmpty()) {
d->component = new QmlComponent(&d->engine, d->source, this);
} else {
@@ -249,6 +247,45 @@ void QFxView::execute()
}
/*!
+ \internal
+*/
+void QFxView::printErrorLine(const QmlError &error)
+{
+ QUrl url = error.url();
+ if (error.line() > 0 && error.column() > 0 &&
+ url.scheme() == QLatin1String("file")) {
+ QString file = url.toLocalFile();
+ QFile f(file);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QTextStream stream(data, QIODevice::ReadOnly);
+ const QString code = stream.readAll();
+ const QStringList lines = code.split(QLatin1Char('\n'));
+
+ if (lines.count() >= error.line()) {
+ const QString &line = lines.at(error.line() - 1);
+ qWarning() << qPrintable(line);
+
+ int column = qMax(0, error.column() - 1);
+ column = qMin(column, line.length());
+
+ QByteArray ind;
+ ind.reserve(column);
+ for (int i = 0; i < column; ++i) {
+ const QChar ch = line.at(i);
+ if (ch.isSpace())
+ ind.append(ch.unicode());
+ else
+ ind.append(' ');
+ }
+ ind.append('^');
+ qWarning() << ind.constData();
+ }
+ }
+ }
+}
+
+/*!
\internal
*/
void QFxView::continueExecute()
@@ -260,8 +297,26 @@ void QFxView::continueExecute()
return;
}
+ if(d->component->isError()) {
+ QList<QmlError> errors = d->component->errors();
+ foreach (const QmlError &error, errors) {
+ qWarning() << error;
+ }
+
+ return;
+ }
+
QObject *obj = d->component->create();
- rootContext()->deactivate();
+
+ if(d->component->isError()) {
+ QList<QmlError> errors = d->component->errors();
+ foreach (const QmlError &error, errors) {
+ qWarning() << error;
+ }
+
+ return;
+ }
+
if (obj) {
if (QFxItem *item = qobject_cast<QFxItem *>(obj)) {
item->QSimpleCanvasItem::setParent(QSimpleCanvas::root());
@@ -330,7 +385,25 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
return 0;
QmlComponent component(&d->engine, qml.toUtf8(), QUrl());
+ if(d->component->isError()) {
+ QList<QmlError> errors = d->component->errors();
+ foreach (const QmlError &error, errors) {
+ qWarning() << error;
+ }
+
+ return 0;
+ }
+
QObject *obj = component.create();
+ if(d->component->isError()) {
+ QList<QmlError> errors = d->component->errors();
+ foreach (const QmlError &error, errors) {
+ qWarning() << error;
+ }
+
+ return 0;
+ }
+
if (obj){
QFxItem *item = static_cast<QFxItem *>(obj);
if (!parent)
diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h
index d2cacf4..f575f27 100644
--- a/src/declarative/util/qfxview.h
+++ b/src/declarative/util/qfxview.h
@@ -57,7 +57,7 @@ QT_MODULE(Declarative)
class QFxItem;
class QmlEngine;
class QmlContext;
-class Canvas;
+class QmlError;
class QFxViewPrivate;
class Q_DECLARATIVE_EXPORT QFxView : public QSimpleCanvas
@@ -84,6 +84,7 @@ public:
void dumpRoot();
+ static void printErrorLine(const QmlError &);
Q_SIGNALS:
void sceneResized(QSize size);
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 4837180..6ad0cb9 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -190,8 +190,6 @@ ModelObject::ModelObject(ModelNode *node)
{
}
-QML_DECLARE_TYPE(ListModel);
-QML_DEFINE_TYPE(ListModel,ListModel);
ListModel::ListModel(QObject *parent)
: QListModelInterface(parent), _rolesOk(false), _root(0)
{
@@ -304,14 +302,10 @@ int ListModel::count() const
class ListModelParser : public QmlCustomParser
{
public:
- virtual QByteArray compile(QXmlStreamReader& reader, bool *);
QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
- virtual QVariant create(const QByteArray &);
-
bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
void setCustomData(QObject *, const QByteArray &);
};
-QML_DEFINE_CUSTOM_PARSER(ListModel, ListModelParser);
bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
{
@@ -462,13 +456,10 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
}
}
-class ListModel2 : public ListModel
-{
-Q_OBJECT
-};
-QML_DECLARE_TYPE(ListModel2);
-QML_DEFINE_CUSTOM_TYPE(ListModel2, ListModel2, ListModelParser);
+QML_DECLARE_TYPE(ListModel);
+QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser);
+// ### FIXME
class ListElement : public QObject
{
Q_OBJECT
@@ -512,170 +503,5 @@ ModelNode::~ModelNode()
if (modelCache) { delete modelCache; modelCache = 0; }
}
-QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok)
-{
- *ok = true;
-
- QByteArray data;
- QList<ListInstruction> instr;
- int depth=0;
-
- while(!reader.atEnd() && depth >= 0) {
- switch(reader.readNext()) {
- case QXmlStreamReader::StartElement:
- {
- QStringRef name = reader.name();
- bool isType = name.at(0).isUpper();
-
- if (isType) {
- ListInstruction li;
- li.type = ListInstruction::Push;
- li.dataIdx = -1;
- instr << li;
-
- for (int i = 0; i < reader.attributes().count(); ++i) {
- const QXmlStreamAttribute &attr = reader.attributes().at(i);
- QStringRef attrName = attr.name();
- QStringRef attrValue = attr.value();
-
- ListInstruction li;
- int ref = data.count();
- data.append(attrName.toString().toLatin1());
- data.append('\0');
- li.type = ListInstruction::Set;
- li.dataIdx = ref;
- instr << li;
-
- ref = data.count();
- data.append(attrValue.toString().toLatin1());
- data.append('\0');
- li.type = ListInstruction::Value;
- li.dataIdx = ref;
- instr << li;
-
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
- } else {
- ListInstruction li;
- int ref = data.count();
- data.append(name.toString().toLatin1());
- data.append('\0');
- li.type = ListInstruction::Set;
- li.dataIdx = ref;
- instr << li;
- }
- }
- ++depth;
- break;
- case QXmlStreamReader::EndElement:
- {
- ListInstruction li;
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- --depth;
- }
- break;
- case QXmlStreamReader::Characters:
- if (!reader.isWhitespace()) {
- int ref = data.count();
- QByteArray d = reader.text().toString().toLatin1();
- d.append('\0');
- data.append(d);
-
- ListInstruction li;
- li.type = ListInstruction::Value;
- li.dataIdx = ref;
- instr << li;
- }
- break;
-
- case QXmlStreamReader::Invalid:
- case QXmlStreamReader::NoToken:
- case QXmlStreamReader::StartDocument:
- case QXmlStreamReader::EndDocument:
- case QXmlStreamReader::Comment:
- case QXmlStreamReader::DTD:
- case QXmlStreamReader::EntityReference:
- case QXmlStreamReader::ProcessingInstruction:
- break;
- }
- }
-
- if (reader.hasError())
- *ok = true;
-
- if (!*ok)
- return QByteArray();
-
- int size = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction) +
- data.count();
-
- QByteArray rv;
- rv.resize(size);
-
- ListModelData *lmd = (ListModelData *)rv.data();
- lmd->dataOffset = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction);
- lmd->instrCount = instr.count();
- for (int ii = 0; ii < instr.count(); ++ii)
- lmd->instructions()[ii] = instr.at(ii);
- ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
-
- return rv;
-}
-
-QVariant ListModelParser::create(const QByteArray &d)
-{
- ListModel *rv = new ListModel;
- ModelNode *root = new ModelNode;
- rv->_root = root;
- QStack<ModelNode *> nodes;
- nodes << root;
-
- const ListModelData *lmd = (const ListModelData *)d.constData();
- const char *data = ((const char *)lmd) + lmd->dataOffset;
-
- for (int ii = 0; ii < lmd->instrCount; ++ii) {
- const ListInstruction &instr = lmd->instructions()[ii];
-
- switch(instr.type) {
- case ListInstruction::Push:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode;
- n->values << qVariantFromValue(n2);
- nodes.push(n2);
- }
- break;
-
- case ListInstruction::Pop:
- nodes.pop();
- break;
-
- case ListInstruction::Value:
- {
- ModelNode *n = nodes.top();
- n->values.append(QByteArray(data + instr.dataIdx));
- }
- break;
-
- case ListInstruction::Set:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode;
- n->properties.insert(QLatin1String(data + instr.dataIdx), n2);
- nodes.push(n2);
- }
- break;
- }
- }
-
- return QVariant::fromValue(rv);
-}
-
QT_END_NAMESPACE
#include "qmllistmodel.moc"
diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp
index 4522807..802653a 100644
--- a/src/script/qscriptextqobject.cpp
+++ b/src/script/qscriptextqobject.cpp
@@ -736,7 +736,7 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType
meta->static_metacall(QMetaObject::CreateInstance, chosenIndex, params);
} else {
Q_ASSERT(thisQObject != 0);
- thisQObject->qt_metacall(QMetaObject::InvokeMetaMethod, chosenIndex, params);
+ QMetaObject::metacall(thisQObject, QMetaObject::InvokeMetaMethod, chosenIndex, params);
}
if (scriptable)