summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pope <daniel.pope@nokia.com>2009-12-10 00:49:46 (GMT)
committerDaniel Pope <daniel.pope@nokia.com>2009-12-10 00:49:46 (GMT)
commitcaa136ca80f5a85e4b28a24e33d8796f82044a28 (patch)
treecc84f21fe0163fe25c2503c7aeecf9a2b853bb22
parent3b5b7c87bcb6bb84d04664d81eb2262bea6f0d10 (diff)
parent4c5a4f4d520d05de6eceb58887c4b065fe103275 (diff)
downloadQt-caa136ca80f5a85e4b28a24e33d8796f82044a28.zip
Qt-caa136ca80f5a85e4b28a24e33d8796f82044a28.tar.gz
Qt-caa136ca80f5a85e4b28a24e33d8796f82044a28.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--examples/declarative/layouts/positioners.qml25
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp49
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp407
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h23
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h29
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp47
-rw-r--r--src/declarative/qml/qmlengine.cpp2
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp2
-rw-r--r--src/declarative/util/qmlopenmetaobject.cpp180
-rw-r--r--src/declarative/util/qmlopenmetaobject_p.h18
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml17
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml12
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml10
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp63
-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
23 files changed, 647 insertions, 545 deletions
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
index 4c26bea..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 }
@@ -109,12 +99,6 @@ Rectangle {
y: 0
columns: 3
- remove: Transition {
- NumberAnimation {
- matchProperties: "x,y"; easing: "easeOutBounce"
- }
- }
-
move: Transition {
NumberAnimation {
matchProperties: "x,y"; easing: "easeOutBounce"
@@ -149,11 +133,6 @@ Rectangle {
x: 260
y: 250
width: 150
- remove: Transition {
- NumberAnimation {
- matchProperties: "x,y"; easing: "easeOutBounce"
- }
- }
move: Transition {
NumberAnimation {
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index 153149e4..b72f010 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -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/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index 89c7657..eebc231 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -371,25 +371,34 @@ QML_DEFINE_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable)
*/
/*!
- \internal
- \class QmlGraphicsFlickable
- \brief The QmlGraphicsFlickable class provides a view that can be "flicked".
+ \qmlsignal Flickable::onMovementStarted()
- \ingroup group_widgets
+ This handler is called when the view begins moving due to user
+ interaction.
+*/
- QmlGraphicsFlickable allows its children to be dragged and flicked.
+/*!
+ \qmlsignal Flickable::onMovementEnded()
-\code
-Flickable {
- width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height
- Image { id: image; source: "bigimage.png" }
-}
-\endcode
+ This handler is called when the view stops moving due to user
+ interaction. If a flick was generated, this handler will
+ be triggered once the flick stops. If a flick was not
+ generated, the handler will be triggered when the
+ user stops dragging - i.e. a mouse or touch release.
+*/
- Note that QmlGraphicsFlickable does not automatically clip its contents. If
- it is not full-screen it is likely that QmlGraphicsItem::clip should be set
- to true.
+/*!
+ \qmlsignal Flickable::onFlickStarted()
+
+ This handler is called when the view is flicked. A flick
+ starts from the point that the mouse or touch is released,
+ while still in motion.
+*/
+/*!
+ \qmlsignal Flickable::onFlickEnded()
+
+ This handler is called when the view stops moving due to a flick.
*/
/*!
@@ -1195,6 +1204,12 @@ void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration)
d->deceleration = deceleration;
}
+/*!
+ \qmlproperty bool Flickable::flicking
+
+ This property holds whether the view is currently moving due to
+ the user flicking the view.
+*/
bool QmlGraphicsFlickable::isFlicking() const
{
Q_D(const QmlGraphicsFlickable);
@@ -1242,6 +1257,12 @@ void QmlGraphicsFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySm
emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing);
}
+/*!
+ \qmlproperty bool Flickable::moving
+
+ This property holds whether the view is currently moving due to
+ the user either dragging or flicking the view.
+*/
bool QmlGraphicsFlickable::isMoving() const
{
Q_D(const QmlGraphicsFlickable);
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index a4fa07a..a49794c 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -2172,7 +2172,6 @@ void QmlGraphicsListView::trackedPositionChanged()
} else {
if (trackedPos < viewPos && d->currentItem->position() < viewPos) {
d->setPosition(d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position());
- d->fixupPosition();
} else if (d->trackedItem->endPosition() > viewPos + d->size()
&& d->currentItem->endPosition() > viewPos + d->size()) {
qreal pos;
@@ -2186,7 +2185,6 @@ void QmlGraphicsListView::trackedPositionChanged()
pos = d->currentItem->position();
}
d->setPosition(pos);
- d->fixupPosition();
}
}
}
@@ -2493,7 +2491,7 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count)
FxListItem *movedItem = moved.take(item->index);
if (!movedItem)
movedItem = d->createItem(item->index);
- if (item->index < firstVisible->index)
+ if (item->index <= firstVisible->index)
moveBy -= movedItem->size();
it = d->visibleItems.insert(it, movedItem);
++it;
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 159fc29..f788077 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -574,7 +574,7 @@ void QmlGraphicsMouseRegion::setHovered(bool h)
\list
\o Qt.LeftButton
\o Qt.RightButton
- \o Qt.MiddleButton
+ \o Qt.MidButton
\endlist
To accept more than one button the flags can be combined with the
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index b1ec5a7..60abdde 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -67,8 +67,10 @@ void QmlGraphicsBasePositionerPrivate::watchChanges(QmlGraphicsItem *other)
QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
- otherPrivate->connectToHeightChanged(q, prePosIdx);
- otherPrivate->connectToWidthChanged(q, prePosIdx);
+ if(type == QmlGraphicsBasePositioner::Vertical || type == QmlGraphicsBasePositioner::Both)
+ otherPrivate->connectToHeightChanged(q, prePosIdx);
+ if(type == QmlGraphicsBasePositioner::Horizontal || type == QmlGraphicsBasePositioner::Both)
+ otherPrivate->connectToWidthChanged(q, prePosIdx);
otherPrivate->registerSiblingOrderNotification(this);
watched << other;
@@ -78,11 +80,14 @@ void QmlGraphicsBasePositionerPrivate::unwatchChanges(QmlGraphicsItem* other)
{
Q_Q(QmlGraphicsBasePositioner);
QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
- bool stillAlive = false; //Use the return from disconnect to see if it was deleted or just reparented
+ bool stillAlive = false; //Use the returns from disconnect to see if it was deleted or just reparented
stillAlive |= QMetaObject::disconnect(other, visibleIdx, q, prePosIdx);
stillAlive |= QMetaObject::disconnect(other, opacityIdx, q, prePosIdx);
- stillAlive |= otherPrivate->disconnectFromHeightChanged(q, prePosIdx);
- stillAlive |= otherPrivate->disconnectFromWidthChanged(q, prePosIdx);
+ //Is disconnect expensive enough to be worth this check?
+ if(type == QmlGraphicsBasePositioner::Vertical || type == QmlGraphicsBasePositioner::Both)
+ stillAlive |= otherPrivate->disconnectFromHeightChanged(q, prePosIdx);
+ if(type == QmlGraphicsBasePositioner::Horizontal || type == QmlGraphicsBasePositioner::Both)
+ stillAlive |= otherPrivate->disconnectFromWidthChanged(q, prePosIdx);
if(stillAlive)
otherPrivate->unregisterSiblingOrderNotification(this);
@@ -97,24 +102,24 @@ void QmlGraphicsBasePositionerPrivate::unwatchChanges(QmlGraphicsItem* other)
To create a QmlGraphics Positioner, simply subclass QmlGraphicsBasePositioner and implement
doLayout(), which is automatically called when the layout might need
- updating.
+ updating. In doLayout() use the setX and setY functions from QmlBasePositioner, and the
+ base class will apply the positions along with the appropriate transitions. The items to
+ position are provided in order as the protected member positionedItems.
- It is strongly recommended that in your implementation of doLayout()
- that you use the move, remove and add transitions when those conditions
- arise. You can use the applyAdd, applyMove and applyRemove functions
- to do this easily.
+ You also need to set a PositionerType, to declare whether you are positioning the x, y or both
+ for the child items. Depending on the chosen type, only x or y changes will be applied.
- Note also that the subclass is responsible for adding the
+ Note that the subclass is responsible for adding the
spacing in between items.
*/
-QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(AutoUpdateType at, QmlGraphicsItem *parent)
+QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(PositionerType at, QmlGraphicsItem *parent)
: QmlGraphicsItem(*(new QmlGraphicsBasePositionerPrivate), parent)
{
Q_D(QmlGraphicsBasePositioner);
d->init(at);
}
-QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, AutoUpdateType at, QmlGraphicsItem *parent)
+QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, PositionerType at, QmlGraphicsItem *parent)
: QmlGraphicsItem(dd, parent)
{
Q_D(QmlGraphicsBasePositioner);
@@ -124,15 +129,15 @@ QmlGraphicsBasePositioner::QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPr
int QmlGraphicsBasePositioner::spacing() const
{
Q_D(const QmlGraphicsBasePositioner);
- return d->_spacing;
+ return d->spacing;
}
void QmlGraphicsBasePositioner::setSpacing(int s)
{
Q_D(QmlGraphicsBasePositioner);
- if (s==d->_spacing)
+ if (s==d->spacing)
return;
- d->_spacing = s;
+ d->spacing = s;
prePositioning();
emit spacingChanged();
}
@@ -161,18 +166,6 @@ void QmlGraphicsBasePositioner::setAdd(QmlTransition *add)
d->addTransition = add;
}
-QmlTransition *QmlGraphicsBasePositioner::remove() const
-{
- Q_D(const QmlGraphicsBasePositioner);
- return d->removeTransition;
-}
-
-void QmlGraphicsBasePositioner::setRemove(QmlTransition *remove)
-{
- Q_D(QmlGraphicsBasePositioner);
- d->removeTransition = remove;
-}
-
void QmlGraphicsBasePositioner::componentComplete()
{
QmlGraphicsItem::componentComplete();
@@ -193,114 +186,49 @@ QVariant QmlGraphicsBasePositioner::itemChange(GraphicsItemChange change,
return QmlGraphicsItem::itemChange(change, value);
}
-bool QmlGraphicsBasePositioner::event(QEvent *e)
-{
- Q_D(QmlGraphicsBasePositioner);
- if (e->type() == QEvent::User) {
- d->_ep = false;
- d->_stableItems += d->_newItems;
- d->_leavingItems.clear();
- d->_newItems.clear();
- return true;
- }
- return QmlGraphicsItem::event(e);
-}
-
-/*!
- Items that have just been added to the positioner. This includes invisible items
- that have turned visible.
-*/
-QSet<QmlGraphicsItem *>* QmlGraphicsBasePositioner::newItems()
-{
- Q_D(QmlGraphicsBasePositioner);
- return &d->_newItems;
-}
-
-/*!
- Items that are visible in the positioner, not including ones that have just been added.
-*/
-QSet<QmlGraphicsItem *>* QmlGraphicsBasePositioner::items()
-{
- Q_D(QmlGraphicsBasePositioner);
- return &d->_stableItems;
-}
-
-/*!
- Items that have just left the positioner. This includes visible items
- that have turned invisible.
-*/
-QSet<QmlGraphicsItem *>* QmlGraphicsBasePositioner::leavingItems()
-{
- Q_D(QmlGraphicsBasePositioner);
- return &d->_leavingItems;
-}
-
void QmlGraphicsBasePositioner::prePositioning()
{
Q_D(QmlGraphicsBasePositioner);
- if (!isComponentComplete() || d->_movingItem)
+ if (!isComponentComplete())
return;
d->queuedPositioning = false;
- if (!d->_ep) {
- d->_ep = true;
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
- }
//Need to order children by creation order modified by stacking order
- //###can we avoid using the QGraphicsItemPrivate?
QList<QGraphicsItem *> children = childItems();
qSort(children.begin(), children.end(), d->insertionOrder);
positionedItems.clear();
+ d->newItems.clear();
- if (d->_items.isEmpty()) {
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
- if (!child)
- continue;
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
+ if (!child)
+ continue;
+ if(!d->watched.contains(child))
d->watchChanges(child);
- d->_items += child;
- if (child->opacity() != 0.0)
- d->_newItems += child;
- positionedItems << child;
- }
- } else {
- QSet<QmlGraphicsItem *> allItems;
- allItems.reserve(children.count());
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii));
- if (!child)
- continue;
- if (!d->_items.contains(child)){
- d->watchChanges(child);
- d->_items += child;
- }
- if (child->opacity() == 0.0){
- if (d->_stableItems.contains(child)){
- d->_leavingItems += child;
- d->_stableItems -= child;
- }
- }else if (!d->_stableItems.contains(child)){
- d->_newItems+=child;
- }
- allItems += child;
- positionedItems << child;
+ if(child->opacity() <= 0.0 || !child->isVisible())
+ continue;
+ if (!d->items.contains(child)){
+ d->items += child;
+ d->newItems += child;
}
- if (d->_items.count() != allItems.count()) {
- QSet<QmlGraphicsItem *> deletedItems = d->_items - allItems;
- foreach(QmlGraphicsItem *child, deletedItems){
- d->unwatchChanges(child);
- d->_items -= child;
- }
+ positionedItems << child;
+ }
+ if(d->items.count() > positionedItems.count()){
+ //Assumed that (aside from init) every add/remove triggers this check
+ //thus the above check will be triggered every time an item is removed
+ QSet<QmlGraphicsItem *> deletedItems = d->items - positionedItems.toSet();
+ foreach(QmlGraphicsItem *child, deletedItems){
+ d->unwatchChanges(child);
+ d->items -= child;
}
}
- d->_animated.clear();
doPositioning();
- finishApplyTransitions();
+ if(d->addTransition || d->moveTransition)
+ finishApplyTransitions();
//Set implicit size to the size of its children
- //###To keep this valid, do we need to update on pos change as well?
qreal h = 0.0f;
qreal w = 0.0f;
- foreach(QmlGraphicsItem *child, d->_items){
+ foreach(QmlGraphicsItem *child, d->items){
if(!child->isVisible() || child->opacity() <= 0)
continue;
h = qMax(h, child->y() + child->height());
@@ -310,69 +238,45 @@ void QmlGraphicsBasePositioner::prePositioning()
setImplicitWidth(w);
}
-void QmlGraphicsBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target, QmlStateOperation::ActionList &actions)
+void QmlGraphicsBasePositioner::positionX(int x, QmlGraphicsItem* target)
{
Q_D(QmlGraphicsBasePositioner);
- if (!target)
- return;
-
- for (int ii=0; ii<changes.size(); ++ii){
-
- QVariant val = changes[ii].second;
- actions << Action(target, changes[ii].first, val);
-
+ if(d->type == Horizontal || d->type == Both){
+ if(!d->addTransition && !d->moveTransition){
+ target->setX(x);
+ }else{
+ if(d->newItems.contains(target))
+ d->addActions << Action(target, QLatin1String("x"), QVariant(x));
+ else
+ d->moveActions << Action(target, QLatin1String("x"), QVariant(x));
+ }
}
+}
- d->_animated << target;
+void QmlGraphicsBasePositioner::positionY(int y, QmlGraphicsItem* target)
+{
+ Q_D(QmlGraphicsBasePositioner);
+ if(d->type == Vertical || d->type == Both){
+ if(!d->addTransition && !d->moveTransition){
+ target->setY(y);
+ }else{
+ if(d->newItems.contains(target))
+ d->addActions << Action(target, QLatin1String("y"), QVariant(y));
+ else
+ d->moveActions << Action(target, QLatin1String("y"), QVariant(y));
+ }
+ }
}
void QmlGraphicsBasePositioner::finishApplyTransitions()
{
Q_D(QmlGraphicsBasePositioner);
// Note that if a transition is not set the transition manager will
- // apply the changes directly, in the case someone uses applyAdd/Move/Remove
- // without testing add()/move()/remove().
+ // apply the changes directly, in the case add/move aren't set
d->addTransitionManager.transition(d->addActions, d->addTransition);
d->moveTransitionManager.transition(d->moveActions, d->moveTransition);
- d->removeTransitionManager.transition(d->removeActions, d->removeTransition);
d->addActions.clear();
d->moveActions.clear();
- d->removeActions.clear();
-}
-void QmlGraphicsBasePositioner::setMovingItem(QmlGraphicsItem *i)
-{
- Q_D(QmlGraphicsBasePositioner);
- d->_movingItem = i;
-}
-
-/*!
- Applies the positioner's add transition to the \a target item.\a changes is a list of property,value
- pairs which will be changed on the target using the add transition.
-*/
-void QmlGraphicsBasePositioner::applyAdd(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target)
-{
- Q_D(QmlGraphicsBasePositioner);
- applyTransition(changes,target, d->addActions);
-}
-
-/*!
- Applies the positioner's move transition to the \a target.\a changes is a list of property,value pairs
- which will be changed on the target using the move transition.
-*/
-void QmlGraphicsBasePositioner::applyMove(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target)
-{
- Q_D(QmlGraphicsBasePositioner);
- applyTransition(changes,target, d->moveActions);
-}
-
-/*!
- Applies the positioner's remove transition to the \a target item.\a changes is a list of
- property,value pairs which will be changed on the target using the remove transition.
-*/
-void QmlGraphicsBasePositioner::applyRemove(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target)
-{
- Q_D(QmlGraphicsBasePositioner);
- applyTransition(changes,target, d->removeActions);
}
QML_DEFINE_TYPE(Qt,4,6,Column,QmlGraphicsColumn)
@@ -426,14 +330,6 @@ Column {
*/
/*!
- \qmlproperty Transition Column::remove
- This property holds the transition to apply when removing an item from the positioner. The transition is only applied to the removed items.
- Positioner transitions will only affect the position (x,y) of items.
-
- Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible.
-
-*/
-/*!
\qmlproperty Transition Column::add
This property holds the transition to be applied 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.
@@ -500,36 +396,14 @@ void QmlGraphicsColumn::doPositioning()
{
int voffset = 0;
- foreach(QmlGraphicsItem* item, *leavingItems()){
- if (remove()){
- QList<QPair<QString,QVariant> > changes;
- applyRemove(changes, item);
- }
- }
-
- QList<QmlGraphicsItem *> children = positionedItems;
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = children.at(ii);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ QmlGraphicsItem *child = positionedItems.at(ii);
if (!child || isInvisible(child))
continue;
- bool needMove = (child->y() != voffset || child->x());
-
- if (needMove && move() && items()->contains(child)) {
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset));
- changes << qMakePair(QString(QLatin1String("x")),QVariant(0));
- applyMove(changes,child);
- } else if (add() && !items()->contains(child)) {
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset));
- changes << qMakePair(QString(QLatin1String("x")),QVariant(0));
- applyAdd(changes,child);
- } else if (needMove) {
- setMovingItem(child);
- child->setY(voffset);
- setMovingItem(0);
- }
+ if(child->y() != voffset)
+ positionY(voffset, child);
+
voffset += child->height();
voffset += spacing();
}
@@ -568,18 +442,6 @@ Row {
*/
/*!
- \qmlproperty Transition Row::remove
- This property holds the transition to apply when removing an item from the positioner.
- The transition will only be applied to the removed item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible.
-
- Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example.
-
-
-*/
-/*!
\qmlproperty Transition Row::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).
@@ -639,35 +501,14 @@ void QmlGraphicsRow::doPositioning()
{
int hoffset = 0;
- foreach(QmlGraphicsItem* item, *leavingItems()){
- if (remove()){
- QList<QPair<QString,QVariant> > changes;
- applyRemove(changes, item);
- }
- }
- QList<QmlGraphicsItem *> children = positionedItems;
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = children.at(ii);
+ for (int ii = 0; ii < positionedItems.count(); ++ii) {
+ QmlGraphicsItem *child = positionedItems.at(ii);
if (!child || isInvisible(child))
continue;
- bool needMove = (child->x() != hoffset || child->y());
-
- if (needMove && move() && items()->contains(child)) {
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset));
- changes << qMakePair(QString(QLatin1String("y")),QVariant(0));
- applyMove(changes,child);
- } else if (add() && !items()->contains(child)) {
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset));
- changes << qMakePair(QString(QLatin1String("y")),QVariant(0));
- applyAdd(changes,child);
- } else if (needMove) {
- setMovingItem(child);
- child->setX(hoffset);
- setMovingItem(0);
- }
+ if(child->x() != hoffset)
+ positionX(hoffset, child);
+
hoffset += child->width();
hoffset += spacing();
}
@@ -721,19 +562,6 @@ Grid {
positioner may exhibit strange behaviour.
*/
/*!
- \qmlproperty Transition Grid::remove
- This property holds the transition to apply when removing an item from the positioner.
- The transition is only applied to the removed item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Removed can mean that either the object has been deleted or
- reparented, and thus is now longer a child of the positioner, or that
- the object has had its opacity set to zero, and thus is no longer
- visible.
-
-
-*/
-/*!
\qmlproperty Transition Grid::add
This property holds the transition to apply when adding an item to the positioner.
The transition is only applied to the added item(s).
@@ -816,7 +644,7 @@ QmlGraphicsGrid::QmlGraphicsGrid(QmlGraphicsItem *parent) :
void QmlGraphicsGrid::doPositioning()
{
int c=_columns,r=_rows;//Actual number of rows/columns
- int numVisible = items()->size() + newItems()->size();
+ int numVisible = positionedItems.count();
if (_columns==-1 && _rows==-1){
c = 4;
r = (numVisible+3)/4;
@@ -829,7 +657,6 @@ void QmlGraphicsGrid::doPositioning()
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
- QList<QmlGraphicsItem *> children = positionedItems;
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
if (j==0)
@@ -837,9 +664,9 @@ void QmlGraphicsGrid::doPositioning()
if (i==0)
maxColWidth << 0;
- if (childIndex == children.count())
+ if (childIndex == positionedItems.count())
continue;
- QmlGraphicsItem *child = children.at(childIndex++);
+ QmlGraphicsItem *child = positionedItems.at(childIndex++);
if (!child || isInvisible(child))
continue;
if (child->width() > maxColWidth[j])
@@ -853,29 +680,12 @@ void QmlGraphicsGrid::doPositioning()
int yoffset=0;
int curRow =0;
int curCol =0;
- foreach(QmlGraphicsItem* item, *leavingItems()){
- if (remove()){
- QList<QPair<QString,QVariant> > changes;
- applyRemove(changes, item);
- }
- }
- foreach(QmlGraphicsItem* child, children){
+ foreach(QmlGraphicsItem* child, positionedItems){
if (!child || isInvisible(child))
continue;
- bool needMove = (child->x()!=xoffset)||(child->y()!=yoffset);
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("x")),QVariant(xoffset));
- changes << qMakePair(QString(QLatin1String("y")),QVariant(yoffset));
- if (newItems()->contains(child) && add()) {
- applyAdd(changes,child);
- } else if (needMove) {
- if (move()){
- applyMove(changes,child);
- }else{
- setMovingItem(child);
- child->setPos(QPointF(xoffset, yoffset));
- setMovingItem(0);
- }
+ if((child->x()!=xoffset)||(child->y()!=yoffset)){
+ positionX(xoffset, child);
+ positionY(yoffset, child);
}
xoffset+=maxColWidth[curCol]+spacing();
curCol++;
@@ -900,18 +710,6 @@ QML_DEFINE_TYPE(Qt,4,6,Flow,QmlGraphicsFlow)
*/
/*!
- \qmlproperty Transition Flow::remove
- This property holds the transition to apply when removing an item from the positioner.
- The transition will only be applied to the removed item(s).
- Positioner transitions will only affect the position (x,y) of items.
-
- Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible.
-
- Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example.
-
-
-*/
-/*!
\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).
@@ -998,20 +796,12 @@ void QmlGraphicsFlow::setFlow(Flow flow)
void QmlGraphicsFlow::doPositioning()
{
Q_D(QmlGraphicsFlow);
- foreach(QmlGraphicsItem* item, *leavingItems()){
- if (remove()){
- QList<QPair<QString,QVariant> > changes;
- applyRemove(changes, item);
- }
- }
int hoffset = 0;
int voffset = 0;
int linemax = 0;
- QList<QmlGraphicsItem *> children = positionedItems;
- for (int ii = 0; ii < children.count(); ++ii) {
- QmlGraphicsItem *child = children.at(ii);
+ foreach(QmlGraphicsItem* child, positionedItems){
if (!child || isInvisible(child))
continue;
@@ -1029,24 +819,9 @@ void QmlGraphicsFlow::doPositioning()
}
}
- bool needMove = (child->x() != hoffset || child->y() != voffset);
-
- if (newItems()->contains(child) && add()) {
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset));
- changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset));
- applyAdd(changes,child);
- } else if (needMove) {
- if (move()){
- QList<QPair<QString, QVariant> > changes;
- changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset));
- changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset));
- applyMove(changes,child);
- } else {
- setMovingItem(child);
- child->setPos(QPointF(hoffset, voffset));
- setMovingItem(0);
- }
+ if(child->x() != hoffset || child->y() != voffset){
+ positionX(hoffset, child);
+ positionY(voffset, child);
}
if (d->flow == LeftToRight) {
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
index 4148ff6..c8f846a 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
@@ -63,10 +63,9 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsBasePositioner : public QmlGraphicsItem
Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(QmlTransition *move READ move WRITE setMove)
Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
- Q_PROPERTY(QmlTransition *remove READ remove WRITE setRemove)
public:
- enum AutoUpdateType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
- QmlGraphicsBasePositioner(AutoUpdateType, QmlGraphicsItem *parent);
+ enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
+ QmlGraphicsBasePositioner(PositionerType, QmlGraphicsItem *parent);
int spacing() const;
void setSpacing(int);
@@ -77,23 +76,13 @@ public:
QmlTransition *add() const;
void setAdd(QmlTransition *);
- QmlTransition *remove() const;
- void setRemove(QmlTransition *);
-
protected:
+ QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, PositionerType at, QmlGraphicsItem *parent);
virtual void componentComplete();
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
- virtual bool event(QEvent *);
- QSet<QmlGraphicsItem *>* newItems();
- QSet<QmlGraphicsItem *>* leavingItems();
- QSet<QmlGraphicsItem *>* items();
- void applyAdd(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target);
- void applyMove(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target);
- void applyRemove(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target);
void finishApplyTransitions();
Q_SIGNALS:
- void layoutItemChanged();
void spacingChanged();
protected Q_SLOTS:
@@ -101,13 +90,11 @@ protected Q_SLOTS:
void prePositioning();
protected:
- QmlGraphicsBasePositioner(QmlGraphicsBasePositionerPrivate &dd, AutoUpdateType at, QmlGraphicsItem *parent);
- void setMovingItem(QmlGraphicsItem *);
QList<QmlGraphicsItem *> positionedItems;
+ void positionX(int,QmlGraphicsItem* target);
+ void positionY(int,QmlGraphicsItem* target);
private:
- void applyTransition(const QList<QPair<QString, QVariant> >& changes, QmlGraphicsItem* target,
- QmlStateOperation::ActionList &actions);
Q_DISABLE_COPY(QmlGraphicsBasePositioner)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsBasePositioner)
};
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
index b079f6a..db795ec 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
@@ -72,9 +72,8 @@ class QmlGraphicsBasePositionerPrivate : public QmlGraphicsItemPrivate
public:
QmlGraphicsBasePositionerPrivate()
- : _ep(false), _componentComplete(false), _spacing(0),
- aut(QmlGraphicsBasePositioner::None), moveTransition(0), addTransition(0),
- removeTransition(0), _movingItem(0), queuedPositioning(false)
+ : spacing(0), type(QmlGraphicsBasePositioner::None), moveTransition(0), addTransition(0),
+ queuedPositioning(false)
{
}
@@ -85,9 +84,9 @@ public:
unwatchChanges(other);//Need to deregister from a list in QmlGI Private
}
- void init(QmlGraphicsBasePositioner::AutoUpdateType at)
+ void init(QmlGraphicsBasePositioner::PositionerType at)
{
- aut = at;
+ type = at;
if (prePosIdx == -1) {
prePosIdx = QmlGraphicsBasePositioner::staticMetaObject.indexOfSlot("prePositioning()");
visibleIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("visibleChanged()");
@@ -95,29 +94,20 @@ public:
}
}
- bool _ep;
- bool _componentComplete;
- int _spacing;
- QmlGraphicsBasePositioner::AutoUpdateType aut;
+ int spacing;
+ QmlGraphicsBasePositioner::PositionerType type;
QmlTransition *moveTransition;
QmlTransition *addTransition;
- QmlTransition *removeTransition;
- QSet<QmlGraphicsItem *> _items;
- QSet<QmlGraphicsItem *> _leavingItems;
- QSet<QmlGraphicsItem *> _stableItems;
- QSet<QmlGraphicsItem *> _newItems;
- QSet<QmlGraphicsItem *> _animated;
+ QSet<QmlGraphicsItem *> items;
+ QSet<QmlGraphicsItem *> newItems;
QmlStateOperation::ActionList addActions;
QmlStateOperation::ActionList moveActions;
- QmlStateOperation::ActionList removeActions;
QmlTransitionManager addTransitionManager;
QmlTransitionManager moveTransitionManager;
- QmlTransitionManager removeTransitionManager;
- QmlGraphicsItem *_movingItem;
void watchChanges(QmlGraphicsItem *other);
void unwatchChanges(QmlGraphicsItem* other);
- QList<QGuard<QmlGraphicsItem> > watched;
+ QList<QGuard<QmlGraphicsItem> > watched;//Can't have QSet and QGuard at the same time?
bool queuedPositioning;
static int prePosIdx;
@@ -130,6 +120,7 @@ public:
Q_UNUSED(other);
if(!queuedPositioning){
//Delay is due to many children often being reordered at once
+ //And we only want to reposition them all once
QTimer::singleShot(0,q,SLOT(prePositioning()));
queuedPositioning = true;
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index a6c40c5..c6f790c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -341,6 +341,9 @@ public:
QmlGraphicsVisualDataModelParts *m_parts;
friend class QmlGraphicsVisualItemParts;
+ QmlOpenMetaObjectType *m_delegateDataType;
+ friend class QmlGraphicsVisualDataModelData;
+
QmlGraphicsVisualDataModelData *data(QObject *item);
QVariant m_modelVariant;
@@ -362,10 +365,11 @@ public:
class QmlGraphicsVisualDataModelDataMetaObject : public QmlOpenMetaObject
{
public:
- QmlGraphicsVisualDataModelDataMetaObject(QObject *parent)
- : QmlOpenMetaObject(parent) {}
+ QmlGraphicsVisualDataModelDataMetaObject(QObject *parent, QmlOpenMetaObjectType *type)
+ : QmlOpenMetaObject(parent, type) {}
- virtual QVariant propertyCreated(int, QMetaPropertyBuilder &);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+ virtual QVariant initialValue(int);
virtual int createProperty(const char *, const char *);
private:
@@ -442,20 +446,22 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c
return -1;
}
-QVariant
-QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
+void QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
{
prop.setWritable(false);
+}
+QVariant QmlGraphicsVisualDataModelDataMetaObject::initialValue(int propId)
+{
QmlGraphicsVisualDataModelData *data =
static_cast<QmlGraphicsVisualDataModelData *>(object());
Q_ASSERT(data->m_model);
QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model);
- QString name = QString::fromUtf8(prop.name());
+ QString strName = QString::fromUtf8(name(propId));
if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
- if (name == QLatin1String("modelData")) {
+ if (strName == QLatin1String("modelData")) {
if (model->m_listAccessor->type() == QmlListAccessor::Instance) {
QObject *object = model->m_listAccessor->at(0).value<QObject*>();
return object->metaObject()->property(1).read(object); // the first property after objectName
@@ -464,11 +470,11 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil
} else {
// return any property of a single object instance.
QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
- return object->property(prop.name());
+ return object->property(name(propId));
}
} else if (model->m_listModelInterface) {
model->ensureRoles();
- QHash<QString,int>::const_iterator it = model->m_roleNames.find(name);
+ QHash<QString,int>::const_iterator it = model->m_roleNames.find(strName);
if (it != model->m_roleNames.end()) {
roles.append(*it);
QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << *it);
@@ -476,7 +482,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil
return QVariant();
else
return values.value(*it);
- } else if (model->m_roles.count() == 1 && name == QLatin1String("modelData")) {
+ } else if (model->m_roles.count() == 1 && strName == QLatin1String("modelData")) {
//for compatability with other lists, assign modelData if there is only a single role
QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << model->m_roles.first());
if (values.isEmpty())
@@ -486,7 +492,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil
}
} else if (model->m_abstractItemModel) {
model->ensureRoles();
- QHash<QString,int>::const_iterator it = model->m_roleNames.find(name);
+ QHash<QString,int>::const_iterator it = model->m_roleNames.find(strName);
if (it != model->m_roleNames.end()) {
roles.append(*it);
QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0);
@@ -500,7 +506,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil
QmlGraphicsVisualDataModelData::QmlGraphicsVisualDataModelData(int index,
QmlGraphicsVisualDataModel *model)
: m_index(index), m_model(model),
- m_meta(new QmlGraphicsVisualDataModelDataMetaObject(this))
+m_meta(new QmlGraphicsVisualDataModelDataMetaObject(this, QmlGraphicsVisualDataModelPrivate::get(model)->m_delegateDataType))
{
}
@@ -526,7 +532,8 @@ public:
QmlGraphicsVisualDataModelPartsMetaObject(QObject *parent)
: QmlOpenMetaObject(parent) {}
- virtual QVariant propertyCreated(int, QMetaPropertyBuilder &);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+ virtual QVariant initialValue(int);
};
class QmlGraphicsVisualDataModelParts : public QObject
@@ -540,14 +547,16 @@ private:
QmlGraphicsVisualDataModel *model;
};
-QVariant
-QmlGraphicsVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
+void QmlGraphicsVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop)
{
prop.setWritable(false);
+}
+QVariant QmlGraphicsVisualDataModelPartsMetaObject::initialValue(int id)
+{
QmlGraphicsVisualDataModel *m = new QmlGraphicsVisualDataModel;
m->setParent(object());
- m->setPart(QString::fromUtf8(prop.name()));
+ m->setPart(QString::fromUtf8(name(id)));
m->setModel(QVariant::fromValue(static_cast<QmlGraphicsVisualDataModelParts *>(object())->model));
QVariant var = QVariant::fromValue((QObject *)m);
@@ -562,7 +571,7 @@ QmlGraphicsVisualDataModelParts::QmlGraphicsVisualDataModelParts(QmlGraphicsVisu
QmlGraphicsVisualDataModelPrivate::QmlGraphicsVisualDataModelPrivate(QmlContext *ctxt)
: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
-, m_context(ctxt), m_parts(0), m_listAccessor(0)
+, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_listAccessor(0)
{
}
@@ -639,6 +648,8 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model)
d->m_roles.clear();
d->m_roleNames.clear();
+ delete d->m_delegateDataType;
+ d->m_delegateDataType = new QmlOpenMetaObjectType(d->m_context?d->m_context->engine():qmlEngine(this));
QObject *object = qvariant_cast<QObject *>(model);
if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
@@ -761,7 +772,7 @@ QmlGraphicsVisualDataModel::ReleaseFlags QmlGraphicsVisualDataModel::release(Qml
if (inPackage)
emit destroyingPackage(qobject_cast<QmlPackage*>(obj));
stat |= Destroyed;
- delete obj;
+ obj->deleteLater();
} else if (!inPackage) {
stat |= Referenced;
}
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/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index 9629d7b..9c39fc8 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -1296,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/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp
index 04cd8a5..473d9d9 100644
--- a/src/declarative/util/qmlopenmetaobject.cpp
+++ b/src/declarative/util/qmlopenmetaobject.cpp
@@ -40,70 +40,141 @@
****************************************************************************/
#include "qmlopenmetaobject_p.h"
-
+#include "qmlpropertycache_p.h"
+#include "qmldeclarativedata_p.h"
#include <qmetaobjectbuilder_p.h>
#include <QDebug>
QT_BEGIN_NAMESPACE
-class QmlOpenMetaObjectPrivate
+
+class QmlOpenMetaObjectTypePrivate
{
public:
- QmlOpenMetaObjectPrivate() : parent(0), mem(0) {}
+ QmlOpenMetaObjectTypePrivate() : mem(0), engine(0) {}
+
+ void init(QObject *obj);
- bool autoCreate;
- QAbstractDynamicMetaObject *parent;
int propertyOffset;
int signalOffset;
- QList<QVariant> data;
QHash<QByteArray, int> names;
QMetaObjectBuilder mob;
QMetaObject *mem;
+ QmlEngine *engine;
+};
+
+QmlOpenMetaObjectType::QmlOpenMetaObjectType(QmlEngine *engine)
+ : d(new QmlOpenMetaObjectTypePrivate)
+{
+ d->engine = engine;
+}
+
+QmlOpenMetaObjectType::~QmlOpenMetaObjectType()
+{
+ qFree(d->mem);
+}
+
+void QmlOpenMetaObjectTypePrivate::init(QObject *obj)
+{
+ if (!mem) {
+ mob.setSuperClass(obj->metaObject());
+ mob.setClassName(obj->metaObject()->className());
+ mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ if (op->metaObject)
+ mob.setSuperClass(op->metaObject);
+ mem = mob.toMetaObject();
+
+ propertyOffset = mem->propertyOffset();
+ signalOffset = mem->methodOffset();
+ }
+}
+
+class QmlOpenMetaObjectPrivate
+{
+public:
+ QmlOpenMetaObjectPrivate(QmlOpenMetaObject *_q) : q(_q), parent(0), type(0), ownType(false) {}
+
+ inline QVariant &getData(int idx) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ if (!prop.second) {
+ prop.first = q->initialValue(idx);
+ prop.second = true;
+ }
+ return prop.first;
+ }
+
+ inline void writeData(int idx, const QVariant &value) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ prop.first = value;
+ prop.second = true;
+ }
+
+ bool autoCreate;
+ QmlOpenMetaObject *q;
+ QAbstractDynamicMetaObject *parent;
+ QList<QPair<QVariant, bool> > data;
QObject *object;
+ QmlOpenMetaObjectType *type;
+ bool ownType;
};
QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, bool automatic)
-: d(new QmlOpenMetaObjectPrivate)
+: d(new QmlOpenMetaObjectPrivate(this))
{
d->autoCreate = automatic;
d->object = obj;
- d->mob.setSuperClass(obj->metaObject());
- d->mob.setClassName(obj->metaObject()->className());
- d->mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+ d->type = new QmlOpenMetaObjectType(0);
+ d->ownType = true;
+ d->type->d->init(obj);
QObjectPrivate *op = QObjectPrivate::get(obj);
- if (op->metaObject)
- d->mob.setSuperClass(op->metaObject);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ op->metaObject = this;
+}
+
+QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, QmlOpenMetaObjectType *type, bool automatic)
+: d(new QmlOpenMetaObjectPrivate(this))
+{
+ d->autoCreate = automatic;
+ d->object = obj;
- d->mem = d->mob.toMetaObject();
- *static_cast<QMetaObject *>(this) = *d->mem;
+ d->type = type;
+ d->type->d->init(obj);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
op->metaObject = this;
- d->propertyOffset = propertyOffset();
- d->signalOffset = methodOffset();
}
QmlOpenMetaObject::~QmlOpenMetaObject()
{
if (d->parent)
delete d->parent;
- qFree(d->mem);
+ if (d->ownType)
+ delete d->type;
delete d;
}
int QmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
{
if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
- && id >= d->propertyOffset) {
- int propId = id - d->propertyOffset;
+ && id >= d->type->d->propertyOffset) {
+ int propId = id - d->type->d->propertyOffset;
if (c == QMetaObject::ReadProperty) {
propertyRead(propId);
- *reinterpret_cast<QVariant *>(a[0]) = d->data[propId];
+ *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
} else if (c == QMetaObject::WriteProperty) {
- if (d->data[propId] != *reinterpret_cast<QVariant *>(a[0])) {
+ if (d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
propertyWrite(propId);
- d->data[propId] = *reinterpret_cast<QVariant *>(a[0]);
- activate(d->object, d->signalOffset + propId, 0);
+ d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
+ activate(d->object, d->type->d->signalOffset + propId, 0);
}
}
return -1;
@@ -117,50 +188,49 @@ int QmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
QVariant QmlOpenMetaObject::value(int id) const
{
- Q_ASSERT(id >= 0 && id < d->data.count());
- return d->data.at(id);
+ return d->getData(id);
}
void QmlOpenMetaObject::setValue(int id, const QVariant &value)
{
- Q_ASSERT(id >= 0 && id < d->data.count());
- d->data[id] = value;
- activate(d->object, id + d->signalOffset, 0);
+ d->writeData(id, value);
+ activate(d->object, id + d->type->d->signalOffset, 0);
}
QVariant QmlOpenMetaObject::value(const QByteArray &name) const
{
- QHash<QByteArray, int>::ConstIterator iter = d->names.find(name);
- if (iter == d->names.end())
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ if (iter == d->type->d->names.end())
return QVariant();
- return d->data.at(*iter);
+ return d->getData(*iter);
}
QVariant &QmlOpenMetaObject::operator[](const QByteArray &name)
{
- QHash<QByteArray, int>::ConstIterator iter = d->names.find(name);
- Q_ASSERT(iter != d->names.end());
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ Q_ASSERT(iter != d->type->d->names.end());
- return d->data[*iter];
+ return d->getData(*iter);
}
void QmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
{
- QHash<QByteArray, int>::ConstIterator iter = d->names.find(name);
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
int id = -1;
- if (iter == d->names.end()) {
- id = doCreateProperty(name.constData()) - d->propertyOffset;
+ if (iter == d->type->d->names.end()) {
+ id = doCreateProperty(name.constData()) - d->type->d->propertyOffset;
} else {
id = *iter;
}
- if (d->data[id] == val)
+ QVariant &dataVal = d->getData(id);
+ if (dataVal == val)
return;
- d->data[id] = val;
- activate(d->object, id + d->signalOffset, 0);
+ dataVal = val;
+ activate(d->object, id + d->type->d->signalOffset, 0);
}
int QmlOpenMetaObject::createProperty(const char *name, const char *)
@@ -173,17 +243,17 @@ int QmlOpenMetaObject::createProperty(const char *name, const char *)
int QmlOpenMetaObject::doCreateProperty(const char *name)
{
- int id = d->mob.propertyCount();
- d->mob.addSignal("__" + QByteArray::number(id) + "()");
- QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
+ int id = d->type->d->mob.propertyCount();
+ d->type->d->mob.addSignal("__" + QByteArray::number(id) + "()");
+ QMetaPropertyBuilder build = d->type->d->mob.addProperty(name, "QVariant", id);
build.setDynamic(true);
- d->data << propertyCreated(id, build);
- qFree(d->mem);
- d->mem = d->mob.toMetaObject();
- *static_cast<QMetaObject *>(this) = *d->mem;
- d->names.insert(name, id);
+ propertyCreated(id, build);
+ qFree(d->type->d->mem);
+ d->type->d->mem = d->type->d->mob.toMetaObject();
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ d->type->d->names.insert(name, id);
- return d->propertyOffset + id;
+ return d->type->d->propertyOffset + id;
}
void QmlOpenMetaObject::propertyRead(int)
@@ -194,21 +264,25 @@ void QmlOpenMetaObject::propertyWrite(int)
{
}
-QVariant QmlOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
+void QmlOpenMetaObject::propertyCreated(int id, QMetaPropertyBuilder &)
+{
+}
+
+QVariant QmlOpenMetaObject::initialValue(int)
{
return QVariant();
}
int QmlOpenMetaObject::count() const
{
- return d->data.count();
+ return d->type->d->names.count();
}
QByteArray QmlOpenMetaObject::name(int idx) const
{
- Q_ASSERT(idx >= 0 && idx < d->data.count());
+ Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
- return d->mob.property(idx).name();
+ return d->type->d->mob.property(idx).name();
}
QObject *QmlOpenMetaObject::object() const
diff --git a/src/declarative/util/qmlopenmetaobject_p.h b/src/declarative/util/qmlopenmetaobject_p.h
index 6045678..b33f99b 100644
--- a/src/declarative/util/qmlopenmetaobject_p.h
+++ b/src/declarative/util/qmlopenmetaobject_p.h
@@ -53,12 +53,27 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QmlEngine;
+class QmlOpenMetaObjectTypePrivate;
+class QmlOpenMetaObjectType
+{
+public:
+ QmlOpenMetaObjectType(QmlEngine *engine);
+ ~QmlOpenMetaObjectType();
+
+private:
+ QmlOpenMetaObjectTypePrivate *d;
+ friend class QmlOpenMetaObject;
+ friend class QmlOpenMetaObjectPrivate;
+};
+
class QmlOpenMetaObjectPrivate;
class QMetaPropertyBuilder;
class Q_DECLARATIVE_EXPORT QmlOpenMetaObject : public QAbstractDynamicMetaObject
{
public:
QmlOpenMetaObject(QObject *, bool = true);
+ QmlOpenMetaObject(QObject *, QmlOpenMetaObjectType *, bool = true);
~QmlOpenMetaObject();
QVariant value(const QByteArray &) const;
@@ -71,13 +86,14 @@ public:
QByteArray name(int) const;
QObject *object() const;
+ virtual QVariant initialValue(int);
protected:
virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
virtual int createProperty(const char *, const char *);
virtual void propertyRead(int);
virtual void propertyWrite(int);
- virtual QVariant propertyCreated(int, QMetaPropertyBuilder &);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
private:
int doCreateProperty(const char *);
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
index 6b128ce..022019c 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
@@ -7,12 +7,7 @@ Item {
columns: 3
add: Transition {
NumberAnimation {
- matchProperties: "x,y"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "x,y"; to: -100
+ matchProperties: "x,y";
}
}
move: Transition {
@@ -23,11 +18,15 @@ Item {
Rectangle {
objectName: "one"
color: "red"
+ x: -100
+ y: -100
width: 50
height: 50
}
Rectangle {
objectName: "two"
+ x: -100
+ y: -100
opacity: 0
color: "green"
width: 50
@@ -36,18 +35,24 @@ Item {
Rectangle {
objectName: "three"
color: "blue"
+ x: -100
+ y: -100
width: 50
height: 50
}
Rectangle {
objectName: "four"
color: "cyan"
+ x: -100
+ y: -100
width: 50
height: 50
}
Rectangle {
objectName: "five"
color: "magenta"
+ x: -100
+ y: -100
width: 50
height: 50
}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
index c29d6df..eba165c 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
@@ -6,12 +6,7 @@ Item {
Row {
add: Transition {
NumberAnimation {
- matchProperties: "x"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "x"; to: -100
+ matchProperties: "x";
}
}
move: Transition {
@@ -22,19 +17,22 @@ Item {
Rectangle {
objectName: "one"
color: "red"
+ x: -100;
width: 50
height: 50
}
Rectangle {
objectName: "two"
color: "blue"
+ x: -100;
opacity: 0
width: 50
height: 50
}
Rectangle {
objectName: "three"
- color: "red"
+ x: -100;
+ color: "green"
width: 50
height: 50
}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
index fcbc5f7..8e3abbd 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
@@ -6,12 +6,7 @@ Item {
Column {
add: Transition {
NumberAnimation {
- matchProperties: "y"; from: -100
- }
- }
- remove: Transition {
- NumberAnimation {
- matchProperties: "y"; to: -100
+ matchProperties: "y";
}
}
move: Transition {
@@ -22,12 +17,14 @@ Item {
Rectangle {
objectName: "one"
color: "red"
+ y: -100
width: 50
height: 50
}
Rectangle {
objectName: "two"
color: "blue"
+ y: -100
opacity: 0
width: 50
height: 50
@@ -35,6 +32,7 @@ Item {
Rectangle {
objectName: "three"
color: "red"
+ y: -100
width: 50
height: 50
}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
index aca3579..0e2109b 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
@@ -126,14 +126,14 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
qApp->processEvents();
QTest::qWait(0);//Let the animation start
- //Note that one and three animate in
+ //Note that they animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
QCOMPARE(one->x(), -100.0);
QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->x(), -100.0);
QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
@@ -144,7 +144,7 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QCOMPARE(one->x(), 0.0);
QCOMPARE(one->y(), 0.0);
QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->x(), -100.0);//Not 'in' yet
QCOMPARE(two->y(), 0.0);
QCOMPARE(three->x(), 50.0);
QCOMPARE(three->y(), 0.0);
@@ -158,15 +158,6 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QTest::qWait(300);//Let the animation complete
QCOMPARE(two->x(), 50.0);
QCOMPARE(three->x(), 100.0);
-
- //Remove 'two'
- two->setOpacity(0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(three->x(), 100.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(three->x(), 50.0);
}
void tst_QmlGraphicsPositioners::test_vertical()
@@ -225,14 +216,14 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
qApp->processEvents();
QTest::qWait(0);//Let the animation start
- //Note that one and three animate in
+ //Note that they animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
QCOMPARE(one->y(), -100.0);
QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QCOMPARE(two->y(), 0.0);
+ QCOMPARE(two->y(), -100.0);
QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
@@ -243,7 +234,7 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
QCOMPARE(one->y(), 0.0);
QCOMPARE(one->x(), 0.0);
QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), 0.0);
+ QCOMPARE(two->y(), -100.0);//Not 'in' yet
QCOMPARE(two->x(), 0.0);
QCOMPARE(three->y(), 50.0);
QCOMPARE(three->x(), 0.0);
@@ -258,14 +249,6 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
QCOMPARE(two->y(), 50.0);
QCOMPARE(three->y(), 100.0);
- //Remove 'two'
- two->setOpacity(0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->y(), 100.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->y(), 50.0);
}
void tst_QmlGraphicsPositioners::test_grid()
@@ -335,7 +318,7 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
qApp->processEvents();
QTest::qWait(0);//Let the animation start
- //Note that all but two animate in
+ //Note that all animate in
QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
QCOMPARE(one->x(), -100.0);
@@ -343,8 +326,8 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 0.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
@@ -366,8 +349,8 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QCOMPARE(one->y(), 0.0);
QCOMPARE(one->x(), 0.0);
QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(two->x(), -100.0);
QCOMPARE(three->y(), 0.0);
QCOMPARE(three->x(), 50.0);
QCOMPARE(four->y(), 0.0);
@@ -401,30 +384,6 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QCOMPARE(five->x(), 50.0);
QCOMPARE(five->y(), 50.0);
- //Remove 'two'
- two->setOpacity(0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
}
void tst_QmlGraphicsPositioners::test_repeater()
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
+ }
+}