summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/declarativeui.qdoc3
-rw-r--r--doc/src/declarative/qmldebugging.qdoc16
-rw-r--r--doc/src/declarative/qmli18n.qdoc29
-rw-r--r--doc/src/index.qdoc2
-rw-r--r--examples/declarative/layouts/positioners.qml69
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp16
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp89
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp138
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h32
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp2
-rw-r--r--src/declarative/qml/qmlenginedebug_p.h2
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp3
-rw-r--r--src/declarative/util/qmllistmodel_p.h2
-rw-r--r--src/declarative/util/qmlstateoperations_p.h2
-rw-r--r--src/declarative/util/qmlxmllistmodel_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp1
-rw-r--r--src/script/api/qscriptengine.cpp7
-rw-r--r--tests/auto/declarative/anchors/data/centerin.qml12
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp16
-rw-r--r--tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp4
-rw-r--r--tests/auto/declarative/qmlqt/tst_qmlqt.cpp2
-rw-r--r--tests/auto/declarative/valuetypes/tst_valuetypes.cpp12
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml131
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml131
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml14
-rw-r--r--tests/benchmarks/declarative/creation/data/item.qml34
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp103
29 files changed, 782 insertions, 98 deletions
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 637e5f1..4d2b09c 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -40,7 +40,7 @@
****************************************************************************/
/*!
-\title Declarative UI
+\title Declarative UI (QML)
\page declarativeui.html
\brief The Qt Declarative module provides a declarative framework for building
@@ -102,5 +102,6 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\o \l {Extending QML}
\o \l {QML Internationalization}
\o \l {QtDeclarative Module}
+\o \l {Debugging QML}
\endlist
*/
diff --git a/doc/src/declarative/qmldebugging.qdoc b/doc/src/declarative/qmldebugging.qdoc
index 13ad5f7..a6def19 100644
--- a/doc/src/declarative/qmldebugging.qdoc
+++ b/doc/src/declarative/qmldebugging.qdoc
@@ -45,7 +45,7 @@
\section1 Logging
-console.log can be used to print debugging information to the console. For example:
+\c console.log can be used to print debugging information to the console. For example:
\qml
Rectangle {
@@ -57,6 +57,13 @@ Rectangle {
}
\endqml
+\section1 Debugging Transitions
+
+When a transition doesn't look quite right, it can be helpful to view it in slow
+motion to see what is happening more clearly. \l {qmlviewer} provides a
+"Slow Down Animations" menu option to facilitate this.
+
+
\section1 The QML Inspector
The \c qmldebugger tool provides an experimental inspector to aid with debugging.
@@ -110,11 +117,4 @@ to an available port number and run the \c qmlviewer. For example:
Then in another process, start the \c qmldebugger tool, enter the port number into the corresponding spinbox
in the top right hand corner, and press the "Connect" button.
-
-\section1 Debugging Transitions
-
-When a transition doesn't look quite right, it can be helpful to view it in slow
-motion to see more clearly what is happening. \l {qmlviewer} provides a menu option
-"Slow Down Animations" to facilitate this.
-
*/
diff --git a/doc/src/declarative/qmli18n.qdoc b/doc/src/declarative/qmli18n.qdoc
index 4b62fcb..0c8b1d1 100644
--- a/doc/src/declarative/qmli18n.qdoc
+++ b/doc/src/declarative/qmli18n.qdoc
@@ -43,6 +43,8 @@
\page qmli18n.html
\title QML Internationalization
+\section1 Overview
+
Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
@@ -63,4 +65,31 @@ capabilities are described more fully in:
You can test a translation in \l {qmlviewer} using the -translation option.
+\section1 Example
+
+First we create a simple QML file with text to be translated. The string
+that needs to be translated is enclosed in a call to \c qsTr().
+
+hello.qml:
+\qml
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Text { text: qsTr("Hello"); anchors.centerIn: parent }
+}
+\endqml
+
+Next we create a translation source file using lupdate:
+\code
+lupdate hello.qml -ts hello.ts
+\endcode
+
+Then we open \c hello.ts in \l {Linguist}, provide a translation
+and create the release file \c hello.qm.
+
+Finally, we can test the translation in qmlviewer:
+\code
+qmlviewer -translation hello.qm hello.qml
+\endcode
*/
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc
index 762a900..c3c1701 100644
--- a/doc/src/index.qdoc
+++ b/doc/src/index.qdoc
@@ -103,7 +103,7 @@
<li><a href="paintsystem.html">Painting and Printing</a></li>
<li><a href="graphicsview.html">Canvas UI with Graphics View</a></li>
<li><a href="webintegration.html">Integrating Web Content</a></li>
- <li><a href="declarativeui.html">Declarative UI</a></li>
+ <li><a href="declarativeui.html">Declarative UI (QML)</a></li>
</ul>
</td>
<td valign="top">
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
index e912632..46762f7 100644
--- a/examples/declarative/layouts/positioners.qml
+++ b/examples/declarative/layouts/positioners.qml
@@ -16,12 +16,7 @@ Rectangle {
}
add: Transition {
NumberAnimation {
- matchProperties: "y"; from: 500; duration:500; easing: "easeOutQuad"
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties:"y"; to: 500; duration:500; easing: "easeInQuad"
+ matchProperties: "y"; easing: "easeOutQuad"
}
}
Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
@@ -45,12 +40,7 @@ Rectangle {
}
add: Transition {
NumberAnimation {
- matchProperties: "x"; from: 500; duration:500; easing: "easeOutQuad"
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "x"; to: 500; duration:500; easing: "easeInQuad"
+ matchProperties: "x"; easing: "easeOutQuad"
}
}
Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
@@ -78,6 +68,9 @@ Rectangle {
blueG1.opacity = 0
blueG2.opacity = 0
blueG3.opacity = 0
+ blueF1.opacity = 0
+ blueF2.opacity = 0
+ blueF3.opacity = 0
}
}
@@ -95,6 +88,9 @@ Rectangle {
blueG1.opacity = 1
blueG2.opacity = 1
blueG3.opacity = 1
+ blueF1.opacity = 1
+ blueF2.opacity = 1
+ blueF3.opacity = 1
}
}
@@ -103,12 +99,41 @@ Rectangle {
y: 0
columns: 3
- remove: Transition {
+ move: Transition {
+ NumberAnimation {
+ matchProperties: "x,y"; easing: "easeOutBounce"
+ }
+ }
+
+ add: Transition {
NumberAnimation {
matchProperties: "x,y"; easing: "easeOutBounce"
}
}
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ opacity: Behavior{NumberAnimation{}}
+ }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ opacity: Behavior{NumberAnimation{}}
+ }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ opacity: Behavior{NumberAnimation{}}
+ }
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Flow {
+ id: layout4
+ x: 260
+ y: 250
+ width: 150
+
move: Transition {
NumberAnimation {
matchProperties: "x,y"; easing: "easeOutBounce"
@@ -120,21 +145,19 @@ Rectangle {
matchProperties: "x,y"; easing: "easeOutBounce"
}
}
-
- Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF1; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
opacity: Behavior{NumberAnimation{}}
}
- Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15
+ Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF2; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
opacity: Behavior{NumberAnimation{}}
}
- Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF3; color: "lightsteelblue"; width: 40; height: 50; border.color: "black"; radius: 15
opacity: Behavior{NumberAnimation{}}
}
- Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
- Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 }
}
+
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index c838d7d..b72f010 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -183,14 +183,14 @@ void QmlGraphicsAnchorsPrivate::centerInChanged()
++updatingCenterIn;
if (centerIn == item->parentItem()) {
- QPointF p((item->parentItem()->width() - item->width()) / 2.,
- (item->parentItem()->height() - item->height()) / 2.);
+ QPointF p((item->parentItem()->width() - item->width()) / 2. + hCenterOffset,
+ (item->parentItem()->height() - item->height()) / 2. + vCenterOffset);
setItemPos(p);
} else if (centerIn->parentItem() == item->parentItem()) {
- QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2.,
- centerIn->y() + (centerIn->height() - item->height()) / 2.);
+ QPointF p(centerIn->x() + (centerIn->width() - item->width()) / 2. + hCenterOffset,
+ centerIn->y() + (centerIn->height() - item->height()) / 2. + vCenterOffset);
setItemPos(p);
}
@@ -495,8 +495,12 @@ void QmlGraphicsAnchorsPrivate::updateVerticalAnchors()
}
} else if (usedAnchors & QmlGraphicsAnchors::HasBaselineAnchor) {
//Handle baseline
- if (baseline.item->parentItem() == item->parentItem()) {
- setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset() + baselineOffset);
+ if (baseline.item == item->parentItem()) {
+ setItemY(adjustedPosition(baseline.item, baseline.anchorLine)
+ - item->baselineOffset() + baselineOffset);
+ } else if (baseline.item->parentItem() == item->parentItem()) {
+ setItemY(position(baseline.item, baseline.anchorLine)
+ - item->baselineOffset() + baselineOffset);
}
}
--updatingVerticalAnchor;
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
index a8d77ea..304e36c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
@@ -58,8 +58,8 @@
#include "qmlgraphicsanchors_p.h"
#include "qmlgraphicsanchors_p_p.h"
-#include <qmlstate_p.h>
-#include <qmlnullablevalue_p_p.h>
+#include "../util/qmlstate_p.h"
+#include "../util/qmlnullablevalue_p_p.h"
#include <qml.h>
#include <qmlcontext.h>
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 135262c..a4fa07a 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -182,7 +182,7 @@ public:
, snapMode(QmlGraphicsListView::NoSnap), overshootDist(0.0)
, footerComponent(0), footer(0), headerComponent(0), header(0)
, ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
- , correctFlick(true), lazyRelease(false)
+ , correctFlick(true), inFlickCorrection(false), lazyRelease(false)
{}
void init();
@@ -322,8 +322,7 @@ public:
if (item->index == -1)
continue;
qreal itemTop = item->position();
- if ((item->index == model->count()-1 || itemTop >= pos-item->size()/2)
- && (item->index == 0 || itemTop <= pos+item->size()/2))
+ if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
return item->position();
}
if (visibleItems.count()) {
@@ -343,8 +342,7 @@ public:
if (item->index == -1)
continue;
qreal itemTop = item->position();
- if ((item->index == model->count()-1 || itemTop >= pos-item->size()/2)
- && (item->index == 0 || itemTop <= pos+item->size()/2))
+ if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
return item;
}
if (visibleItems.count() && visibleItems.first()->position() <= pos)
@@ -483,6 +481,7 @@ public:
bool autoHighlight : 1;
bool haveHighlightRange : 1;
bool correctFlick : 1;
+ bool inFlickCorrection : 1;
bool lazyRelease : 1;
static int itemResizedIdx;
@@ -1076,14 +1075,11 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
accel = v2 / (2.0f * qAbs(dist));
overshootDist = 0.0;
} else {
- if (velocity > 0)
- flickTargetX = minX;
- else
- flickTargetX = maxX;
+ flickTargetX = velocity > 0 ? minX : maxX;
overshootDist = overShoot ? 30 : 0;
}
timeline.reset(_moveX);
- timeline.accel(_moveX, v, accel, maxDistance);
+ timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
timeline.execute(fixupXEvent);
flicked = true;
emit q->flickingChanged();
@@ -1091,14 +1087,15 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
correctFlick = true;
} else {
// reevaluate the target boundary.
- qreal newtarget = -snapPosAt(-(flickTargetX - highlightRangeStart)) + highlightRangeStart;
- if (newtarget < maxX) {
+ qreal newtarget = flickTargetX;
+ if (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)
+ newtarget = -snapPosAt(-(flickTargetX - highlightRangeStart)) + highlightRangeStart;
+ if (velocity < 0 && newtarget < maxX)
newtarget = maxX;
- }
- if (newtarget == flickTargetX) {
- // boundary unchanged - nothing to do
+ else if (velocity > 0 && newtarget > minX)
+ newtarget = minX;
+ if (newtarget == flickTargetX) // boundary unchanged - nothing to do
return;
- }
flickTargetX = newtarget;
qreal dist = -newtarget + _moveX.value();
if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
@@ -1175,14 +1172,11 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
accel = v2 / (2.0f * qAbs(dist));
overshootDist = 0.0;
} else {
- if (velocity > 0)
- flickTargetY = minY;
- else
- flickTargetY = maxY;
+ flickTargetY = velocity > 0 ? minY : maxY;
overshootDist = overShoot ? 30 : 0;
}
timeline.reset(_moveY);
- timeline.accel(_moveY, v, accel, maxDistance);
+ timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
timeline.execute(fixupYEvent);
flicked = true;
emit q->flickingChanged();
@@ -1190,14 +1184,15 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
correctFlick = true;
} else {
// reevaluate the target boundary.
- qreal newtarget = -snapPosAt(-(flickTargetY - highlightRangeStart)) + highlightRangeStart;
- if (newtarget < maxY) {
+ qreal newtarget = flickTargetY;
+ if (snapMode != QmlGraphicsListView::NoSnap || highlightRange == QmlGraphicsListView::StrictlyEnforceRange)
+ newtarget = -snapPosAt(-(flickTargetY - highlightRangeStart)) + highlightRangeStart;
+ if (velocity < 0 && newtarget < maxY)
newtarget = maxY;
- }
- if (newtarget == flickTargetY) {
- // boundary unchanged - nothing to do
+ else if (velocity > 0 && newtarget > minY)
+ newtarget = minY;
+ if (newtarget == flickTargetY) // boundary unchanged - nothing to do
return;
- }
flickTargetY = newtarget;
qreal dist = -newtarget + _moveY.value();
if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
@@ -1919,24 +1914,38 @@ void QmlGraphicsListView::viewportMoved()
}
}
- if (d->flicked && d->correctFlick) {
+ if (d->flicked && d->correctFlick && !d->inFlickCorrection) {
+ d->inFlickCorrection = true;
// Near an end and it seems that the extent has changed?
// Recalculate the flick so that we don't end up in an odd position.
- if (d->velocityY > 0) {
- if (d->flickTargetY - d->_moveY.value() < height()/2 && minYExtent() != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
- } else if (d->velocityY < 0) {
- if (d->_moveY.value() - d->flickTargetY < height()/2 && maxYExtent() != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
+ if (yflick()) {
+ if (d->velocityY > 0) {
+ const qreal minY = minYExtent();
+ if ((minY - d->_moveY.value() < height()/2 || d->flickTargetY - d->_moveY.value() < height()/2)
+ && minY != d->flickTargetY)
+ d->flickY(-d->verticalVelocity.value());
+ } else if (d->velocityY < 0) {
+ const qreal maxY = maxYExtent();
+ if ((d->_moveY.value() - maxY < height()/2 || d->_moveY.value() - d->flickTargetY < height()/2)
+ && maxY != d->flickTargetY)
+ d->flickY(-d->verticalVelocity.value());
+ }
}
- if (d->velocityX > 0) {
- if (d->flickTargetX - d->_moveX.value() < height()/2 && minXExtent() != d->flickTargetX)
- d->flickX(-d->verticalVelocity.value());
- } else if (d->velocityX < 0) {
- if (d->_moveX.value() - d->flickTargetX < height()/2 && maxXExtent() != d->flickTargetX)
- d->flickX(-d->verticalVelocity.value());
+ if (xflick()) {
+ if (d->velocityX > 0) {
+ const qreal minX = minXExtent();
+ if ((minX - d->_moveX.value() < height()/2 || d->flickTargetX - d->_moveX.value() < height()/2)
+ && minX != d->flickTargetX)
+ d->flickX(-d->verticalVelocity.value());
+ } else if (d->velocityX < 0) {
+ const qreal maxX = maxXExtent();
+ if ((d->_moveX.value() - maxX < height()/2 || d->_moveX.value() - d->flickTargetX < height()/2)
+ && maxX != d->flickTargetX)
+ d->flickX(-d->verticalVelocity.value());
+ }
}
+ d->inFlickCorrection = false;
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index 101fae2..60abdde 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -47,6 +47,7 @@
#include <qmlstategroup_p.h>
#include <qmlstateoperations_p.h>
#include <qfxperf_p_p.h>
+#include <QtCore/qmath.h>
#include <QDebug>
#include <QCoreApplication>
@@ -699,4 +700,141 @@ void QmlGraphicsGrid::doPositioning()
}
}
+
+QML_DEFINE_TYPE(Qt,4,6,Flow,QmlGraphicsFlow)
+/*!
+ \qmlclass Flow QmlGraphicsFlow
+ \brief The Flow item lines up its children side by side, wrapping as necessary.
+ \inherits Item
+
+
+*/
+/*!
+ \qmlproperty Transition Flow::add
+ This property holds the transition to apply when adding an item to the positioner.
+ The transition will only be applied to the added item(s).
+ Positioner transitions will only affect the position (x,y) of items.
+
+ Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
+
+
+*/
+/*!
+ \qmlproperty Transition Flow::move
+ This property holds the transition to apply when moving an item within the positioner.
+ Positioner transitions will only affect the position (x,y) of items.
+
+ This can happen when other items are added or removed from the positioner, or when items resize themselves.
+
+ \qml
+Flow {
+ id: positioner
+ move: Transition {
+ NumberAnimation {
+ matchProperties: "x,y"
+ ease: "easeOutBounce"
+ }
+ }
+}
+ \endqml
+
+*/
+/*!
+ \qmlproperty int Flow::spacing
+
+ spacing is the amount in pixels left empty between each adjacent
+ item, and defaults to 0.
+
+*/
+
+class QmlGraphicsFlowPrivate : public QmlGraphicsBasePositionerPrivate
+{
+ Q_DECLARE_PUBLIC(QmlGraphicsFlow)
+
+public:
+ QmlGraphicsFlowPrivate()
+ : QmlGraphicsBasePositionerPrivate(), flow(QmlGraphicsFlow::LeftToRight)
+ {}
+
+ QmlGraphicsFlow::Flow flow;
+};
+
+QmlGraphicsFlow::QmlGraphicsFlow(QmlGraphicsItem *parent)
+: QmlGraphicsBasePositioner(*(new QmlGraphicsFlowPrivate), Both, parent)
+{
+}
+
+/*!
+ \qmlproperty enumeration Flow::flow
+ This property holds the flow of the layout.
+
+ Possible values are \c LeftToRight (default) and \c TopToBottom.
+
+ If \a flow is \c LeftToRight, the items are positioned next to
+ to each other from left to right until the width of the Flow
+ is exceeded, then wrapped to the next line.
+ If \a flow is \c TopToBottom, the items are positioned next to each
+ other from top to bottom until the height of the Flow is exceeded,
+ then wrapped to the next column.
+*/
+QmlGraphicsFlow::Flow QmlGraphicsFlow::flow() const
+{
+ Q_D(const QmlGraphicsFlow);
+ return d->flow;
+}
+
+void QmlGraphicsFlow::setFlow(Flow flow)
+{
+ Q_D(QmlGraphicsFlow);
+ if (d->flow != flow) {
+ d->flow = flow;
+ prePositioning();
+ emit flowChanged();
+ }
+}
+
+void QmlGraphicsFlow::doPositioning()
+{
+ Q_D(QmlGraphicsFlow);
+
+ int hoffset = 0;
+ int voffset = 0;
+ int linemax = 0;
+
+ foreach(QmlGraphicsItem* child, positionedItems){
+ if (!child || isInvisible(child))
+ continue;
+
+ if (d->flow == LeftToRight) {
+ if (hoffset && hoffset + child->width() > width()) {
+ hoffset = 0;
+ voffset += linemax + spacing();
+ linemax = 0;
+ }
+ } else {
+ if (voffset && voffset + child->height() > height()) {
+ voffset = 0;
+ hoffset += linemax + spacing();
+ linemax = 0;
+ }
+ }
+
+ if(child->x() != hoffset || child->y() != voffset){
+ positionX(hoffset, child);
+ positionY(voffset, child);
+ }
+
+ if (d->flow == LeftToRight) {
+ hoffset += child->width();
+ hoffset += spacing();
+ linemax = qMax(linemax, qCeil(child->height()));
+ } else {
+ voffset += child->height();
+ voffset += spacing();
+ linemax = qMax(linemax, qCeil(child->width()));
+ }
+ }
+}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
index bc8315e..c8f846a 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
@@ -44,7 +44,7 @@
#include "qmlgraphicsitem.h"
-#include <qmlstate_p.h>
+#include "../util/qmlstate_p.h"
#include <QtCore/QObject>
#include <QtCore/QString>
@@ -87,8 +87,6 @@ Q_SIGNALS:
protected Q_SLOTS:
virtual void doPositioning()=0;
-
-private Q_SLOTS:
void prePositioning();
protected:
@@ -145,11 +143,39 @@ private:
Q_DISABLE_COPY(QmlGraphicsGrid)
};
+class QmlGraphicsFlowPrivate;
+class Q_DECLARATIVE_EXPORT QmlGraphicsFlow: public QmlGraphicsBasePositioner
+{
+ Q_OBJECT
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+public:
+ QmlGraphicsFlow(QmlGraphicsItem *parent=0);
+
+ Q_ENUMS(Flow)
+ enum Flow { LeftToRight, TopToBottom };
+ Flow flow() const;
+ void setFlow(Flow);
+
+Q_SIGNALS:
+ void flowChanged();
+
+protected Q_SLOTS:
+ virtual void doPositioning();
+
+protected:
+ QmlGraphicsFlow(QmlGraphicsFlowPrivate &dd, QmlGraphicsItem *parent);
+private:
+ Q_DISABLE_COPY(QmlGraphicsFlow)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsFlow)
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsColumn)
QML_DECLARE_TYPE(QmlGraphicsRow)
QML_DECLARE_TYPE(QmlGraphicsGrid)
+QML_DECLARE_TYPE(QmlGraphicsFlow)
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h
index c7d067d..88938a7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h
@@ -44,7 +44,7 @@
#include "qmlgraphicsborderimage_p.h"
-#include <qmlpixmapcache_p.h>
+#include "../util/qmlpixmapcache_p.h"
#include <qml.h>
#include <QtCore/QString>
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 63d5b70..ad68c8f 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -680,6 +680,8 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
QUrl url;
if(ctxt->argumentCount() > 2)
url = QUrl(ctxt->argument(2).toString());
+ else
+ url = QUrl("inline");
if (url.isValid() && url.isRelative())
url = context->resolvedUrl(url);
diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h
index c173fdc..7c48b8b 100644
--- a/src/declarative/qml/qmlenginedebug_p.h
+++ b/src/declarative/qml/qmlenginedebug_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <qmldebugservice_p.h>
+#include "../debugger/qmldebugservice_p.h"
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index 5f0fe9ce..9c39fc8 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -1006,6 +1006,7 @@ QmlXMLHttpRequest::QmlXMLHttpRequest()
QmlXMLHttpRequest::~QmlXMLHttpRequest()
{
destroyNetwork();
+ delete m_nam;
}
QScriptValue QmlXMLHttpRequest::callback() const
@@ -1295,7 +1296,7 @@ static QScriptValue qmlxmlhttprequest_open(QScriptContext *context, QScriptEngin
// Argument 1 - URL
- QUrl url(context->argument(1).toString());
+ QUrl url = QUrl::fromEncoded(context->argument(1).toString().toUtf8());
if (url.isRelative()) {
url = QmlScriptEngine::get(engine)->resolvedUrl(context,url);
diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h
index 734d44c..2a1a57d 100644
--- a/src/declarative/util/qmllistmodel_p.h
+++ b/src/declarative/util/qmllistmodel_p.h
@@ -49,7 +49,7 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QVariant>
-#include <qlistmodelinterface_p.h>
+#include "../3rdparty/qlistmodelinterface_p.h"
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qmlstateoperations_p.h b/src/declarative/util/qmlstateoperations_p.h
index b03af48..87af7bb 100644
--- a/src/declarative/util/qmlstateoperations_p.h
+++ b/src/declarative/util/qmlstateoperations_p.h
@@ -45,7 +45,7 @@
#include "qmlstate_p.h"
#include <qmlgraphicsitem.h>
-#include <qmlgraphicsanchors_p.h>
+#include "../graphicsitems/qmlgraphicsanchors_p.h"
#include <qmlscriptstring.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qmlxmllistmodel_p.h
index e645740..67fc751 100644
--- a/src/declarative/util/qmlxmllistmodel_p.h
+++ b/src/declarative/util/qmlxmllistmodel_p.h
@@ -45,7 +45,7 @@
#include <qml.h>
#include <qmlinfo.h>
-#include <qlistmodelinterface_p.h>
+#include "../3rdparty/qlistmodelinterface_p.h"
QT_BEGIN_HEADER
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index dd76f1c..9e6fcc0 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1328,6 +1328,7 @@ QGraphicsItem::~QGraphicsItem()
d_ptr->removeExtraItemCache();
clearFocus();
+ d_ptr->subFocusItem = 0;
// Update focus scope item ptr.
QGraphicsItem *p = d_ptr->parent;
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index b6aa872..1879367 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -33,6 +33,7 @@
#include "qscriptvalue_p.h"
#include "qscriptvalueiterator.h"
#include "qscriptclass.h"
+#include "qscriptcontextinfo.h"
#include "qscriptprogram.h"
#include "qscriptprogram_p.h"
#include "qdebug.h"
@@ -698,9 +699,9 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
#ifndef QT_NO_QOBJECT
QString context;
-// ### implement context resolution
-// if (ctx->parentContext())
-// context = QFileInfo(ctx->parentContext()->fileName()).baseName();
+ QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec);
+ if (ctx && ctx->parentContext())
+ context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName();
#endif
QString text(args.at(0).toString(exec));
#ifndef QT_NO_QOBJECT
diff --git a/tests/auto/declarative/anchors/data/centerin.qml b/tests/auto/declarative/anchors/data/centerin.qml
new file mode 100644
index 0000000..09b97f6
--- /dev/null
+++ b/tests/auto/declarative/anchors/data/centerin.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Rectangle {
+ objectName: "centered"
+ width: 50; height: 50; color: "blue"
+ anchors.centerIn: parent;
+ anchors.verticalCenterOffset: 30
+ anchors.horizontalCenterOffset: 10
+ }
+}
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index 7378d95..bbe5ef1 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -71,6 +71,7 @@ private slots:
void nullItem();
void nullItem_data();
void crash1();
+ void centerIn();
};
/*
@@ -378,6 +379,21 @@ void tst_anchors::crash1()
delete view;
}
+void tst_anchors::centerIn()
+{
+ QmlView *view = new QmlView;
+
+ view->setUrl(QUrl("file://" SRCDIR "/data/centerin.qml"));
+
+ view->execute();
+ qApp->processEvents();
+
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->x(), 85.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->y(), 105.0);
+
+ delete view;
+}
+
QTEST_MAIN(tst_anchors)
#include "tst_anchors.moc"
diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
index 14de1df..ddf9a07 100644
--- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
+++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
@@ -69,8 +69,6 @@ void tst_QmlListAccessor::invalid()
QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
QCOMPARE(accessor.count(), 0);
- QCOMPARE(accessor.at(0), QVariant());
- QCOMPARE(accessor.at(4), QVariant());
QVERIFY(!accessor.append(QVariant(10)));
QVERIFY(!accessor.insert(0, QVariant(10)));
QVERIFY(!accessor.removeAt(0));
@@ -83,8 +81,6 @@ void tst_QmlListAccessor::invalid()
QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
QCOMPARE(accessor.count(), 0);
- QCOMPARE(accessor.at(0), QVariant());
- QCOMPARE(accessor.at(4), QVariant());
QVERIFY(!accessor.append(QVariant(10)));
QVERIFY(!accessor.insert(0, QVariant(10)));
QVERIFY(!accessor.removeAt(0));
diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
index 21c5478..f184af0 100644
--- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
+++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
@@ -327,7 +327,7 @@ void tst_qmlqt::createQmlObject()
QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
QString warning3 = "QmlEngine::createQmlObject(): Component is not ready";
QString warning4 = "QmlEngine::createQmlObject():";
- QString warning5 = " :3: Cannot assign object type QObject with no default method";
+ QString warning5 = " " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
diff --git a/tests/auto/declarative/valuetypes/tst_valuetypes.cpp b/tests/auto/declarative/valuetypes/tst_valuetypes.cpp
index d42bfc5..1a5d7b6 100644
--- a/tests/auto/declarative/valuetypes/tst_valuetypes.cpp
+++ b/tests/auto/declarative/valuetypes/tst_valuetypes.cpp
@@ -474,11 +474,23 @@ void tst_valuetypes::valueSources()
delete object;
}
+static void checkNoErrors(QmlComponent& component)
+{
+ QList<QmlError> errors = component.errors();
+ if (errors.isEmpty())
+ return;
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QmlError &error = errors.at(ii);
+ qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
+ }
+}
+
// Test that property value interceptors can be applied to value types
void tst_valuetypes::valueInterceptors()
{
QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
QVERIFY(object != 0);
QCOMPARE(object->rect().x(), 26);
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml b/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml
new file mode 100644
index 0000000..56d616e
--- /dev/null
+++ b/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml
@@ -0,0 +1,131 @@
+import Qt.VisualTest 4.6
+
+VisualTest {
+ Frame {
+ msec: 0
+ }
+ Frame {
+ msec: 16
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 32
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 48
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 64
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 80
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 96
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 112
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 128
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 144
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 160
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 176
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 192
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 208
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 224
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 240
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 256
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 272
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 288
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 304
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 320
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 336
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 352
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 368
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 384
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 400
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 416
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 432
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 448
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 464
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 480
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 496
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml b/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml
new file mode 100644
index 0000000..56d616e
--- /dev/null
+++ b/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml
@@ -0,0 +1,131 @@
+import Qt.VisualTest 4.6
+
+VisualTest {
+ Frame {
+ msec: 0
+ }
+ Frame {
+ msec: 16
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 32
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 48
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 64
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 80
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 96
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 112
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 128
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 144
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 160
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 176
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 192
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 208
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 224
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 240
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 256
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 272
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 288
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 304
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 320
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 336
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 352
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 368
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 384
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 400
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 416
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 432
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 448
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 464
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 480
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+ Frame {
+ msec: 496
+ hash: "3e022a120a2dbe688d53657508de36cf"
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml b/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml
new file mode 100644
index 0000000..80f0f03
--- /dev/null
+++ b/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Rectangle {
+ id: s; width: 600; height: 100; color: "lightsteelblue"
+ property string text: "The quick brown fox jumps over the lazy dog."
+ Text {
+ text: s.text
+ anchors.verticalCenter: s.verticalCenter
+ }
+ Text {
+ text: s.text
+ anchors.baseline: s.verticalCenter
+ }
+}
diff --git a/tests/benchmarks/declarative/creation/data/item.qml b/tests/benchmarks/declarative/creation/data/item.qml
new file mode 100644
index 0000000..74d2f27
--- /dev/null
+++ b/tests/benchmarks/declarative/creation/data/item.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+
+Item {
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+ Item {}
+}
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
index 99411d4..61033e2 100644
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ b/tests/benchmarks/declarative/creation/tst_creation.cpp
@@ -44,7 +44,9 @@
#include <QmlComponent>
#include <QmlMetaType>
#include <QDebug>
+#include <QGraphicsScene>
#include <QGraphicsItem>
+#include <QmlGraphicsItem>
#include <private/qobject_p.h>
class tst_creation : public QObject
@@ -65,6 +67,13 @@ private slots:
void qgraphicsitem();
void qgraphicsitem_tree();
+ void itemtree_notree_cpp();
+ void itemtree_objtree_cpp();
+ void itemtree_cpp();
+ void itemtree_data_cpp();
+ void itemtree_qml();
+ void itemtree_scene_cpp();
+
private:
QmlEngine engine;
};
@@ -241,6 +250,100 @@ void tst_creation::qgraphicsitem_tree()
}
}
+struct QmlGraphics_DerivedObject : public QObject
+{
+ void setParent_noEvent(QObject *parent) {
+ bool sce = d_ptr->sendChildEvents;
+ d_ptr->sendChildEvents = false;
+ setParent(parent);
+ d_ptr->sendChildEvents = sce;
+ }
+};
+
+inline void QmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
+{
+ static_cast<QmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
+}
+
+void tst_creation::itemtree_notree_cpp()
+{
+ QBENCHMARK {
+ QmlGraphicsItem *item = new QmlGraphicsItem;
+ for (int i = 0; i < 30; ++i) {
+ QmlGraphicsItem *child = new QmlGraphicsItem;
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_objtree_cpp()
+{
+ QBENCHMARK {
+ QmlGraphicsItem *item = new QmlGraphicsItem;
+ for (int i = 0; i < 30; ++i) {
+ QmlGraphicsItem *child = new QmlGraphicsItem;
+ QmlGraphics_setParent_noEvent(child,item);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_cpp()
+{
+ QBENCHMARK {
+ QmlGraphicsItem *item = new QmlGraphicsItem;
+ for (int i = 0; i < 30; ++i) {
+ QmlGraphicsItem *child = new QmlGraphicsItem;
+ QmlGraphics_setParent_noEvent(child,item);
+ child->setParentItem(item);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_data_cpp()
+{
+ QBENCHMARK {
+ QmlGraphicsItem *item = new QmlGraphicsItem;
+ for (int i = 0; i < 30; ++i) {
+ QmlGraphicsItem *child = new QmlGraphicsItem;
+ QmlGraphics_setParent_noEvent(child,item);
+ item->data()->append(child);
+ }
+ delete item;
+ }
+}
+
+void tst_creation::itemtree_qml()
+{
+ QmlComponent component(&engine, TEST_FILE("item.qml"));
+ QObject *obj = component.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = component.create();
+ delete obj;
+ }
+}
+
+void tst_creation::itemtree_scene_cpp()
+{
+ QGraphicsScene scene;
+ QmlGraphicsItem *root = new QmlGraphicsItem;
+ scene.addItem(root);
+ QBENCHMARK {
+ QmlGraphicsItem *item = new QmlGraphicsItem;
+ for (int i = 0; i < 30; ++i) {
+ QmlGraphicsItem *child = new QmlGraphicsItem;
+ QmlGraphics_setParent_noEvent(child,item);
+ child->setParentItem(item);
+ }
+ item->setParentItem(root);
+ delete item;
+ }
+ delete root;
+}
+
QTEST_MAIN(tst_creation)