diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-02-03 05:25:14 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-02-03 05:25:14 (GMT) |
commit | 135e8cd5be1b15a265f11f9e5dc99091d64dc090 (patch) | |
tree | 2eaaf42f8f01b71e28aab2c54157125591935989 /src | |
parent | 28093fa09de04d0633c261a91fd3746c107963fc (diff) | |
parent | 76f8d4eba12cd806270c145f908c96d4cd1c72cf (diff) | |
download | Qt-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
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 1 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsitem.cpp | 7 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview.cpp | 26 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 51 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 5 |
5 files changed, 73 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)); |