diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 17:28:53 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 17:28:53 (GMT) |
commit | 40c018c7a0c8e95fcf928a6c1ce5301f16ffa5e3 (patch) | |
tree | ae81752150551e52207add26de6a3b142be060b7 /src/declarative/graphicsitems | |
parent | e06d011cc08de370ece3b0c324b0a735a2625820 (diff) | |
parent | 4029da6fae201512b15f1e088bf720b0c37e1437 (diff) | |
download | Qt-40c018c7a0c8e95fcf928a6c1ce5301f16ffa5e3.zip Qt-40c018c7a0c8e95fcf928a6c1ce5301f16ffa5e3.tar.gz Qt-40c018c7a0c8e95fcf928a6c1ce5301f16ffa5e3.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:
update Browser.qml to run again
Update Autotests
Probably fix compile on windows
Fix typo in docs
Probably fix compile
Fix qdeclarativevaluetype::font() autotest
Initialize member variable in QDeclarativeGridViewAttached
Handle itemsInserted/Removed/Moved() correctly for repeater.
Add QML support for methods returning QList<QObject *>
Compile
Update configure.exe to include declarative module by default
Make QDeclarativeItem NOTIFY signals canonical
Integrate QML's object ownership with the JS collector
Remove unused data member.
Fix warning.
Fix warnings and change geometry-related functions to use reals.
When flicking with snap, bias towards moving at least one item.
Doc fix.
Diffstat (limited to 'src/declarative/graphicsitems')
18 files changed, 139 insertions, 102 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp index 1977817..eb5b6ce 100644 --- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp +++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp @@ -65,12 +65,12 @@ public: if (graphicsObject && graphicsObject->isWidget()) { if (!on) { graphicsObject->removeEventFilter(q); - QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); - QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); + QObject::disconnect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize())); + QObject::disconnect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize())); } else { graphicsObject->installEventFilter(q); - QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); - QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); + QObject::connect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize())); + QObject::connect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize())); } } } diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 60ffbe2..f35b903 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -755,14 +755,15 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m vTime = timeline.time(); } } else if (snapMode != QDeclarativeGridView::NoSnap) { - qreal pos = qMax(qMin(snapPosAt(position()) - highlightRangeStart, -maxExtent), -minExtent); - qreal dist = qAbs(data.move + pos); + qreal pos = -snapPosAt(-(data.move.value() - highlightRangeStart)) + highlightRangeStart; + pos = qMin(qMax(pos, maxExtent), minExtent); + qreal dist = qAbs(data.move.value() - pos); if (dist > 0) { timeline.reset(data.move); if (fixupDuration) - timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); else - data.move.setValue(-pos); + data.move.setValue(pos); vTime = timeline.time(); } } else { @@ -788,7 +789,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m if (FxGridItem *item = firstVisibleItem()) maxDistance = qAbs(item->rowPos() + data.move.value()); } else if (data.move.value() < minExtent) { - maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0)); + maxDistance = qAbs(minExtent - data.move.value()); } if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange) data.flickTarget = minExtent; @@ -797,7 +798,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m qreal pos = snapPosAt(-data.move.value()) + rowSize(); maxDistance = qAbs(pos + data.move.value()); } else if (data.move.value() > maxExtent) { - maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0); + maxDistance = qAbs(maxExtent - data.move.value()); } if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange) data.flickTarget = maxExtent; @@ -816,7 +817,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m qreal maxAccel = v2 / (2.0f * maxDistance); qreal overshootDist = 0.0; if (maxAccel < accel) { - qreal dist = v2 / (accel * 2.0); + // + rowSize()/4 to encourage moving at least one item in the flick direction + qreal dist = v2 / (accel * 2.0) + rowSize()/4; if (v > 0) dist = -dist; data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart; diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index 787c04c..183bb05 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -192,7 +192,7 @@ class QDeclarativeGridViewAttached : public QObject Q_OBJECT public: QDeclarativeGridViewAttached(QObject *parent) - : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} + : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} ~QDeclarativeGridViewAttached() {} Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9d6b2a0..7c6c46b 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -273,7 +273,7 @@ void QDeclarativeContents::calcHeight() m_height = qMax(bottom - top, qreal(0.0)); if (m_height != oldheight || m_y != oldy) - emit rectChanged(); + emit rectChanged(rectF()); } //TODO: optimization: only check sender(), if there is one @@ -301,7 +301,7 @@ void QDeclarativeContents::calcWidth() m_width = qMax(right - left, qreal(0.0)); if (m_width != oldwidth || m_x != oldx) - emit rectChanged(); + emit rectChanged(rectF()); } void QDeclarativeContents::setItem(QDeclarativeItem *item) @@ -313,11 +313,11 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item) QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i)); if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? continue; - connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); + connect(child, SIGNAL(heightChanged(qreal)), this, SLOT(calcHeight())); connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); + connect(child, SIGNAL(widthChanged(qreal)), this, SLOT(calcWidth())); connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); - connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged())); + connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); } calcHeight(); @@ -1652,7 +1652,7 @@ void QDeclarativeItem::setClip(bool c) if (clip() == c) return; setFlag(ItemClipsChildrenToShape, c); - emit clipChanged(); + emit clipChanged(c); } /*! @@ -1792,11 +1792,11 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, if (newGeometry.x() != oldGeometry.x()) emit xChanged(); if (newGeometry.width() != oldGeometry.width()) - emit widthChanged(); + emit widthChanged(newGeometry.width()); if (newGeometry.y() != oldGeometry.y()) emit yChanged(); if (newGeometry.height() != oldGeometry.height()) - emit heightChanged(); + emit heightChanged(newGeometry.height()); for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); @@ -2058,7 +2058,6 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) return; d->_baselineOffset = offset; - emit baselineOffsetChanged(); for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); @@ -2068,6 +2067,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) anchor->updateVerticalAnchors(); } } + emit baselineOffsetChanged(offset); } /*! @@ -2214,7 +2214,7 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep) } /*! - \qmlmethod object Item::mapFromItem(Item item, int x, int y) + \qmlmethod object Item::mapFromItem(Item item, real x, real y) Maps the point (\a x, \a y), which is in \a item's coordinate system, to this item's coordinate system, and returns an object with \c x and \c y @@ -2223,7 +2223,7 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep) If \a item is a \c null value, this maps the point from the coordinate system of the root QML view. */ -QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int y) const +QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qreal y) const { QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject()); @@ -2234,13 +2234,13 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int // If QGraphicsItem::mapFromItem() is called with 0, behaves the same as mapFromScene() QPointF p = qobject_cast<QGraphicsItem*>(this)->mapFromItem(itemObj, x, y); - sv.setProperty("x", p.x()); - sv.setProperty("y", p.y()); + sv.setProperty(QLatin1String("x"), p.x()); + sv.setProperty(QLatin1String("y"), p.y()); return sv; } /*! - \qmlmethod object Item::mapToItem(Item item, int x, int y) + \qmlmethod object Item::mapToItem(Item item, real x, real y) Maps the point (\a x, \a y), which is in this item's coordinate system, to \a item's coordinate system, and returns an object with \c x and \c y @@ -2249,7 +2249,7 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int If \a item is a \c null value, this maps \a x and \a y to the coordinate system of the root QML view. */ -QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, int x, int y) const +QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qreal y) const { QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject(); QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject()); @@ -2260,23 +2260,15 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, int x, int y) // If QGraphicsItem::mapToItem() is called with 0, behaves the same as mapToScene() QPointF p = qobject_cast<QGraphicsItem*>(this)->mapToItem(itemObj, x, y); - sv.setProperty("x", p.x()); - sv.setProperty("y", p.y()); + sv.setProperty(QLatin1String("x"), p.x()); + sv.setProperty(QLatin1String("y"), p.y()); return sv; } -/*! - \internal - - This function emits the \e focusChanged signal. - - Subclasses overriding this function should call up - to their base class. -*/ -void QDeclarativeItem::focusChanged(bool flag) +void QDeclarativeItemPrivate::focusChanged(bool flag) { - Q_UNUSED(flag); - emit focusChanged(); + Q_Q(QDeclarativeItem); + emit q->focusChanged(flag); } /*! \internal */ @@ -2569,14 +2561,16 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const /*! \internal */ bool QDeclarativeItem::sceneEvent(QEvent *event) { + Q_D(QDeclarativeItem); if (event->type() == QEvent::KeyPress) { QKeyEvent *k = static_cast<QKeyEvent *>(event); - if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { keyPressEvent(static_cast<QKeyEvent *>(event)); if (!event->isAccepted()) return QGraphicsItem::sceneEvent(event); + else + return true; } else { return QGraphicsItem::sceneEvent(event); } @@ -2585,7 +2579,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { - focusChanged(hasFocus()); + d->focusChanged(hasFocus()); } return rv; } @@ -2598,7 +2592,7 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, Q_D(const QDeclarativeItem); switch (change) { case ItemParentHasChanged: - emit parentChanged(); + emit parentChanged(parentItem()); break; case ItemChildAddedChange: case ItemChildRemovedChange: @@ -2711,7 +2705,7 @@ void QDeclarativeItem::setSmooth(bool smooth) if (d->smooth == smooth) return; d->smooth = smooth; - emit smoothChanged(); + emit smoothChanged(smooth); update(); } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 2053eba..9b85ba3 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -42,8 +42,8 @@ #ifndef QDECLARATIVEITEM_H #define QDECLARATIVEITEM_H -#include <qdeclarative.h> -#include <qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarative.h> +#include <QtDeclarative/qdeclarativecomponent.h> #include <QtCore/QObject> #include <QtCore/QList> @@ -161,8 +161,8 @@ public: bool keepMouseGrab() const; void setKeepMouseGrab(bool); - Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, int x, int y) const; - Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, int x, int y) const; + Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const; + Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const; QDeclarativeAnchorLine left() const; QDeclarativeAnchorLine right() const; @@ -173,18 +173,18 @@ public: QDeclarativeAnchorLine baseline() const; Q_SIGNALS: - void widthChanged(); - void heightChanged(); + void widthChanged(qreal); + void heightChanged(qreal); void childrenChanged(); - void childrenRectChanged(); - void baselineOffsetChanged(); + void childrenRectChanged(const QRectF &); + void baselineOffsetChanged(qreal); void stateChanged(const QString &); - void focusChanged(); - void wantsFocusChanged(); - void parentChanged(); + void focusChanged(bool); + void wantsFocusChanged(bool); + void parentChanged(QDeclarativeItem *); void transformOriginChanged(TransformOrigin); - void smoothChanged(); - void clipChanged(); + void smoothChanged(bool); + void clipChanged(bool); protected: bool isComponentComplete() const; @@ -199,7 +199,6 @@ protected: virtual void classBegin(); virtual void componentComplete(); - virtual void focusChanged(bool); virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); virtual void inputMethodEvent(QInputMethodEvent *); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index e424970..55df063 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -91,7 +91,7 @@ public Q_SLOTS: void calcWidth(); Q_SIGNALS: - void rectChanged(); + void rectChanged(QRectF); private: QDeclarativeItem *m_item; @@ -101,7 +101,7 @@ private: qreal m_height; }; -class QDeclarativeItemPrivate : public QGraphicsItemPrivate +class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate { Q_DECLARE_PUBLIC(QDeclarativeItem) @@ -240,7 +240,7 @@ public: // Reimplemented from QGraphicsItemPrivate virtual void subFocusItemChange() { - emit q_func()->wantsFocusChanged(); + emit q_func()->wantsFocusChanged(subFocusItem != 0); } // Reimplemented from QGraphicsItemPrivate @@ -255,9 +255,11 @@ public: } } + virtual void focusChanged(bool); + static int consistentTime; static QTime currentTime(); - static void Q_DECLARATIVE_EXPORT setConsistentTime(int t); + static void setConsistentTime(int t); static void start(QTime &); static int elapsed(QTime &); static int restart(QTime &); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index d54bb70..6385ddd 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -557,7 +557,7 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item) return; if (trackedItem == item) { const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); + const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal)); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); trackedItem = 0; @@ -748,7 +748,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem() FxListItem *oldTracked = trackedItem; const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); + const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal)); if (trackedItem && item != trackedItem) { QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); @@ -1124,7 +1124,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m if (FxListItem *item = firstVisibleItem()) maxDistance = qAbs(item->position() + data.move.value()); } else if (data.move.value() < minExtent) { - maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0)); + maxDistance = qAbs(minExtent - data.move.value()); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) data.flickTarget = minExtent; @@ -1133,7 +1133,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m if (FxListItem *item = nextVisibleItem()) maxDistance = qAbs(item->position() + data.move.value()); } else if (data.move.value() > maxExtent) { - maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0); + maxDistance = qAbs(maxExtent - data.move.value()); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) data.flickTarget = maxExtent; @@ -1156,7 +1156,8 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m qreal v2 = v * v; qreal maxAccel = v2 / (2.0f * maxDistance); if (maxAccel < accel) { - qreal dist = v2 / (accel * 2.0); + // + averageSize/4 to encourage moving at least one item in the flick direction + qreal dist = v2 / (accel * 2.0) + averageSize/4; if (v > 0) dist = -dist; data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart; @@ -1166,6 +1167,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } else { data.flickTarget = velocity > 0 ? minExtent : maxExtent; overshootDist = overShoot ? overShootDistance(v, vSize) : 0; + qDebug() << "boundary" << overshootDist; } timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); @@ -1956,10 +1958,11 @@ void QDeclarativeListView::viewportMoved() if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { // reposition highlight qreal pos = d->highlight->position(); - if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size()) - pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size(); - if (pos < d->position() + d->highlightRangeStart) - pos = d->position() + d->highlightRangeStart; + qreal viewPos = qRound(d->position()); + if (pos > viewPos + d->highlightRangeEnd - 1 - d->highlight->size()) + pos = viewPos + d->highlightRangeEnd - 1 - d->highlight->size(); + if (pos < viewPos + d->highlightRangeStart) + pos = viewPos + d->highlightRangeStart; d->highlight->setPosition(pos); // update current index diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index ec7aa62..13195af 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -383,7 +383,6 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) } d->dragged = false; setHovered(true); - d->start = event->pos(); d->startScene = event->scenePos(); // we should only start timer if pressAndHold is connected to. if (d->isConnected("pressAndHold(QDeclarativeMouseEvent*)")) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h index d4871f2..88206cd 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h @@ -101,7 +101,6 @@ public: bool dragY : 1; bool dragged : 1; QDeclarativeDrag *drag; - QPointF start; QPointF startScene; qreal startX; qreal startY; diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index ab6007a..28a93d2 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -211,8 +211,8 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem() */ void QDeclarativePaintedItem::init() { - connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache())); - connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache())); + connect(this,SIGNAL(widthChanged(qreal)),this,SLOT(clearCache())); + connect(this,SIGNAL(heightChanged(qreal)),this,SLOT(clearCache())); connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache())); } diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 1212e89..0f59a70 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -212,19 +212,22 @@ void QDeclarativeBasePositioner::prePositioning() QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children; qSort(children.begin(), children.end(), d->insertionOrder); + QPODVector<PositionedItem,8> oldItems; + positionedItems.copyAndClear(oldItems); for (int ii = 0; ii < children.count(); ++ii) { QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii)); if (!child) continue; PositionedItem *item = 0; PositionedItem posItem(child); - int wIdx = positionedItems.find(posItem); + int wIdx = oldItems.find(posItem); if (wIdx < 0) { d->watchChanges(child); positionedItems.append(posItem); item = &positionedItems[positionedItems.count()-1]; } else { - item = &positionedItems[wIdx]; + item = &oldItems[wIdx]; + positionedItems.append(*item); } if (child->opacity() <= 0.0 || !child->isVisible()) { item->isVisible = false; diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index e4cd499..b9696c8 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -296,6 +296,8 @@ void QDeclarativeRepeater::clear() void QDeclarativeRepeater::regenerate() { Q_D(QDeclarativeRepeater); + if (!isComponentComplete()) + return; clear(); @@ -312,23 +314,65 @@ void QDeclarativeRepeater::regenerate() } } -void QDeclarativeRepeater::itemsInserted(int, int) +void QDeclarativeRepeater::itemsInserted(int index, int count) { - regenerate(); + Q_D(QDeclarativeRepeater); + if (!isComponentComplete()) + return; + for (int i = 0; i < count; ++i) { + int modelIndex = index + i; + QDeclarativeItem *item = d->model->item(modelIndex); + if (item) { + item->setParent(parentItem()); + if (modelIndex < d->deletables.count()) + item->stackBefore(d->deletables.at(modelIndex)); + else + item->stackBefore(this); + d->deletables.insert(modelIndex, item); + } + } } -void QDeclarativeRepeater::itemsRemoved(int, int) +void QDeclarativeRepeater::itemsRemoved(int index, int count) { - regenerate(); + Q_D(QDeclarativeRepeater); + if (!isComponentComplete()) + return; + while (count--) { + QDeclarativeItem *item = d->deletables.takeAt(index); + if (item) { + item->setParentItem(this); + d->model->release(item); + } + } } -void QDeclarativeRepeater::itemsMoved(int,int,int) +void QDeclarativeRepeater::itemsMoved(int from, int to, int count) { - regenerate(); + Q_D(QDeclarativeRepeater); + if (!isComponentComplete()) + return; + QList<QDeclarativeItem*> removed; + int removedCount = count; + while (removedCount--) + removed << d->deletables.takeAt(from); + for (int i = 0; i < count; ++i) + d->deletables.insert(to + i, removed.at(i)); + for (int i = 0; i < d->model->count(); ++i) { + if (i < from && i < to) + continue; + QDeclarativeItem *item = d->deletables.at(i); + if (i < d->deletables.count()-1) + item->stackBefore(d->deletables.at(i+1)); + else + item->stackBefore(this); + } } void QDeclarativeRepeater::modelReset() { + if (!isComponentComplete()) + return; regenerate(); } diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index be73b39..dbae47d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -760,17 +760,11 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) QDeclarativePaintedItem::keyReleaseEvent(event); } -/*! - \overload - Handles changing of the focus property. Focus is applied to the control - even if the edit does not have active focus. This is because things - like KeyProxy can give the behavior of focus even when hasFocus() isn't - true. -*/ -void QDeclarativeTextEdit::focusChanged(bool hasFocus) +void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) { - setCursorVisible(hasFocus); - QDeclarativeItem::focusChanged(hasFocus); + Q_Q(QDeclarativeTextEdit); + q->setCursorVisible(hasFocus); + QDeclarativeItemPrivate::focusChanged(hasFocus); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 6183b1d..b1682c4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -215,8 +215,6 @@ protected: void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); - void focusChanged(bool); - // mouse filter? void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h index 002fac4..dd2a29d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h @@ -80,6 +80,7 @@ public: void updateDefaultTextOption(); void relayoutDocument(); void updateSelection(); + void focusChanged(bool); QString text; QFont font; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 3382628..6df3533 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -636,12 +636,12 @@ int QDeclarativeTextInput::xToPos(int x) return d->control->xToPos(x - d->hscroll); } -void QDeclarativeTextInput::focusChanged(bool hasFocus) +void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) { - Q_D(QDeclarativeTextInput); - d->focused = hasFocus; - setCursorVisible(hasFocus); - QDeclarativeItem::focusChanged(hasFocus); + Q_Q(QDeclarativeTextInput); + focused = hasFocus; + q->setCursorVisible(hasFocus); + QDeclarativeItemPrivate::focusChanged(hasFocus); } void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index f690ae2..6a61c2d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -199,8 +199,6 @@ protected: void keyPressEvent(QKeyEvent* ev); bool event(QEvent *e); - void focusChanged(bool hasFocus); - public Q_SLOTS: void selectAll(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 3d28f40..5d17a55 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -83,6 +83,7 @@ public: void init(); void startCreatingCursor(); + void focusChanged(bool hasFocus); QLineControl* control; |