summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-13 00:12:35 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-13 00:12:35 (GMT)
commit91054842ae3b87b224ea153711cedf7056e4da60 (patch)
tree1de54549136dd2047a9678d77368d4b30e783788
parent8979501336a441e585d38b711ee0fe4a284040f3 (diff)
parent5efd577b1aea64f422e08ca8d54e041fa4b20783 (diff)
downloadQt-91054842ae3b87b224ea153711cedf7056e4da60.zip
Qt-91054842ae3b87b224ea153711cedf7056e4da60.tar.gz
Qt-91054842ae3b87b224ea153711cedf7056e4da60.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Autotest for QTBUG-5491 (Animation in a Behavior doesn't update running) Private variable cleanup. wantsFocus should be based on FocusScope chain, not parent chain.
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp29
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h20
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml20
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/chain.qml28
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml4
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test.qml2
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test5.qml2
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp7
11 files changed, 119 insertions, 36 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index f5ea537..7022fac 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1609,7 +1609,7 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const
bool QDeclarativeItem::isComponentComplete() const
{
Q_D(const QDeclarativeItem);
- return d->_componentComplete;
+ return d->componentComplete;
}
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
@@ -1750,7 +1750,7 @@ QRectF QDeclarativeItem::childrenRect()
Q_D(QDeclarativeItem);
if (!d->_contents) {
d->_contents = new QDeclarativeContents(this);
- if (d->_componentComplete)
+ if (d->componentComplete)
d->_contents->complete();
}
return d->_contents->rectF();
@@ -2154,19 +2154,19 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const
qreal QDeclarativeItem::baselineOffset() const
{
Q_D(const QDeclarativeItem);
- if (!d->_baselineOffset.isValid()) {
+ if (!d->baselineOffset.isValid()) {
return 0.0;
} else
- return d->_baselineOffset;
+ return d->baselineOffset;
}
void QDeclarativeItem::setBaselineOffset(qreal offset)
{
Q_D(QDeclarativeItem);
- if (offset == d->_baselineOffset)
+ if (offset == d->baselineOffset)
return;
- d->_baselineOffset = offset;
+ d->baselineOffset = offset;
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2295,7 +2295,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
bool QDeclarativeItem::keepMouseGrab() const
{
Q_D(const QDeclarativeItem);
- return d->_keepMouse;
+ return d->keepMouse;
}
/*!
@@ -2319,7 +2319,7 @@ bool QDeclarativeItem::keepMouseGrab() const
void QDeclarativeItem::setKeepMouseGrab(bool keep)
{
Q_D(QDeclarativeItem);
- d->_keepMouse = keep;
+ d->keepMouse = keep;
}
/*!
@@ -2416,6 +2416,8 @@ QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const
void QDeclarativeItemPrivate::focusChanged(bool flag)
{
Q_Q(QDeclarativeItem);
+ if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent)
+ emit q->wantsFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange()
emit q->focusChanged(flag);
}
@@ -2590,7 +2592,7 @@ QDeclarativeListProperty<QGraphicsTransform> QDeclarativeItem::transform()
void QDeclarativeItem::classBegin()
{
Q_D(QDeclarativeItem);
- d->_componentComplete = false;
+ d->componentComplete = false;
if (d->_stateGroup)
d->_stateGroup->classBegin();
if (d->_anchors)
@@ -2608,7 +2610,7 @@ void QDeclarativeItem::classBegin()
void QDeclarativeItem::componentComplete()
{
Q_D(QDeclarativeItem);
- d->_componentComplete = true;
+ d->componentComplete = true;
if (d->_stateGroup)
d->_stateGroup->componentComplete();
if (d->_anchors) {
@@ -2626,7 +2628,7 @@ QDeclarativeStateGroup *QDeclarativeItemPrivate::_states()
Q_Q(QDeclarativeItem);
if (!_stateGroup) {
_stateGroup = new QDeclarativeStateGroup;
- if (!_componentComplete)
+ if (!componentComplete)
_stateGroup->classBegin();
QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)),
q, SIGNAL(stateChanged(QString)));
@@ -3107,7 +3109,10 @@ void QDeclarativeItem::setSize(const QSizeF &size)
/*! \internal */
bool QDeclarativeItem::wantsFocus() const
{
- return focusItem() != 0;
+ Q_D(const QDeclarativeItem);
+ return focusItem() == this ||
+ (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) ||
+ (!parentItem() && focusItem() != 0);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index fb416c2..bc5d809 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -120,11 +120,11 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate
public:
QDeclarativeItemPrivate()
: _anchors(0), _contents(0),
- _baselineOffset(0),
+ baselineOffset(0),
_anchorLines(0),
_stateGroup(0), origin(QDeclarativeItem::Center),
widthValid(false), heightValid(false),
- _componentComplete(true), _keepMouse(false),
+ componentComplete(true), keepMouse(false),
smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0),
mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0)
{
@@ -144,12 +144,10 @@ public:
QDeclarative_setParent_noEvent(q, parent);
q->setParentItem(parent);
}
- _baselineOffset.invalidate();
+ baselineOffset.invalidate();
mouseSetsFocus = false;
}
- QString _id;
-
// Private Properties
qreal width() const;
void setWidth(qreal);
@@ -203,7 +201,7 @@ public:
if (!_anchors) {
Q_Q(QDeclarativeItem);
_anchors = new QDeclarativeAnchors(q);
- if (!_componentComplete)
+ if (!componentComplete)
_anchors->classBegin();
}
return _anchors;
@@ -211,7 +209,7 @@ public:
QDeclarativeAnchors *_anchors;
QDeclarativeContents *_contents;
- QDeclarativeNullableValue<qreal> _baselineOffset;
+ QDeclarativeNullableValue<qreal> baselineOffset;
struct AnchorLines {
AnchorLines(QGraphicsObject *);
@@ -260,8 +258,8 @@ public:
QDeclarativeItem::TransformOrigin origin:4;
bool widthValid:1;
bool heightValid:1;
- bool _componentComplete:1;
- bool _keepMouse:1;
+ bool componentComplete:1;
+ bool keepMouse:1;
bool smooth:1;
bool transformOriginDirty : 1;
bool doneEventPreHandler : 1;
@@ -286,7 +284,9 @@ public:
// Reimplemented from QGraphicsItemPrivate
virtual void subFocusItemChange()
{
- emit q_func()->wantsFocusChanged(subFocusItem != 0);
+ if (flags & QGraphicsItem::ItemIsFocusScope || !parent)
+ emit q_func()->wantsFocusChanged(subFocusItem != 0);
+ //see also QDeclarativeItemPrivate::focusChanged
}
// Reimplemented from QGraphicsItemPrivate
diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index a7c445d..e95dfc7 100644
--- a/src/imports/particles/qdeclarativeparticles.cpp
+++ b/src/imports/particles/qdeclarativeparticles.cpp
@@ -1232,7 +1232,7 @@ void QDeclarativeParticles::burst(int count, int emissionRate)
void QDeclarativeParticlesPainter::updateSize()
{
- if (!d->_componentComplete)
+ if (!d->componentComplete)
return;
const int parentX = parentItem()->x();
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml
new file mode 100644
index 0000000..d439875
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml
@@ -0,0 +1,20 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width:200; height:200
+
+ property real myValue: 0
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 100
+ height: 100
+ color: "green"
+ smooth: true
+ rotation: myValue
+ Behavior on rotation {
+ RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 70739fb..5c2c145 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <qsignalspy.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeview.h>
@@ -78,6 +79,7 @@ private slots:
void dontStart();
void startup();
void groupedPropertyCrash();
+ void runningTrue();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -366,6 +368,22 @@ void tst_qdeclarativebehaviors::groupedPropertyCrash()
QVERIFY(rect); //don't crash
}
+//QTBUG-5491
+void tst_qdeclarativebehaviors::runningTrue()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *animation = rect->findChild<QDeclarativeAbstractAnimation*>("rotAnim");
+ QVERIFY(animation);
+
+ QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
+ rect->setProperty("myValue", 180);
+ QTRY_VERIFY(runningSpy.count() > 0);
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml
new file mode 100644
index 0000000..6c39f20
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml
@@ -0,0 +1,28 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width:300; height:400
+
+ property bool focus1: root.wantsFocus
+ property bool focus2: item1.wantsFocus
+ property bool focus3: fs1.wantsFocus
+ property bool focus4: fs2.wantsFocus
+ property bool focus5: theItem.wantsFocus
+
+ Item {
+ id: item1
+ FocusScope {
+ id: fs1
+ focus: true
+ FocusScope {
+ id: fs2
+ focus: true
+ Item {
+ id: theItem
+ focus: true
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
index 5904fd6..af9c420 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
@@ -8,10 +8,10 @@ Rectangle {
FocusScope {
id: firstScope
+ objectName: "item0"
focus: true
Rectangle {
- objectName: "item0"
height: 120; width: 420
color: "transparent"
@@ -44,9 +44,9 @@ Rectangle {
FocusScope {
id: secondScope
+ objectName: "item3"
Rectangle {
- objectName: "item3"
y: 160; height: 120; width: 420
color: "transparent"
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
index 6b09c29..aa43ba8 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
@@ -9,12 +9,12 @@ Rectangle {
FocusScope {
id: myScope
+ objectName: "item0"
focus: true
Keys.onDigit9Pressed: console.log("Error - FocusScope")
Rectangle {
- objectName: "item0"
height: 120
width: 420
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
index d67ec57..cdb5164 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
@@ -9,12 +9,12 @@ Rectangle {
FocusScope {
id: myScope
+ objectName: "item0"
focus: true
Keys.onReturnPressed: console.log("Error - FocusScope")
Rectangle {
- objectName: "item0"
height: 120
width: 420
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
index 7732e6d..2559087 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -68,6 +68,7 @@ private slots:
void noFocus();
void textEdit();
void forceFocus();
+ void noParentFocus();
};
/*
@@ -97,7 +98,7 @@ void tst_qdeclarativefocusscope::basic()
QDeclarativeView *view = new QDeclarativeView;
view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml"));
- QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0"));
QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
@@ -228,7 +229,7 @@ void tst_qdeclarativefocusscope::textEdit()
QDeclarativeView *view = new QDeclarativeView;
view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml"));
- QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0"));
QDeclarativeTextEdit *item1 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item1"));
QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
QDeclarativeTextEdit *item3 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item3"));
@@ -283,10 +284,10 @@ void tst_qdeclarativefocusscope::forceFocus()
QDeclarativeView *view = new QDeclarativeView;
view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml"));
- QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeFocusScope *item0 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item0"));
QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
+ QDeclarativeFocusScope *item3 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item3"));
QDeclarativeRectangle *item4 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item4"));
QDeclarativeRectangle *item5 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item5"));
QVERIFY(item0 != 0);
@@ -333,6 +334,20 @@ void tst_qdeclarativefocusscope::forceFocus()
delete view;
}
+void tst_qdeclarativefocusscope::noParentFocus()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml"));
+ QVERIFY(view->rootObject());
+
+ QVERIFY(view->rootObject()->property("focus1") == true);
+ QVERIFY(view->rootObject()->property("focus2") == false);
+ QVERIFY(view->rootObject()->property("focus3") == true);
+ QVERIFY(view->rootObject()->property("focus4") == true);
+ QVERIFY(view->rootObject()->property("focus5") == true);
+
+ delete view;
+}
QTEST_MAIN(tst_qdeclarativefocusscope)
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index 4a57def..ffb2105 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -703,11 +703,8 @@ void tst_QDeclarativeItem::propertyChanges()
QCOMPARE(focusArguments.at(0).toBool(), true);
QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(parentItem->wantsFocus(), true);
- QCOMPARE(wantsFocusSpy.count(),1);
- QList<QVariant> wantsFocusArguments = wantsFocusSpy.first();
- QVERIFY(wantsFocusArguments.count() == 1);
- QCOMPARE(wantsFocusArguments.at(0).toBool(), true);
+ QCOMPARE(parentItem->wantsFocus(), false);
+ QCOMPARE(wantsFocusSpy.count(),0);
delete canvas;
}