summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-03 05:25:14 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-03 05:25:14 (GMT)
commit135e8cd5be1b15a265f11f9e5dc99091d64dc090 (patch)
tree2eaaf42f8f01b71e28aab2c54157125591935989
parent28093fa09de04d0633c261a91fd3746c107963fc (diff)
parent76f8d4eba12cd806270c145f908c96d4cd1c72cf (diff)
downloadQt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.zip
Qt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.tar.gz
Qt-135e8cd5be1b15a265f11f9e5dc99091d64dc090.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp26
-rw-r--r--src/declarative/qml/qmlcompiler.cpp51
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp5
-rw-r--r--tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml29
-rw-r--r--tests/auto/declarative/qmlecmascript/data/listToVariant.qml5
-rw-r--r--tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml10
-rw-r--r--tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml8
-rw-r--r--tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml29
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp28
11 files changed, 182 insertions, 17 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 05868ba..890d3ad 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -374,6 +374,7 @@ FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex)
model->completeItem();
listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
+ unrequestedItems.remove(listItem->item);
}
requestedIndex = 0;
return listItem;
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index 6835427..f26496e 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -57,13 +57,12 @@
#include <QFile>
#include <QEvent>
#include <QGraphicsSceneMouseEvent>
+#include <QtCore/qnumeric.h>
#include <QtScript/qscriptengine.h>
#include <QtGui/qgraphicstransform.h>
#include <QtGui/qgraphicseffect.h>
#include <qlistmodelinterface_p.h>
-#include <math.h>
-
QT_BEGIN_NAMESPACE
#ifndef FLT_MAX
@@ -2845,7 +2844,7 @@ qreal QmlGraphicsItem::width() const
void QmlGraphicsItem::setWidth(qreal w)
{
Q_D(QmlGraphicsItem);
- if (isnan(w))
+ if (qIsNaN(w))
return;
d->widthValid = true;
@@ -2917,7 +2916,7 @@ qreal QmlGraphicsItem::height() const
void QmlGraphicsItem::setHeight(qreal h)
{
Q_D(QmlGraphicsItem);
- if (isnan(h))
+ if (qIsNaN(h))
return;
d->heightValid = true;
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 8bde152..ad0aa04 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -605,6 +605,7 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex)
if (listItem->attached->m_prevSection != listItem->attached->m_section)
createSection(listItem);
}
+ unrequestedItems.remove(listItem->item);
}
requestedIndex = -1;
@@ -731,6 +732,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
if (footer)
updateFooter();
updateViewport();
+ updateUnrequestedPositions();
} else if (!doBuffer && buffer && bufferMode != NoBuffer) {
refill(from, to, true);
}
@@ -765,7 +767,6 @@ void QmlGraphicsListViewPrivate::layout()
updateHeader();
if (footer)
updateFooter();
- updateUnrequestedPositions();
updateViewport();
}
@@ -779,14 +780,20 @@ void QmlGraphicsListViewPrivate::updateUnrequestedIndexes()
void QmlGraphicsListViewPrivate::updateUnrequestedPositions()
{
- QHash<QmlGraphicsItem*,int>::const_iterator it;
- for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
- if (visibleItem(*it))
- continue;
- if (orient == QmlGraphicsListView::Vertical)
- it.key()->setY(positionAt(*it));
- else
- it.key()->setX(positionAt(*it));
+ Q_Q(QmlGraphicsListView);
+ if (unrequestedItems.count()) {
+ qreal pos = position();
+ QHash<QmlGraphicsItem*,int>::const_iterator it;
+ for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
+ QmlGraphicsItem *item = it.key();
+ if (orient == QmlGraphicsListView::Vertical) {
+ if (item->y() + item->height() > pos && item->y() < pos + q->height())
+ item->setY(positionAt(*it));
+ } else {
+ if (item->x() + item->width() > pos && item->x() < pos + q->width())
+ item->setX(positionAt(*it));
+ }
+ }
}
}
@@ -2611,6 +2618,7 @@ void QmlGraphicsListView::destroyRemoved()
void QmlGraphicsListView::itemsMoved(int from, int to, int count)
{
Q_D(QmlGraphicsListView);
+ d->updateUnrequestedIndexes();
if (d->visibleItems.isEmpty()) {
refill();
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index c6a5d82..a7ae649 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -680,6 +680,13 @@ void QmlCompiler::compileTree(Object *tree)
QmlEnginePrivate::get(engine)->registerCompositeType(output);
}
+static bool ValuePtrLessThan(const Value *t1, const Value *t2)
+{
+ return t1->location.start.line < t2->location.start.line ||
+ (t1->location.start.line == t2->location.start.line &&
+ t1->location.start.column < t2->location.start.column);
+}
+
bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
{
componentStat.objects++;
@@ -739,9 +746,46 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
}
+ // Merge
+ Property *defaultProperty = 0;
+ Property *skipProperty = 0;
+ if (obj->defaultProperty) {
+ const QMetaObject *metaObject = obj->metaObject();
+ Q_ASSERT(metaObject);
+ QMetaProperty p = QmlMetaType::defaultProperty(metaObject);
+ if (p.name()) {
+ Property *explicitProperty = obj->getProperty(p.name(), false);
+ if (explicitProperty && !explicitProperty->value) {
+ skipProperty = explicitProperty;
+
+ defaultProperty = new Property;
+ defaultProperty->parent = obj;
+ defaultProperty->isDefault = true;
+ defaultProperty->location = obj->defaultProperty->location;
+ defaultProperty->listValueRange = obj->defaultProperty->listValueRange;
+ defaultProperty->listCommaPositions = obj->defaultProperty->listCommaPositions;
+
+ defaultProperty->values = obj->defaultProperty->values;
+ defaultProperty->values += explicitProperty->values;
+ foreach(Value *value, defaultProperty->values)
+ value->addref();
+ qSort(defaultProperty->values.begin(), defaultProperty->values.end(), ValuePtrLessThan);
+
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ } else {
+ defaultProperty = obj->defaultProperty;
+ defaultProperty->addref();
+ }
+ }
+
// Build all explicit properties specified
foreach(Property *prop, obj->properties) {
+ if (prop == skipProperty)
+ continue;
if (prop->name == "id")
continue;
@@ -771,8 +815,8 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
// Build the default property
- if (obj->defaultProperty) {
- Property *prop = obj->defaultProperty;
+ if (defaultProperty) {
+ Property *prop = defaultProperty;
bool canDefer = false;
if (isCustomParser) {
@@ -794,6 +838,9 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
prop->isDeferred = true;
}
+ if (defaultProperty)
+ defaultProperty->release();
+
// Compile custom parser parts
if (isCustomParser && !customProps.isEmpty()) {
QmlCustomParser *cp = output->types.at(obj->type).type->customParser();
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 94e9fdd..500bdd0 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -668,6 +668,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qnumeric.h>
#include <QtGui/qapplication.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qpainter.h>
@@ -3439,7 +3440,7 @@ void QGraphicsItem::setX(qreal x)
if (d_ptr->inDestructor)
return;
- if (isnan(x))
+ if (qIsNaN(x))
return;
d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y()));
@@ -3466,7 +3467,7 @@ void QGraphicsItem::setY(qreal y)
if (d_ptr->inDestructor)
return;
- if (isnan(y))
+ if (qIsNaN(y))
return;
d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y));
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml
new file mode 100644
index 0000000..128db69
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml
@@ -0,0 +1,29 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ Component.onCompleted: {
+ flagProperty = "FlagVal1 | FlagVal3"
+ enumProperty = "EnumVal2"
+ stringProperty = "Hello World!"
+ uintProperty = 10
+ intProperty = -19
+ realProperty = 23.2
+ doubleProperty = -19.7
+ floatProperty = 8.5
+ colorProperty = "red"
+ dateProperty = "1982-11-25"
+ timeProperty = "11:11:32"
+ dateTimeProperty = "2009-05-12T13:22:01"
+ pointProperty = "99,13"
+ pointFProperty = "-10.1,12.3"
+ sizeProperty = "99x13"
+ sizeFProperty = "0.1x0.2"
+ rectProperty = "9,7,100x200"
+ rectFProperty = "1000.1,-10.9,400x90.99"
+ boolProperty = true
+ variantProperty = "Hello World!"
+ vectorProperty = "10,1,2.2"
+ urlProperty = "main.qml"
+ }
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml b/tests/auto/declarative/qmlecmascript/data/listToVariant.qml
new file mode 100644
index 0000000..47f4e50
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/listToVariant.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ property var test: children
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml
new file mode 100644
index 0000000..e73d38e2
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml
@@ -0,0 +1,10 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ resettableProperty: 19
+
+ function doReset() {
+ resettableProperty = undefined;
+ }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml b/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml
new file mode 100644
index 0000000..3987a3c
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+QtObject {
+ property int a: 10
+ property int b: 10 + a
+ property QtObject c: QtObject {}
+ property list<QtObject> d: [ QtObject {}, QtObject {} ]
+}
diff --git a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml b/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml
new file mode 100644
index 0000000..3651511
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml
@@ -0,0 +1,29 @@
+import Test 1.0
+import Qt 4.6
+
+MyContainer {
+ QtObject {
+ property int index: 0
+ }
+
+ QtObject {
+ property int index: 1
+ }
+
+ children: [
+ QtObject {
+ property int index: 2
+ },
+ QtObject {
+ property int index: 3
+ }
+ ]
+
+ QtObject {
+ property int index: 4
+ }
+
+ QtObject {
+ property int index: 5
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index d37c7b4..54442d5 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -109,6 +109,8 @@ private slots:
void i18n_data();
void onCompleted();
void scriptString();
+ void defaultPropertyListOrder();
+ void declaredPropertyValues();
void importsBuiltin_data();
void importsBuiltin();
@@ -1019,6 +1021,32 @@ void tst_qmllanguage::scriptString()
QCOMPARE(object->grouped()->script().context(), qmlContext(object));
}
+// Check that default property assignments are correctly spliced into explicit
+// property assignments
+void tst_qmllanguage::defaultPropertyListOrder()
+{
+ QmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
+ VERIFY_ERRORS(0);
+
+ MyContainer *container = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->children()->count(), 6);
+ QCOMPARE(container->children()->at(0)->property("index"), QVariant(0));
+ QCOMPARE(container->children()->at(1)->property("index"), QVariant(1));
+ QCOMPARE(container->children()->at(2)->property("index"), QVariant(2));
+ QCOMPARE(container->children()->at(3)->property("index"), QVariant(3));
+ QCOMPARE(container->children()->at(4)->property("index"), QVariant(4));
+ QCOMPARE(container->children()->at(5)->property("index"), QVariant(5));
+}
+
+void tst_qmllanguage::declaredPropertyValues()
+{
+ QmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
+ QEXPECT_FAIL("", "QTBUG-7860", Abort);
+ VERIFY_ERRORS(0);
+}
+
// Check that first child of qml is of given type. Empty type insists on error.
void tst_qmllanguage::testType(const QString& qml, const QString& type)
{