diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-28 05:22:35 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-28 05:22:35 (GMT) |
commit | 5c44fa2e28c4da946b59841ec2480c5d38969784 (patch) | |
tree | 73fa88fc5dd096346315ccd87115849923ab3d76 /src/declarative | |
parent | 57d2291b2e0533d23bd52e9814faf6a5727a4e96 (diff) | |
parent | 1545a7f0e67cc125a116f0d72b81cb325a675381 (diff) | |
download | Qt-5c44fa2e28c4da946b59841ec2480c5d38969784.zip Qt-5c44fa2e28c4da946b59841ec2480c5d38969784.tar.gz Qt-5c44fa2e28c4da946b59841ec2480c5d38969784.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfxflickable.cpp | 26 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 152 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.h | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxpositioners.cpp | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.cpp | 22 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext.h | 15 | ||||
-rw-r--r-- | src/declarative/fx/qfxtext_p.h | 4 | ||||
-rw-r--r-- | src/declarative/util/qmleasefollow.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qmlspringfollow.cpp | 9 |
10 files changed, 164 insertions, 83 deletions
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 92e79dd..659193d 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE static const int DragThreshold = 8; static const int FlickThreshold = 20; +// Really slow flicks can be annoying. +static const int minimumFlickVelocity = 200; class QFxFlickableVisibleArea : public QObject { @@ -183,6 +185,8 @@ void QFxFlickablePrivate::flickX(qreal velocity) { Q_Q(QFxFlickable); qreal maxDistance = -1; + if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks. + velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity; // -ve velocity means list is moving up if (velocity > 0) { if (_moveX.value() < q->minXExtent()) @@ -686,8 +690,8 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) if (rejectX) velocityX = 0; if (moved) { - q->viewportMoved(); q->movementStarting(); + q->viewportMoved(); } lastPos = event->pos(); @@ -707,15 +711,23 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *even } vTime = timeline.time(); - if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) - flickY(velocityY); - else + if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) { + qreal velocity = velocityY; + if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks. + velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity; + flickY(velocity); + } else { fixupY(); + } - if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) - flickX(velocityX); - else + if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) { + qreal velocity = velocityX; + if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks. + velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity; + flickX(velocity); + } else { fixupX(); + } stealMouse = false; lastPosTime = QTime(); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index e714494..7d60336 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1199,7 +1199,7 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj) /*! \class QFxItem - \brief QFxItem is the most basic of all visual items in QML. + \brief The QFxItem class provides the most basic of all visual items in QML. All visual items in Qt Declarative inherit from QFxItem. Although QFxItem has no visual appearance, it defines all the properties that are diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index fbb91b1..1f1b97b 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -141,15 +141,15 @@ public: } ~FxListItem() {} - qreal position() const { return (view->orientation() == Qt::Vertical ? item->y() : item->x()); } - int size() const { return (view->orientation() == Qt::Vertical ? item->height() : item->width()); } + qreal position() const { return (view->orientation() == QFxListView::Vertical ? item->y() : item->x()); } + int size() const { return (view->orientation() == QFxListView::Vertical ? item->height() : item->width()); } qreal endPosition() const { - return (view->orientation() == Qt::Vertical + return (view->orientation() == QFxListView::Vertical ? item->y() + (item->height() > 0 ? item->height() : 1) : item->x() + (item->width() > 0 ? item->width() : 1)) - 1; } void setPosition(qreal pos) { - if (view->orientation() == Qt::Vertical) { + if (view->orientation() == QFxListView::Vertical) { item->setY(pos); } else { item->setX(pos); @@ -170,7 +170,7 @@ class QFxListViewPrivate : public QFxFlickablePrivate public: QFxListViewPrivate() - : model(0), currentItem(0), orient(Qt::Vertical) + : model(0), currentItem(0), orient(QFxListView::Vertical) , visiblePos(0), visibleIndex(0) , averageSize(100.0), currentIndex(-1), requestedIndex(-1) , highlightRangeStart(0), highlightRangeEnd(0) @@ -199,18 +199,18 @@ public: qreal position() const { Q_Q(const QFxListView); - return orient == Qt::Vertical ? q->viewportY() : q->viewportX(); + return orient == QFxListView::Vertical ? q->viewportY() : q->viewportX(); } void setPosition(qreal pos) { Q_Q(QFxListView); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) q->setViewportY(pos); else q->setViewportX(pos); } qreal size() const { Q_Q(const QFxListView); - return orient == Qt::Vertical ? q->height() : q->width(); + return orient == QFxListView::Vertical ? q->height() : q->width(); } qreal startPosition() const { @@ -378,7 +378,7 @@ public: QList<FxListItem*> visibleItems; QHash<QFxItem*,int> unrequestedItems; FxListItem *currentItem; - Qt::Orientation orient; + QFxListView::Orientation orient; int visiblePos; int visibleIndex; qreal averageSize; @@ -454,7 +454,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex) model->completeItem(); listItem->item->setZValue(1); listItem->item->setParent(q->viewport()); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized())); else QObject::connect(listItem->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); @@ -470,8 +470,8 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) if (!item) return; if (trackedItem == item) { - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); + const char *notifier1 = orient == QFxListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); + const char *notifier2 = orient == QFxListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); trackedItem = 0; @@ -479,7 +479,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) if (model->release(item->item) == 0) { // item was not destroyed, and we no longer reference it. unrequestedItems.insert(item->item, model->indexOf(item->item, q)); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) QObject::disconnect(item->item, SIGNAL(heightChanged()), q, SLOT(itemResized())); else QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); @@ -553,7 +553,7 @@ void QFxListViewPrivate::refill(qreal from, qreal to) updateAverage(); if (!sectionExpression.isEmpty()) updateCurrentSection(); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) q->setViewportHeight(endPosition() - startPosition()); else q->setViewportWidth(endPosition() - startPosition()); @@ -597,7 +597,7 @@ void QFxListViewPrivate::updateUnrequestedPositions() for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { if (visibleItem(*it)) continue; - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) it.key()->setY(positionAt(*it)); else it.key()->setX(positionAt(*it)); @@ -613,8 +613,8 @@ void QFxListViewPrivate::updateTrackedItem() FxListItem *oldTracked = trackedItem; - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); + const char *notifier1 = orient == QFxListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); + const char *notifier2 = orient == QFxListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); if (trackedItem && item != trackedItem) { QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); @@ -669,16 +669,16 @@ void QFxListViewPrivate::createHighlight() if (item) { item->setZValue(0); highlight = new FxListItem(item, q); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) highlight->item->setHeight(currentItem->item->height()); else highlight->item->setWidth(currentItem->item->width()); - const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); + const QLatin1String posProp(orient == QFxListView::Vertical ? "y" : "x"); highlightPosAnimator = new QmlEaseFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); highlightPosAnimator->setVelocity(highlightMoveSpeed); highlightPosAnimator->setEnabled(autoHighlight); - const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); + const QLatin1String sizeProp(orient == QFxListView::Vertical ? "height" : "width"); highlightSizeAnimator = new QmlEaseFollow(q); highlightSizeAnimator->setVelocity(highlightResizeSpeed); highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp)); @@ -691,12 +691,11 @@ void QFxListViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - updateTrackedItem(); - if (currentItem && autoHighlight && highlight && !pressed && moveReason != QFxListViewPrivate::Mouse) { + if (currentItem && autoHighlight && highlight && !moving) { // auto-update highlight highlightPosAnimator->setSourceValue(currentItem->position()); highlightSizeAnimator->setSourceValue(currentItem->size()); - if (orient == Qt::Vertical) { + if (orient == QFxListView::Vertical) { if (highlight->item->width() == 0) highlight->item->setWidth(currentItem->item->width()); } else { @@ -704,6 +703,7 @@ void QFxListViewPrivate::updateHighlight() highlight->item->setHeight(currentItem->item->height()); } } + updateTrackedItem(); } void QFxListViewPrivate::updateSections() @@ -792,7 +792,7 @@ void QFxListViewPrivate::updateAverage() void QFxListViewPrivate::fixupPosition() { - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) fixupY(); else fixupX(); @@ -801,7 +801,7 @@ void QFxListViewPrivate::fixupPosition() void QFxListViewPrivate::fixupY() { QFxFlickablePrivate::fixupY(); - if (orient == Qt::Horizontal) + if (orient == QFxListView::Horizontal) return; if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) { @@ -816,7 +816,7 @@ void QFxListViewPrivate::fixupY() void QFxListViewPrivate::fixupX() { QFxFlickablePrivate::fixupX(); - if (orient == Qt::Vertical) + if (orient == QFxListView::Vertical) return; if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) { @@ -832,8 +832,10 @@ void QFxListViewPrivate::flickX(qreal velocity) { Q_Q(QFxListView); - if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange) + if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange) { QFxFlickablePrivate::flickX(velocity); + return; + } qreal maxDistance = -1; // -ve velocity means list is moving up @@ -855,19 +857,20 @@ void QFxListViewPrivate::flickX(qreal velocity) v = maxVelocity; } qreal accel = deceleration; - qreal maxAccel = (v * v) / (2.0f * maxDistance); + qreal v2 = v * v; + qreal maxAccel = v2 / (2.0f * maxDistance); if (maxAccel < accel) { // If we are not flicking to the end then attempt to stop exactly on an item boundary - qreal dist = (v * v) / accel / 2.0; + qreal dist = v2 / accel / 2.0; if (v > 0) dist = -dist; - dist = -_moveX.value() - snapPosAt(-_moveX.value() + dist + highlightRangeStart); + dist = -_moveX.value() - snapPosAt(-(_moveX.value() - highlightRangeStart) + dist) + highlightRangeStart; if (v < 0 && dist >= 0 || v > 0 && dist <= 0) { timeline.reset(_moveX); fixupX(); return; } - accel = (v * v) / (2.0f * qAbs(dist)); + accel = v2 / (2.0f * qAbs(dist)); } timeline.reset(_moveX); timeline.accel(_moveX, v, accel, maxDistance); @@ -885,7 +888,60 @@ void QFxListViewPrivate::flickX(qreal velocity) void QFxListViewPrivate::flickY(qreal velocity) { - QFxFlickablePrivate::flickY(velocity); + Q_Q(QFxListView); + + if (!haveHighlightRange || highlightRange != QFxListView::StrictlyEnforceRange) { + QFxFlickablePrivate::flickY(velocity); + return; + } + + qreal maxDistance = -1; + // -ve velocity means list is moving up + if (velocity > 0) { + if (_moveY.value() < q->minYExtent()) + maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0)); + flickTargetY = q->minYExtent(); + } else { + if (_moveY.value() > q->maxYExtent()) + maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0); + flickTargetY = q->maxYExtent(); + } + if (maxDistance > 0) { + qreal v = velocity; + if (maxVelocity != -1 && maxVelocity < qAbs(v)) { + if (v < 0) + v = -maxVelocity; + else + v = maxVelocity; + } + qreal accel = deceleration; + qreal v2 = v * v; + qreal maxAccel = v2 / (2.0f * maxDistance); + if (maxAccel < accel) { + // If we are not flicking to the end then attempt to stop exactly on an item boundary + qreal dist = v2 / accel / 2.0; + if (v > 0) + dist = -dist; + dist = -_moveY.value() - snapPosAt(-(_moveY.value() - highlightRangeStart) + dist) + highlightRangeStart; + if (v < 0 && dist >= 0 || v > 0 && dist <= 0) { + timeline.reset(_moveY); + fixupY(); + return; + } + accel = v2 / (2.0f * qAbs(dist)); + } + timeline.reset(_moveY); + timeline.accel(_moveY, v, accel, maxDistance); + timeline.execute(fixupYEvent); + if (!flicked) { + flicked = true; + emit q->flickingChanged(); + emit q->flickStarted(); + } + } else { + timeline.reset(_moveY); + fixupY(); + } } //---------------------------------------------------------------------------- @@ -1185,6 +1241,10 @@ void QFxListView::setHighlight(QmlComponent *highlight) \snippet doc/src/snippets/declarative/listview/highlight.qml 1 + Note that the highlight animation also affects the way that the view + is scrolled. This is because the view moves to maintain the + highlight within the preferred highlight range (or visible viewport). + \sa highlight */ bool QFxListView::highlightFollowsCurrentItem() const @@ -1298,18 +1358,18 @@ void QFxListView::setSpacing(qreal spacing) Horizontal Example: \image ListViewHorizontal.png */ -Qt::Orientation QFxListView::orientation() const +QFxListView::Orientation QFxListView::orientation() const { Q_D(const QFxListView); return d->orient; } -void QFxListView::setOrientation(Qt::Orientation orientation) +void QFxListView::setOrientation(QFxListView::Orientation orientation) { Q_D(QFxListView); if (d->orient != orientation) { d->orient = orientation; - if (d->orient == Qt::Vertical) + if (d->orient == QFxListView::Vertical) setViewportWidth(-1); else setViewportHeight(-1); @@ -1445,7 +1505,7 @@ void QFxListView::viewportMoved() Q_D(QFxListView); QFxFlickable::viewportMoved(); refill(); - if (isFlicking() || d->pressed) + if (isFlicking() || d->moving) d->moveReason = QFxListViewPrivate::Mouse; if (d->moveReason == QFxListViewPrivate::Mouse) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { @@ -1466,7 +1526,7 @@ void QFxListView::viewportMoved() qreal QFxListView::minYExtent() const { Q_D(const QFxListView); - if (d->orient == Qt::Horizontal) + if (d->orient == QFxListView::Horizontal) return QFxFlickable::minYExtent(); qreal extent = -d->startPosition(); if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) @@ -1478,7 +1538,7 @@ qreal QFxListView::minYExtent() const qreal QFxListView::maxYExtent() const { Q_D(const QFxListView); - if (d->orient == Qt::Horizontal) + if (d->orient == QFxListView::Horizontal) return QFxFlickable::maxYExtent(); qreal extent; if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) @@ -1494,7 +1554,7 @@ qreal QFxListView::maxYExtent() const qreal QFxListView::minXExtent() const { Q_D(const QFxListView); - if (d->orient == Qt::Vertical) + if (d->orient == QFxListView::Vertical) return QFxFlickable::minXExtent(); qreal extent = -d->startPosition(); if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) @@ -1506,7 +1566,7 @@ qreal QFxListView::minXExtent() const qreal QFxListView::maxXExtent() const { Q_D(const QFxListView); - if (d->orient == Qt::Vertical) + if (d->orient == QFxListView::Vertical) return QFxFlickable::maxXExtent(); qreal extent; if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) @@ -1527,8 +1587,8 @@ void QFxListView::keyPressEvent(QKeyEvent *event) return; if (d->model && d->model->count() && d->interactive) { - if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Left) - || (d->orient == Qt::Vertical && event->key() == Qt::Key_Up)) { + if ((d->orient == QFxListView::Horizontal && event->key() == Qt::Key_Left) + || (d->orient == QFxListView::Vertical && event->key() == Qt::Key_Up)) { if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) { d->moveReason = QFxListViewPrivate::Key; decrementCurrentIndex(); @@ -1538,8 +1598,8 @@ void QFxListView::keyPressEvent(QKeyEvent *event) event->accept(); return; } - } else if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Right) - || (d->orient == Qt::Vertical && event->key() == Qt::Key_Down)) { + } else if ((d->orient == QFxListView::Horizontal && event->key() == Qt::Key_Right) + || (d->orient == QFxListView::Vertical && event->key() == Qt::Key_Down)) { if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) { d->moveReason = QFxListViewPrivate::Key; incrementCurrentIndex(); @@ -1606,7 +1666,7 @@ void QFxListView::trackedPositionChanged() Q_D(QFxListView); if (!d->trackedItem) return; - if (!isFlicking() && !d->pressed && d->moveReason != QFxListViewPrivate::Mouse) { + if (!isFlicking() && !d->moving && d->moveReason != QFxListViewPrivate::Mouse) { const qreal trackedPos = d->trackedItem->position(); if (d->haveHighlightRange) { if (d->highlightRange == StrictlyEnforceRange) { @@ -1930,7 +1990,7 @@ void QFxListView::createdItem(int index, QFxItem *item) if (d->requestedIndex != index) { item->setParentItem(viewport()); d->unrequestedItems.insert(item, index); - if (d->orient == Qt::Vertical) + if (d->orient == QFxListView::Vertical) item->setY(d->positionAt(index)); else item->setX(d->positionAt(index)); diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 0fa0fa0..b31b951 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode) Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) + Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled) Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged) @@ -81,6 +81,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) Q_ENUMS(HighlightRangeMode) + Q_ENUMS(Orientation) Q_CLASSINFO("DefaultProperty", "data") public: @@ -118,8 +119,9 @@ public: qreal spacing() const; void setSpacing(qreal spacing); - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation); + enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical }; + Orientation orientation() const; + void setOrientation(Orientation); bool isWrapEnabled() const; void setWrapEnabled(bool); diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp index f8e7213..cc385e0 100644 --- a/src/declarative/fx/qfxpositioners.cpp +++ b/src/declarative/fx/qfxpositioners.cpp @@ -659,8 +659,10 @@ void QFxRow::doPositioning() child->setX(hoffset); setMovingItem(0); } - hoffset += child->width(); - hoffset += spacing(); + if(!child->width() || !child->height()){//don't advance for invisible children + hoffset += child->width(); + hoffset += spacing(); + } } } diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 4d02f0d..763256b 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -420,28 +420,28 @@ void QFxText::setTextFormat(TextFormat format) } /*! - \qmlproperty Qt::TextElideMode Text::elide + \qmlproperty enumeration Text::elide Set this property to elide parts of the text fit to the Text item's width. The text will only elide if an explicit width has been set. This property cannot be used with wrap enabled or with rich text. - Eliding can be ElideNone (the default), ElideLeft, ElideMiddle, or ElideRight. + Eliding can be \c ElideNone (the default), \c ElideLeft, \c ElideMiddle, or \c ElideRight. - If the text is a multi-length string, and the mode is not ElideNone, + If the text is a multi-length string, and the mode is not \c ElideNone, the first string that fits will be used, otherwise the last will be elided. Multi-length strings are ordered from longest to shortest, separated by the - Unicode "String Terminator" character U009C (write this in QML with "\\x9C"). + Unicode "String Terminator" character \c U009C (write this in QML with \c{"\\x9C"}). */ -Qt::TextElideMode QFxText::elideMode() const +QFxText::TextElideMode QFxText::elideMode() const { Q_D(const QFxText); return d->elideMode; } -void QFxText::setElideMode(Qt::TextElideMode mode) +void QFxText::setElideMode(QFxText::TextElideMode mode) { Q_D(QFxText); if (mode == d->elideMode) @@ -458,7 +458,7 @@ void QFxText::geometryChanged(const QRectF &newGeometry, { Q_D(QFxText); if (newGeometry.width() != oldGeometry.width()) { - if (d->wrap || d->elideMode != Qt::ElideNone) { + if (d->wrap || d->elideMode != QFxText::ElideNone) { d->imgDirty = true; d->updateSize(); } @@ -486,8 +486,8 @@ void QFxTextPrivate::updateSize() tmp = text; tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); singleline = !tmp.contains(QChar::LineSeparator); - if (singleline && elideMode != Qt::ElideNone && q->widthValid()) - tmp = fm.elidedText(tmp,elideMode,q->width()); // XXX still worth layout...? + if (singleline && elideMode != QFxText::ElideNone && q->widthValid()) + tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...? layout.clearLayout(); layout.setFont(font); layout.setText(tmp); @@ -586,7 +586,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) qreal lineWidth = 0; //set manual width - if ((wrap || elideMode != Qt::ElideNone) && q->widthValid()) + if ((wrap || elideMode != QFxText::ElideNone) && q->widthValid()) lineWidth = q->width(); layout->beginLayout(); @@ -596,7 +596,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) if (!line.isValid()) break; - if ((wrap || elideMode != Qt::ElideNone) && q->widthValid()) + if ((wrap || elideMode != QFxText::ElideNone) && q->widthValid()) line.setLineWidth(lineWidth); } layout->endLayout(); diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 763e2aa..cdb8025 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -57,6 +57,7 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_ENUMS(VAlignment) Q_ENUMS(TextStyle) Q_ENUMS(TextFormat) + Q_ENUMS(TextElideMode) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QFont font READ font WRITE setFont) @@ -67,7 +68,7 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign) Q_PROPERTY(bool wrap READ wrap WRITE setWrap) //### there are several wrap modes in Qt Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) - Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) //### elideMode? + Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode) //### elideMode? public: QFxText(QFxItem *parent=0); @@ -84,8 +85,12 @@ public: Raised, Sunken }; enum TextFormat { PlainText = Qt::PlainText, - RichText = Qt::RichText, - AutoText = Qt::AutoText }; + RichText = Qt::RichText, + AutoText = Qt::AutoText }; + enum TextElideMode { ElideLeft = Qt::ElideLeft, + ElideRight = Qt::ElideRight, + ElideMiddle = Qt::ElideMiddle, + ElideNone = Qt::ElideNone }; QString text() const; void setText(const QString &); @@ -114,8 +119,8 @@ public: TextFormat textFormat() const; void setTextFormat(TextFormat format); - Qt::TextElideMode elideMode() const; - void setElideMode(Qt::TextElideMode); + TextElideMode elideMode() const; + void setElideMode(TextElideMode); void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h index 8b24c66..a10cdfa 100644 --- a/src/declarative/fx/qfxtext_p.h +++ b/src/declarative/fx/qfxtext_p.h @@ -70,7 +70,7 @@ class QFxTextPrivate : public QFxItemPrivate public: QFxTextPrivate() : color((QRgb)0), style(QFxText::Normal), imgDirty(true), - hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone), + hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(QFxText::ElideNone), dirty(true), wrap(false), richText(false), singleline(false), control(0), doc(0), format(QFxText::AutoText) { @@ -97,7 +97,7 @@ public: QPixmap imgStyleCache; QFxText::HAlignment hAlign; QFxText::VAlignment vAlign; - Qt::TextElideMode elideMode; + QFxText::TextElideMode elideMode; bool dirty; bool wrap; bool richText; diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp index 99720f8..9d17d25 100644 --- a/src/declarative/util/qmleasefollow.cpp +++ b/src/declarative/util/qmleasefollow.cpp @@ -210,7 +210,6 @@ void QmlEaseFollowPrivate::tick(int t) qreal value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds; value = (invert?-1.0:1.0) * value; target.write(initialValue + value); - out = initialValue + value; } else if (time_seconds < td) { @@ -397,7 +396,7 @@ void QmlEaseFollow::setSourceValue(qreal s) { Q_D(QmlEaseFollow); - if (d->source == s) + if (d->clock.state() == QAbstractAnimation::Running && d->source == s) return; d->source = s; diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp index 34ec976..569cc48 100644 --- a/src/declarative/util/qmlspringfollow.cpp +++ b/src/declarative/util/qmlspringfollow.cpp @@ -272,10 +272,11 @@ qreal QmlSpringFollow::sourceValue() const void QmlSpringFollow::setSourceValue(qreal value) { Q_D(QmlSpringFollow); - if (d->sourceValue != value) { - d->sourceValue = value; - d->start(); - } + if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value) + return; + + d->sourceValue = value; + d->start(); } /*! |