diff options
Diffstat (limited to 'src/declarative/graphicsitems')
15 files changed, 150 insertions, 127 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects.cpp b/src/declarative/graphicsitems/qdeclarativeeffects.cpp index efab24e..ea1f9cc 100644 --- a/src/declarative/graphicsitems/qdeclarativeeffects.cpp +++ b/src/declarative/graphicsitems/qdeclarativeeffects.cpp @@ -45,6 +45,7 @@ /*! \qmlclass Blur QGraphicsBlurEffect + \since 4.7 \brief The Blur object provides a blur effect. A blur effect blurs the source item. This effect is useful for reducing details; @@ -80,6 +81,7 @@ /*! \qmlclass Colorize QGraphicsColorizeEffect + \since 4.7 \brief The Colorize object provides a colorize effect. A colorize effect renders the source item with a tint of its color. @@ -106,6 +108,7 @@ /*! \qmlclass DropShadow QGraphicsDropShadowEffect + \since 4.7 \brief The DropShadow object provides a drop shadow effect. A drop shadow effect renders the source item with a drop shadow. The color of @@ -147,6 +150,7 @@ /*! \qmlclass Opacity QGraphicsOpacityEffect + \since 4.7 \brief The Opacity object provides an opacity effect. An opacity effect renders the source with an opacity. This effect is useful diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp index d2cbb54..8be2f40 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents.cpp +++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp @@ -114,6 +114,7 @@ Item { /*! \qmlclass MouseEvent QDeclarativeMouseEvent + \since 4.7 \brief The MouseEvent object provides information about a mouse event. The position of the mouse can be found via the x and y properties. diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 9f19f53..c54ddd0 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -128,7 +128,7 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() , vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false) , pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true) , interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100) - , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(200) + , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600) , horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0) , flickDirection(QDeclarativeFlickable::AutoFlickDirection) { @@ -142,12 +142,29 @@ void QDeclarativeFlickablePrivate::init() QObject::connect(&timeline, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFiltersChildEvents(true); - QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(positionXChanged())); - QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(positionYChanged())); + QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(contentXChanged())); + QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(contentYChanged())); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange())); QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange())); } +/* + Returns the amount to overshoot by given a velocity. + Will be roughly in range 0 - size/4 +*/ +qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size) +{ + Q_Q(QDeclarativeFlickable); + if (maxVelocity <= 0) + return 0.0; + + velocity = qAbs(velocity); + if (velocity > maxVelocity) + velocity = maxVelocity; + qreal dist = size / 4 * velocity / maxVelocity; + return dist; +} + void QDeclarativeFlickablePrivate::flickX(qreal velocity) { Q_Q(QDeclarativeFlickable); @@ -156,12 +173,12 @@ void QDeclarativeFlickablePrivate::flickX(qreal velocity) if (velocity > 0) { const qreal minX = q->minXExtent(); if (_moveX.value() < minX) - maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0)); + maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity,q->width()):0)); flickTargetX = minX; } else { const qreal maxX = q->maxXExtent(); if (_moveX.value() > maxX) - maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0); + maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity,q->width()):0); flickTargetX = maxX; } if (maxDistance > 0) { @@ -194,12 +211,12 @@ void QDeclarativeFlickablePrivate::flickY(qreal velocity) if (velocity > 0) { const qreal minY = q->minYExtent(); if (_moveY.value() < minY) - maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0)); + maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity,q->height()):0)); flickTargetY = minY; } else { const qreal maxY = q->maxYExtent(); if (_moveY.value() > maxY) - maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0); + maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity,q->height()):0); flickTargetY = maxY; } if (maxDistance > 0) { @@ -233,18 +250,24 @@ void QDeclarativeFlickablePrivate::fixupX() if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) { timeline.reset(_moveX); if (_moveX.value() != q->minXExtent()) { - if (fixupDuration) - timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); - else - _moveY.setValue(q->minYExtent()); + if (fixupDuration) { + qreal dist = q->minXExtent() - _moveX; + timeline.move(_moveX, q->minXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); + timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4); + } else { + _moveX.setValue(q->minXExtent()); + } } //emit flickingChanged(); } else if (_moveX.value() < q->maxXExtent()) { timeline.reset(_moveX); - if (fixupDuration) - timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); - else - _moveY.setValue(q->maxYExtent()); + if (fixupDuration) { + qreal dist = q->maxXExtent() - _moveX; + timeline.move(_moveX, q->maxXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); + timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4); + } else { + _moveX.setValue(q->maxXExtent()); + } //emit flickingChanged(); } else { flicked = false; @@ -272,18 +295,24 @@ void QDeclarativeFlickablePrivate::fixupY() if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) { timeline.reset(_moveY); if (_moveY.value() != q->minYExtent()) { - if (fixupDuration) - timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); - else + if (fixupDuration) { + qreal dist = q->minYExtent() - _moveY; + timeline.move(_moveY, q->minYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); + timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4); + } else { _moveY.setValue(q->minYExtent()); + } } //emit flickingChanged(); } else if (_moveY.value() < q->maxYExtent()) { timeline.reset(_moveY); - if (fixupDuration) - timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); - else + if (fixupDuration) { + qreal dist = q->maxYExtent() - _moveY; + timeline.move(_moveY, q->maxYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); + timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4); + } else { _moveY.setValue(q->maxYExtent()); + } //emit flickingChanged(); } else { flicked = false; @@ -336,6 +365,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() /*! \qmlclass Flickable QDeclarativeFlickable + \since 4.7 \brief The Flickable item provides a surface that can be "flicked". \inherits Item @@ -343,7 +373,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() \code Flickable { - width: 200; height: 200; viewportWidth: image.width; viewportHeight: image.height + width: 200; height: 200; contentWidth: image.width; contentHeight: image.height Image { id: image; source: "bigimage.png" } } \endcode @@ -429,20 +459,20 @@ QDeclarativeFlickable::~QDeclarativeFlickable() } /*! - \qmlproperty int Flickable::viewportX - \qmlproperty int Flickable::viewportY + \qmlproperty int Flickable::contentX + \qmlproperty int Flickable::contentY These properties hold the surface coordinate currently at the top-left corner of the Flickable. For example, if you flick an image up 100 pixels, - \c yPosition will be 100. + \c contentY will be 100. */ -qreal QDeclarativeFlickable::viewportX() const +qreal QDeclarativeFlickable::contentX() const { Q_D(const QDeclarativeFlickable); return -d->_moveX.value(); } -void QDeclarativeFlickable::setViewportX(qreal pos) +void QDeclarativeFlickable::setContentX(qreal pos) { Q_D(QDeclarativeFlickable); pos = qRound(pos); @@ -454,13 +484,13 @@ void QDeclarativeFlickable::setViewportX(qreal pos) } } -qreal QDeclarativeFlickable::viewportY() const +qreal QDeclarativeFlickable::contentY() const { Q_D(const QDeclarativeFlickable); return -d->_moveY.value(); } -void QDeclarativeFlickable::setViewportY(qreal pos) +void QDeclarativeFlickable::setContentY(qreal pos) { Q_D(QDeclarativeFlickable); pos = qRound(pos); @@ -506,12 +536,10 @@ void QDeclarativeFlickable::setInteractive(bool interactive) /*! \qmlproperty real Flickable::horizontalVelocity \qmlproperty real Flickable::verticalVelocity - \qmlproperty real Flickable::reportedVelocitySmoothing The instantaneous velocity of movement along the x and y axes, in pixels/sec. The reported velocity is smoothed to avoid erratic output. - reportedVelocitySmoothing determines how much smoothing is applied. */ qreal QDeclarativeFlickable::horizontalVelocity() const { @@ -584,8 +612,8 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea() \list \o AutoFlickDirection (default) - allows flicking vertically if the - \e viewportHeight is not equal to the \e height of the Flickable. - Allows flicking horizontally if the \e viewportWidth is not equal + \e contentHeight is not equal to the \e height of the Flickable. + Allows flicking horizontally if the \e contentWidth is not equal to the \e width of the Flickable. \o HorizontalFlick - allows flicking horizontally. \o VerticalFlick - allows flicking vertically. @@ -968,10 +996,10 @@ QDeclarativeListProperty<QDeclarativeItem> QDeclarativeFlickable::flickableChild /*! \qmlproperty bool Flickable::overShoot - This property holds the number of pixels the surface may overshoot the + This property holds whether the surface may overshoot the Flickable's boundaries when flicked. - If overShoot is non-zero the contents can be flicked beyond the boundary + If overShoot is true the contents can be flicked beyond the boundary of the Flickable before being moved back to the boundary. This provides the feeling that the edges of the view are soft, rather than a hard physical boundary. @@ -992,26 +1020,26 @@ void QDeclarativeFlickable::setOverShoot(bool o) } /*! - \qmlproperty int Flickable::viewportWidth - \qmlproperty int Flickable::viewportHeight + \qmlproperty int Flickable::contentWidth + \qmlproperty int Flickable::contentHeight - The dimensions of the viewport (the surface controlled by Flickable). Typically this + The dimensions of the content (the surface controlled by Flickable). Typically this should be set to the combined size of the items placed in the Flickable. \code Flickable { - width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height + width: 320; height: 480; contentWidth: image.width; contentHeight: image.height Image { id: image; source: "bigimage.png" } } \endcode */ -qreal QDeclarativeFlickable::viewportWidth() const +qreal QDeclarativeFlickable::contentWidth() const { Q_D(const QDeclarativeFlickable); return d->vWidth; } -void QDeclarativeFlickable::setViewportWidth(qreal w) +void QDeclarativeFlickable::setContentWidth(qreal w) { Q_D(QDeclarativeFlickable); if (d->vWidth == w) @@ -1024,7 +1052,7 @@ void QDeclarativeFlickable::setViewportWidth(qreal w) // Make sure that we're entirely in view. if (!d->pressed) d->fixupX(); - emit viewportWidthChanged(); + emit contentWidthChanged(); d->updateBeginningEnd(); } @@ -1033,7 +1061,7 @@ void QDeclarativeFlickable::widthChange() Q_D(QDeclarativeFlickable); if (d->vWidth < 0) { d->viewport->setWidth(width()); - emit viewportWidthChanged(); + emit contentWidthChanged(); } d->updateBeginningEnd(); } @@ -1043,18 +1071,18 @@ void QDeclarativeFlickable::heightChange() Q_D(QDeclarativeFlickable); if (d->vHeight < 0) { d->viewport->setHeight(height()); - emit viewportHeightChanged(); + emit contentHeightChanged(); } d->updateBeginningEnd(); } -qreal QDeclarativeFlickable::viewportHeight() const +qreal QDeclarativeFlickable::contentHeight() const { Q_D(const QDeclarativeFlickable); return d->vHeight; } -void QDeclarativeFlickable::setViewportHeight(qreal h) +void QDeclarativeFlickable::setContentHeight(qreal h) { Q_D(QDeclarativeFlickable); if (d->vHeight == h) @@ -1067,7 +1095,7 @@ void QDeclarativeFlickable::setViewportHeight(qreal h) // Make sure that we're entirely in view. if (!d->pressed) d->fixupY(); - emit viewportHeightChanged(); + emit contentHeightChanged(); d->updateBeginningEnd(); } @@ -1259,22 +1287,6 @@ void QDeclarativeFlickable::setPressDelay(int delay) emit pressDelayChanged(); } -qreal QDeclarativeFlickable::reportedVelocitySmoothing() const -{ - Q_D(const QDeclarativeFlickable); - return d->reportedVelocitySmoothing; -} - -void QDeclarativeFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySmoothing) -{ - Q_D(QDeclarativeFlickable); - Q_ASSERT(reportedVelocitySmoothing >= 0); - if (reportedVelocitySmoothing == d->reportedVelocitySmoothing) - return; - d->reportedVelocitySmoothing = reportedVelocitySmoothing; - emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing); -} - /*! \qmlproperty bool Flickable::moving diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 19fb2a9..4617688 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -56,14 +56,13 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem { Q_OBJECT - Q_PROPERTY(qreal viewportWidth READ viewportWidth WRITE setViewportWidth NOTIFY viewportWidthChanged) - Q_PROPERTY(qreal viewportHeight READ viewportHeight WRITE setViewportHeight NOTIFY viewportHeightChanged) - Q_PROPERTY(qreal viewportX READ viewportX WRITE setViewportX NOTIFY positionXChanged) - Q_PROPERTY(qreal viewportY READ viewportY WRITE setViewportY NOTIFY positionYChanged) + Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged) + Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged) + Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged) + Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged) Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged) Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged) - Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged) Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged) Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) @@ -98,17 +97,17 @@ public: bool overShoot() const; void setOverShoot(bool); - qreal viewportWidth() const; - void setViewportWidth(qreal); + qreal contentWidth() const; + void setContentWidth(qreal); - qreal viewportHeight() const; - void setViewportHeight(qreal); + qreal contentHeight() const; + void setContentHeight(qreal); - qreal viewportX() const; - void setViewportX(qreal pos); + qreal contentX() const; + void setContentX(qreal pos); - qreal viewportY() const; - void setViewportY(qreal pos); + qreal contentY() const; + void setContentY(qreal pos); bool isMoving() const; bool isFlicking() const; @@ -116,9 +115,6 @@ public: int pressDelay() const; void setPressDelay(int delay); - qreal reportedVelocitySmoothing() const; - void setReportedVelocitySmoothing(qreal); - qreal maximumFlickVelocity() const; void setMaximumFlickVelocity(qreal); @@ -143,17 +139,16 @@ public: void setFlickDirection(FlickDirection); Q_SIGNALS: - void viewportWidthChanged(); - void viewportHeightChanged(); - void positionXChanged(); - void positionYChanged(); + void contentWidthChanged(); + void contentHeightChanged(); + void contentXChanged(); + void contentYChanged(); void movingChanged(); void flickingChanged(); void movementStarted(); void movementEnded(); void flickStarted(); void flickEnded(); - void reportedVelocitySmoothingChanged(int); void horizontalVelocityChanged(); void verticalVelocityChanged(); void isAtBoundaryChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index dc3a8a2..1ff4f92 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -85,6 +85,8 @@ public: void setRoundedViewportX(qreal x); void setRoundedViewportY(qreal y); + qreal overShootDistance(qreal velocity, qreal size); + public: QDeclarativeItem *viewport; QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveX; diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index ab5022b..b43b30b 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -133,14 +133,14 @@ public: qreal position() const { Q_Q(const QDeclarativeGridView); - return flow == QDeclarativeGridView::LeftToRight ? q->viewportY() : q->viewportX(); + return flow == QDeclarativeGridView::LeftToRight ? q->contentY() : q->contentX(); } void setPosition(qreal pos) { Q_Q(QDeclarativeGridView); if (flow == QDeclarativeGridView::LeftToRight) - q->setViewportY(pos); + q->setContentY(pos); else - q->setViewportX(pos); + q->setContentX(pos); } int size() const { Q_Q(const QDeclarativeGridView); @@ -315,9 +315,9 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex) if (QDeclarativeItem *item = model->item(modelIndex, false)) { listItem = new FxGridItem(item, q); listItem->index = modelIndex; + listItem->item->setZValue(1); // complete model->completeItem(); - listItem->item->setZValue(1); listItem->item->setParent(q->viewport()); unrequestedItems.remove(listItem->item); } @@ -458,9 +458,9 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) } if (changed) { if (flow == QDeclarativeGridView::LeftToRight) - q->setViewportHeight(endPosition() - startPosition()); + q->setContentHeight(endPosition() - startPosition()); else - q->setViewportWidth(endPosition() - startPosition()); + q->setContentWidth(endPosition() - startPosition()); } else if (!doBuffer && buffer && bufferMode != NoBuffer) { refill(from, to, true); } @@ -473,9 +473,9 @@ void QDeclarativeGridViewPrivate::updateGrid() columns = (int)qMax((flow == QDeclarativeGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); if (isValid()) { if (flow == QDeclarativeGridView::LeftToRight) - q->setViewportHeight(endPosition() - startPosition()); + q->setContentHeight(endPosition() - startPosition()); else - q->setViewportWidth(endPosition() - startPosition()); + q->setContentWidth(endPosition() - startPosition()); } } @@ -516,10 +516,10 @@ void QDeclarativeGridViewPrivate::layout(bool removed) updateHighlight(); moveReason = Other; if (flow == QDeclarativeGridView::LeftToRight) { - q->setViewportHeight(endPosition() - startPosition()); + q->setContentHeight(endPosition() - startPosition()); fixupY(); } else { - q->setViewportWidth(endPosition() - startPosition()); + q->setContentWidth(endPosition() - startPosition()); fixupX(); } updateUnrequestedPositions(); @@ -675,6 +675,7 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) /*! \qmlclass GridView QDeclarativeGridView + \since 4.7 \inherits Flickable \brief The GridView item provides a grid view of items provided by a model. @@ -1028,10 +1029,10 @@ void QDeclarativeGridView::setFlow(Flow flow) if (d->flow != flow) { d->flow = flow; if (d->flow == LeftToRight) { - setViewportWidth(-1); + setContentWidth(-1); setFlickDirection(QDeclarativeFlickable::VerticalFlick); } else { - setViewportHeight(-1); + setContentHeight(-1); setFlickDirection(QDeclarativeFlickable::HorizontalFlick); } d->clear(); diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 338b086..99ab053 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) : QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent) { - connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry())); + connect(this, SIGNAL(pixmapChanged()), this, SLOT(updatePaintedGeometry())); } QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent) @@ -139,12 +139,6 @@ QDeclarativeImage::~QDeclarativeImage() { } -void QDeclarativeImage::setSource(const QUrl &url) -{ - QDeclarativeImageBase::setSource(url); - updatePaintedGeometry(); -} - /*! \qmlproperty QPixmap Image::pixmap @@ -268,10 +262,10 @@ void QDeclarativeImage::updatePaintedGeometry() Q_D(QDeclarativeImage); if (d->fillMode == PreserveAspectFit) { - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); if (!d->pix.width() || !d->pix.height()) return; + qreal widthScale = width() / qreal(d->pix.width()); + qreal heightScale = height() / qreal(d->pix.height()); if (widthScale <= heightScale) { d->paintedWidth = width(); d->paintedHeight = widthScale * qreal(d->pix.height()); diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h index 5b365e7..fb77ac9 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h @@ -76,7 +76,6 @@ public: qreal paintedWidth() const; qreal paintedHeight() const; - void setSource(const QUrl &url); void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); Q_SIGNALS: diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 81c5688..4b4917e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -60,8 +60,8 @@ #include "qdeclarativeitemchangelistener_p.h" #include <private/qpodvector_p.h> -#include "../util/qdeclarativestate_p.h" -#include "../util/qdeclarativenullablevalue_p_p.h" +#include <private/qdeclarativestate_p.h> +#include <private/qdeclarativenullablevalue_p_p.h> #include <qdeclarative.h> #include <qdeclarativecontext.h> diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index e6b6f2a..03303a0 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -203,14 +203,14 @@ public: qreal position() const { Q_Q(const QDeclarativeListView); - return orient == QDeclarativeListView::Vertical ? q->viewportY() : q->viewportX(); + return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX(); } void setPosition(qreal pos) { Q_Q(QDeclarativeListView); if (orient == QDeclarativeListView::Vertical) - q->setViewportY(pos); + q->setContentY(pos); else - q->setViewportX(pos); + q->setContentX(pos); } qreal size() const { Q_Q(const QDeclarativeListView); @@ -382,9 +382,9 @@ public: void updateViewport() { Q_Q(QDeclarativeListView); if (orient == QDeclarativeListView::Vertical) { - q->setViewportHeight(endPosition() - startPosition() + 1); + q->setContentHeight(endPosition() - startPosition() + 1); } else { - q->setViewportWidth(endPosition() - startPosition() + 1); + q->setContentWidth(endPosition() - startPosition() + 1); } } @@ -530,9 +530,9 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) listItem->attached->m_prevSection = sectionAt(modelIndex-1); } } + listItem->item->setZValue(1); // complete model->completeItem(); - listItem->item->setZValue(1); listItem->item->setParent(q->viewport()); QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); @@ -1073,7 +1073,7 @@ void QDeclarativeListViewPrivate::fixupY() qreal pos = currentItem->position() - highlightRangeStart; timeline.reset(_moveY); if (fixupDuration) - timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); else _moveY.setValue(-pos); vTime = timeline.time(); @@ -1085,7 +1085,7 @@ void QDeclarativeListViewPrivate::fixupY() if (dist > 0) { timeline.reset(_moveY); if (fixupDuration) - timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); else _moveY.setValue(-pos); vTime = timeline.time(); @@ -1155,7 +1155,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity) if (FxListItem *item = firstVisibleItem()) maxDistance = qAbs(item->position() + _moveX.value()); } else if (_moveX.value() < minX) { - maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0)); + maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity, q->width()):0)); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) flickTargetX = minX; @@ -1164,7 +1164,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity) if (FxListItem *item = nextVisibleItem()) maxDistance = qAbs(item->position() + _moveX.value()); } else if (_moveX.value() > maxX) { - maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0); + maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity, q->width()):0); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) flickTargetX = maxX; @@ -1196,7 +1196,7 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity) overshootDist = 0.0; } else { flickTargetX = velocity > 0 ? minX : maxX; - overshootDist = overShoot ? 30 : 0; + overshootDist = overShoot ? overShootDistance(v, q->width()) : 0; } timeline.reset(_moveX); timeline.accel(_moveX, v, accel, maxDistance + overshootDist); @@ -1253,7 +1253,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity) if (FxListItem *item = firstVisibleItem()) maxDistance = qAbs(item->position() + _moveY.value()); } else if (_moveY.value() < minY) { - maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0)); + maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity, q->height()):0)); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) flickTargetY = minY; @@ -1262,7 +1262,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity) if (FxListItem *item = nextVisibleItem()) maxDistance = qAbs(item->position() + _moveY.value()); } else if (_moveY.value() > maxY) { - maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0); + maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity, q->height()):0); } if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange) flickTargetY = maxY; @@ -1294,7 +1294,7 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity) overshootDist = 0.0; } else { flickTargetY = velocity > 0 ? minY : maxY; - overshootDist = overShoot ? 30 : 0; + overshootDist = overShoot ? overShootDistance(v, q->height()) : 0; } timeline.reset(_moveY); timeline.accel(_moveY, v, accel, maxDistance + overshootDist); @@ -1819,10 +1819,10 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie if (d->orient != orientation) { d->orient = orientation; if (d->orient == QDeclarativeListView::Vertical) { - setViewportWidth(-1); + setContentWidth(-1); setFlickDirection(VerticalFlick); } else { - setViewportHeight(-1); + setContentHeight(-1); setFlickDirection(HorizontalFlick); } d->clear(); @@ -1980,6 +1980,12 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed) visible item at the time the mouse button is released. This mode is particularly useful for moving one page at a time. \endlist + + snapMode does not affect the currentIndex. To update the + currentIndex as the list is moved set \e highlightRangeMode + to \e StrictlyEnforceRange. + + \sa highlightRangeMode */ QDeclarativeListView::SnapMode QDeclarativeListView::snapMode() const { diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index c131f4c..f1b0213 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -111,7 +111,7 @@ QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex) { Q_Q(QDeclarativePathView); requestedIndex = modelIndex; - QDeclarativeItem *item = model->item(modelIndex); + QDeclarativeItem *item = model->item(modelIndex, false); if (item) { if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item)) static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(true); @@ -655,6 +655,7 @@ void QDeclarativePathViewPrivate::regenerate() } items.append(item); item->setZValue(i); + model->completeItem(); if (currentIndex == index) item->setFocus(true); } @@ -715,6 +716,7 @@ void QDeclarativePathView::refill() int index = (d->firstIndex + d->items.count())%d->model->count(); QDeclarativeItem *item = d->getItem(index); item->setZValue(wrapIndex); + d->model->completeItem(); if (d->currentIndex == index) item->setFocus(true); d->items << item; @@ -731,6 +733,7 @@ void QDeclarativePathView::refill() d->firstIndex = d->model->count() - 1; QDeclarativeItem *item = d->getItem(d->firstIndex); item->setZValue(d->firstIndex); + d->model->completeItem(); if (d->currentIndex == d->firstIndex) item->setFocus(true); d->items.prepend(item); @@ -757,6 +760,7 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count) for (int i = 0; i < count; ++i) { QDeclarativeItem *item = d->getItem(modelIndex + i); item->setZValue(modelIndex + i); + d->model->completeItem(); d->items.insert(modelIndex + i, item); } refill(); diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index ff6fc4b..f38847c 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -44,7 +44,7 @@ #include "qdeclarativeitem.h" -#include "../util/qdeclarativestate_p.h" +#include <private/qdeclarativestate_p.h> #include <private/qpodvector_p.h> #include <QtCore/QObject> diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h index 92b3f91..fbf9040 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h @@ -44,7 +44,7 @@ #include "qdeclarativeborderimage_p.h" -#include "../util/qdeclarativepixmapcache_p.h" +#include <private/qdeclarativepixmapcache_p.h> #include <qdeclarative.h> #include <QtCore/QString> diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 9919904..3382628 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -704,6 +704,8 @@ bool QDeclarativeTextInput::event(QEvent* ev) break; default: handled = d->control->processEvent(ev); + if (ev->type() == QEvent::InputMethod) + updateSize(); } if(!handled) return QDeclarativePaintedItem::event(ev); diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/declarative/graphicsitems/qdeclarativewebview.cpp index 61b5b56..a2b16ba 100644 --- a/src/declarative/graphicsitems/qdeclarativewebview.cpp +++ b/src/declarative/graphicsitems/qdeclarativewebview.cpp @@ -177,6 +177,8 @@ void QDeclarativeWebView::init() { Q_D(QDeclarativeWebView); + QWebSettings::enablePersistentStorage(); + setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, false); @@ -955,6 +957,7 @@ void QDeclarativeWebView::setPage(QWebPage *page) connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect))); connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged())); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); + connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize))); connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); |