diff options
Diffstat (limited to 'src/declarative')
5 files changed, 46 insertions, 10 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index 9e48bf2..7719469 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -98,7 +98,7 @@ public: MouseRegion { anchors.fill: parent - onClicked: flipable.state = (flipable.state == 'back' ? 'front' : 'back') + onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back') } } \endqml diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 5b4f1f1..db59cf2 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -1307,20 +1307,20 @@ QmlGraphicsKeysAttached *QmlGraphicsKeysAttached::qmlAttachedProperties(QObject \qml Item { Image { - file: "tile.png" + source: "tile.png" } Image { x: 80 width: 100 height: 100 - file: "tile.png" + source: "tile.png" } Image { x: 190 width: 100 height: 100 - tile: true - file: "tile.png" + fillMode: Image.Tile + source: "tile.png" } } \endqml diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index e05ae66..0224465 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1603,7 +1603,7 @@ qreal QmlGraphicsListView::maxYExtent() const if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) extent = -(d->positionAt(count()-1) - d->highlightRangeEnd); else - extent = -(d->endPosition() - height()); + extent = -(d->endPosition() - height() + 1); qreal minY = minYExtent(); if (extent > minY) extent = minY; @@ -1631,7 +1631,7 @@ qreal QmlGraphicsListView::maxXExtent() const if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) extent = -(d->positionAt(count()-1) - d->highlightRangeEnd); else - extent = -(d->endPosition() - width()); + extent = -(d->endPosition() - width() + 1); qreal minX = minXExtent(); if (extent > minX) extent = minX; @@ -1706,6 +1706,43 @@ void QmlGraphicsListView::decrementCurrentIndex() } } +/*! + \qmlmethod ListView::positionViewAtIndex(int index) + + Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view. + If positioning the view at the index would cause empty space to be displayed at + the end of the view, the view will be positioned at the end. +*/ +void QmlGraphicsListView::positionViewAtIndex(int index) +{ + Q_D(QmlGraphicsListView); + if (index < 0 || index >= d->model->count()) + return; + + FxListItem *item = d->visibleItem(index); + if (item) { + // Already created - just move to top of view + int pos = item->position(); + if (item->position() > -maxYExtent()) + pos = -maxYExtent(); + d->setPosition(pos); + } else { + int pos = d->positionAt(index); + // save the currently visible items in case any of them end up visible again + QList<FxListItem*> oldVisible = d->visibleItems; + d->visibleItems.clear(); + d->visiblePos = pos; + d->visibleIndex = index; + d->setPosition(pos); + if (d->position() > -maxYExtent()) + d->setPosition(-maxYExtent()); + // now release the reference to all the old visible items. + for (int i = 0; i < oldVisible.count(); ++i) + d->releaseItem(oldVisible.at(i)); + } +} + + void QmlGraphicsListView::componentComplete() { Q_D(QmlGraphicsListView); diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index b8a6e1f..795c766 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -147,6 +147,7 @@ public: public Q_SLOTS: void incrementCurrentIndex(); void decrementCurrentIndex(); + void positionViewAtIndex(int index); Q_SIGNALS: void countChanged(); diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index bec2ff8..5f5269f 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -144,7 +144,6 @@ void QmlGraphicsTextEdit::setText(const QString &text) d->control->setPlainText(text); } q_textChanged(); - updateSize(); } /*! @@ -889,8 +888,7 @@ void QmlGraphicsTextEditPrivate::init() void QmlGraphicsTextEdit::q_textChanged() { - if (!widthValid()) - updateSize(); //### optimize: we get 3 calls to updateSize every time a letter is typed + updateSize(); emit textChanged(text()); } |