diff options
Diffstat (limited to 'src/declarative/graphicsitems')
23 files changed, 242 insertions, 185 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp index 26fb97f..c96ca0e 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp @@ -272,7 +272,7 @@ void QDeclarativeAnchorsPrivate::addDepend(QGraphicsObject *item) } else if(itemPrivate->isWidget) { Q_Q(QDeclarativeAnchors); QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); - QObject::connect(widget, SIGNAL(destroyed(QObject *)), q, SLOT(_q_widgetDestroyed(QObject *))); + QObject::connect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); } } @@ -289,7 +289,7 @@ void QDeclarativeAnchorsPrivate::remDepend(QGraphicsObject *item) } else if(itemPrivate->isWidget) { Q_Q(QDeclarativeAnchors); QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); - QObject::disconnect(widget, SIGNAL(destroyed(QObject *)), q, SLOT(_q_widgetDestroyed(QObject *))); + QObject::disconnect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); } } diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h index c929797..8223b17 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h +++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h @@ -48,6 +48,8 @@ #include <QtCore/QObject> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -56,7 +58,7 @@ QT_MODULE(Declarative) class QDeclarativeAnchorsPrivate; class QDeclarativeAnchorLine; -class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp index dbfb3fb..61fd562 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents.cpp +++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp @@ -113,11 +113,13 @@ Item { \qmlclass MouseEvent QDeclarativeMouseEvent \since 4.7 \ingroup qml-event-elements - + \brief The MouseEvent object provides information about a mouse event. - The position of the mouse can be found via the x and y properties. - The button that caused the event is available via the button property. + The position of the mouse can be found via the \l x and \l y properties. + The button that caused the event is available via the \l button property. + + \sa MouseArea */ /*! @@ -129,7 +131,7 @@ Item { \qmlproperty int MouseEvent::x \qmlproperty int MouseEvent::y - These properties hold the position of the mouse event. + These properties hold the coordinates of the position supplied by the mouse event. */ @@ -186,7 +188,7 @@ Item { It contains a bitwise combination of: \list \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. + \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. \o Qt.AltModifier - An Alt key on the keyboard is pressed. \o Qt.MetaModifier - A Meta key on the keyboard is pressed. @@ -195,9 +197,12 @@ Item { For example, to react to a Shift key + Left mouse button click: \qml -MouseArea { - onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); } -} + MouseArea { + onClicked: { + if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) + doSomething(); + } + } \endqml */ diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index cdfdc58..6fe1522 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -85,7 +85,11 @@ qreal QDeclarativeFlickableVisibleArea::yPosition() const void QDeclarativeFlickableVisibleArea::updateVisible() { QDeclarativeFlickablePrivate *p = static_cast<QDeclarativeFlickablePrivate *>(QGraphicsItemPrivate::get(flickable)); - bool pageChange = false; + + bool changeX = false; + bool changeY = false; + bool changeWidth = false; + bool changeHeight = false; // Vertical const qreal viewheight = flickable->height(); @@ -95,11 +99,11 @@ void QDeclarativeFlickableVisibleArea::updateVisible() if (pageSize != m_heightRatio) { m_heightRatio = pageSize; - pageChange = true; + changeHeight = true; } if (pagePos != m_yPosition) { m_yPosition = pagePos; - pageChange = true; + changeY = true; } // Horizontal @@ -110,14 +114,21 @@ void QDeclarativeFlickableVisibleArea::updateVisible() if (pageSize != m_widthRatio) { m_widthRatio = pageSize; - pageChange = true; + changeWidth = true; } if (pagePos != m_xPosition) { m_xPosition = pagePos; - pageChange = true; + changeX = true; } - if (pageChange) - emit pageChanged(); + + if (changeX) + emit xPositionChanged(m_xPosition); + if (changeY) + emit yPositionChanged(m_yPosition); + if (changeWidth) + emit widthRatioChanged(m_widthRatio); + if (changeHeight) + emit heightRatioChanged(m_heightRatio); } @@ -472,9 +483,9 @@ qreal QDeclarativeFlickable::contentX() const void QDeclarativeFlickable::setContentX(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->hData.move); d->vTime = d->timeline.time(); + movementXEnding(); if (-pos != d->hData.move.value()) { d->hData.move.setValue(-pos); viewportMoved(); @@ -490,9 +501,9 @@ qreal QDeclarativeFlickable::contentY() const void QDeclarativeFlickable::setContentY(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->vData.move); d->vTime = d->timeline.time(); + movementYEnding(); if (-pos != d->vData.move.value()) { d->vData.move.setValue(-pos); viewportMoved(); @@ -1484,6 +1495,15 @@ void QDeclarativeFlickable::movementStarting() void QDeclarativeFlickable::movementEnding() { Q_D(QDeclarativeFlickable); + movementXEnding(); + movementYEnding(); + d->hData.smoothVelocity.setValue(0); + d->vData.smoothVelocity.setValue(0); +} + +void QDeclarativeFlickable::movementXEnding() +{ + Q_D(QDeclarativeFlickable); if (d->flickingHorizontally) { d->flickingHorizontally = false; emit flickingChanged(); @@ -1491,13 +1511,6 @@ void QDeclarativeFlickable::movementEnding() if (!d->flickingVertically) emit flickEnded(); } - if (d->flickingVertically) { - d->flickingVertically = false; - emit flickingChanged(); - emit flickingVerticallyChanged(); - if (!d->flickingHorizontally) - emit flickEnded(); - } if (!d->pressed && !d->stealMouse) { if (d->movingHorizontally) { d->movingHorizontally = false; @@ -1507,6 +1520,20 @@ void QDeclarativeFlickable::movementEnding() if (!d->movingVertically) emit movementEnded(); } + } +} + +void QDeclarativeFlickable::movementYEnding() +{ + Q_D(QDeclarativeFlickable); + if (d->flickingVertically) { + d->flickingVertically = false; + emit flickingChanged(); + emit flickingVerticallyChanged(); + if (!d->flickingHorizontally) + emit flickEnded(); + } + if (!d->pressed && !d->stealMouse) { if (d->movingVertically) { d->movingVertically = false; d->vMoved = false; @@ -1516,8 +1543,6 @@ void QDeclarativeFlickable::movementEnding() emit movementEnded(); } } - d->hData.smoothVelocity.setValue(0); - d->vData.smoothVelocity.setValue(0); } void QDeclarativeFlickablePrivate::updateVelocity() diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 44f2bcf..6e4d8ed 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -163,7 +163,6 @@ Q_SIGNALS: void horizontalVelocityChanged(); void verticalVelocityChanged(); void isAtBoundaryChanged(); - void pageChanged(); void flickableDirectionChanged(); void interactiveChanged(); void boundsBehaviorChanged(); @@ -191,6 +190,8 @@ protected Q_SLOTS: void movementEnding(); protected: + void movementXEnding(); + void movementYEnding(); virtual qreal minXExtent() const; virtual qreal minYExtent() const; virtual qreal maxXExtent() const; diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index beee741..afefde2 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -182,10 +182,10 @@ class QDeclarativeFlickableVisibleArea : public QObject { Q_OBJECT - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) + Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged) + Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged) + Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged) + Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) public: QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent=0); @@ -198,7 +198,10 @@ public: void updateVisible(); signals: - void pageChanged(); + void xPositionChanged(qreal xPosition); + void yPositionChanged(qreal yPosition); + void widthRatioChanged(qreal widthRatio); + void heightRatioChanged(qreal heightRatio); private: QDeclarativeFlickable *flickable; diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 4ecf87b..f118a85 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -83,27 +83,28 @@ public: \section1 Example Usage - \beginfloatright - \inlineimage flipable.gif - \endfloat - The following example shows a Flipable item that flips whenever it is clicked, rotating about the y-axis. - The \l Rotation element is used to specify the angle and axis of the flip. - When \c flipped is true, the item changes to the "back" state, where - the angle is changed to 180 degrees to produce the flipping effect. + This flipable item has a \c flipped boolean property that is toggled + whenever the MouseArea within the flipable is clicked. When + \c flipped is true, the item changes to the "back" state; in this + state, the \c angle of the \l Rotation item is changed to 180 + degrees to produce the flipping effect. When \c flipped is false, the + item reverts to the default state, in which the \c angle value is 0. + + \snippet doc/src/snippets/declarative/flipable/flipable.qml 0 - \clearfloat - \snippet doc/src/snippets/declarative/flipable/flipable-snippet.qml 0 + \image flipable.gif - The \l Transition creates the animation that changes the angle over the - duration of one second. When the item changes between its "back" and + The \l Transition creates the animation that changes the angle over + four seconds. When the item changes between its "back" and default states, the NumberAnimation animates the angle between its old and new values. - See the \l {QML States} and \l {QML Animation} documentation for more - details on state changes and how animations work within transitions. + See \l {QML States} for details on state changes and the default + state, and \l {QML Animation} for more information on how animations + work within transitions. \sa {declarative/ui-components/flipable}{Flipable example} */ diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 6ee6b0d..6f38f63 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -112,7 +112,7 @@ public: , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarativeGridView::NoSnap) , ownModel(false), wrap(false), autoHighlight(true) , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) - , deferredRelease(false), haveHighlightRange(false) {} + , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {} void init(); void clear(); @@ -392,6 +392,7 @@ public: bool layoutScheduled : 1; bool deferredRelease : 1; bool haveHighlightRange : 1; + bool currentIndexCleared : 1; }; void QDeclarativeGridViewPrivate::init() @@ -730,6 +731,8 @@ void QDeclarativeGridViewPrivate::createHighlight() QDeclarative_setParent_noEvent(item, q->contentItem()); item->setParentItem(q->contentItem()); highlight = new FxGridItem(item, q); + if (currentItem) + highlight->setPosition(currentItem->colPos(), currentItem->rowPos()); highlightXAnimator = new QSmoothedAnimation(q); highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x")); highlightXAnimator->userDuration = highlightMoveDuration; @@ -771,8 +774,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) currentItem->attached->setIsCurrentItem(false); releaseItem(currentItem); currentItem = 0; - currentIndex = -1; + currentIndex = modelIndex; + emit q->currentIndexChanged(); updateHighlight(); + } else if (currentIndex != modelIndex) { + currentIndex = modelIndex; emit q->currentIndexChanged(); } return; @@ -1211,7 +1217,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); @@ -1236,7 +1242,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore | QDeclarativeGridViewPrivate::BufferAfter; if (isComponentComplete()) { refill(); - if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { + if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; @@ -1252,7 +1258,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); emit countChanged(); } @@ -1324,7 +1330,8 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) \qmlproperty Item GridView::currentItem The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. + \c currentItem holds the current item. Setting the currentIndex to -1 + will clear the highlight and set currentItem to null. If highlightFollowsCurrentItem is \c true, setting either of these properties will smoothly scroll the GridView so that the current @@ -1344,10 +1351,13 @@ void QDeclarativeGridView::setCurrentIndex(int index) Q_D(QDeclarativeGridView); if (d->requestedIndex >= 0) // currently creating item return; - if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + d->currentIndexCleared = (index == -1); + if (index == d->currentIndex) + return; + if (isComponentComplete() && d->isValid()) { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(index); - } else if (index != d->currentIndex) { + } else { d->currentIndex = index; emit currentIndexChanged(); } @@ -1822,6 +1832,8 @@ void QDeclarativeGridView::viewportMoved() { Q_D(QDeclarativeGridView); QDeclarativeFlickable::viewportMoved(); + if (!d->itemCount) + return; d->lazyRelease = true; if (d->flickingHorizontally || d->flickingVertically) { if (yflick()) { @@ -1983,22 +1995,25 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) Move the currentIndex up one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexUp() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { if (currentIndex() >= d->columns || d->wrap) { int index = currentIndex() - d->columns; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } else { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } } @@ -2008,22 +2023,25 @@ void QDeclarativeGridView::moveCurrentIndexUp() Move the currentIndex down one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexDown() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { - if (currentIndex() < d->model->count() - d->columns || d->wrap) { + if (currentIndex() < count - d->columns || d->wrap) { int index = currentIndex()+d->columns; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } else { - if (currentIndex() < d->model->count() - 1 || d->wrap) { + if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } } @@ -2033,22 +2051,25 @@ void QDeclarativeGridView::moveCurrentIndexDown() Move the currentIndex left one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexLeft() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } else { if (currentIndex() >= d->columns || d->wrap) { int index = currentIndex() - d->columns; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } } @@ -2058,22 +2079,25 @@ void QDeclarativeGridView::moveCurrentIndexLeft() Move the currentIndex right one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexRight() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { - if (currentIndex() < d->model->count() - 1 || d->wrap) { + if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } else { - if (currentIndex() < d->model->count() - d->columns || d->wrap) { + if (currentIndex() < count - d->columns || d->wrap) { int index = currentIndex()+d->columns; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } } @@ -2201,7 +2225,7 @@ void QDeclarativeGridView::componentComplete() if (d->isValid()) { refill(); d->moveReason = QDeclarativeGridViewPrivate::SetIndex; - if (d->currentIndex < 0) + if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else d->updateCurrent(d->currentIndex); @@ -2276,13 +2300,13 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) return; if (!d->visibleItems.count() || d->model->count() <= 1) { d->scheduleLayout(); - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; emit currentIndexChanged(); - } else if (d->currentIndex < 0) { + } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) { d->updateCurrent(0); } d->itemCount += count; @@ -2390,7 +2414,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) } } - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) { @@ -2477,8 +2501,8 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) if (removedVisible && d->visibleItems.isEmpty()) { d->timeline.clear(); - d->setPosition(0); if (d->itemCount == 0) { + d->setPosition(0); d->updateHeader(); d->updateFooter(); update(); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 51eb5f2..95a4fd6 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -728,41 +728,39 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) \since 4.7 \brief The Keys attached property provides key handling to Items. - All visual primitives support key handling via the \e Keys - attached property. Keys can be handled via the \e onPressed - and \e onReleased signal properties. + All visual primitives support key handling via the Keys + attached property. Keys can be handled via the onPressed + and onReleased signal properties. The signal properties have a \l KeyEvent parameter, named \e event which contains details of the event. If a key is handled \e event.accepted should be set to true to prevent the event from propagating up the item hierarchy. - \code - Item { - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Left) { - console.log("move left"); - event.accepted = true; - } - } - } - \endcode + \section1 Example Usage + + The following example shows how the general onPressed handler can + be used to test for a certain key; in this case, the left cursor + key: + + \snippet doc/src/snippets/declarative/keys/keys-pressed.qml key item Some keys may alternatively be handled via specific signal properties, for example \e onSelectPressed. These handlers automatically set \e event.accepted to true. - \code - Item { - focus: true - Keys.onLeftPressed: console.log("move left") - } - \endcode + \snippet doc/src/snippets/declarative/keys/keys-handler.qml key item + + See \l{Qt::Key}{Qt.Key} for the list of keyboard codes. - See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. + \section1 Key Handling Priorities - If priority is Keys.BeforeItem (default) the order of key event processing is: + The Keys attached property can be configured to handle key events + before or after the item it is attached to. This makes it possible + to intercept events in order to override an item's default behavior, + or act as a fallback for keys not handled by the item. + + If \l priority is Keys.BeforeItem (default) the order of key event processing is: \list 1 \o Items specified in \c forwardTo @@ -773,6 +771,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) \endlist If priority is Keys.AfterItem the order of key event processing is: + \list 1 \o Item specific key handling, e.g. TextInput key handling \o Items specified in \c forwardTo diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 6fd3b71..38a4839 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -182,7 +182,8 @@ public: , bufferMode(BufferBefore | BufferAfter) , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false) , correctFlick(false), inFlickCorrection(false), lazyRelease(false) - , deferredRelease(false), layoutScheduled(false), minExtentDirty(true), maxExtentDirty(true) + , deferredRelease(false), layoutScheduled(false), currentIndexCleared(false) + , minExtentDirty(true), maxExtentDirty(true) {} void init(); @@ -393,44 +394,19 @@ public: } // map a model index to visibleItems index. - // These may differ if removed items are still present in the visible list, - // e.g. doing a removal animation int mapFromModel(int modelIndex) const { if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) return -1; for (int i = 0; i < visibleItems.count(); ++i) { FxListItem *listItem = visibleItems.at(i); if (listItem->index == modelIndex) - return i + visibleIndex; + return i; if (listItem->index > modelIndex) return -1; } return -1; // Not in visibleList } - bool mapRangeFromModel(int &index, int &count) const { - if (index + count < visibleIndex) - return false; - - int lastIndex = -1; - for (int i = visibleItems.count()-1; i >= 0; --i) { - FxListItem *listItem = visibleItems.at(i); - if (listItem->index != -1) { - lastIndex = listItem->index; - break; - } - } - - if (index > lastIndex) - return false; - - int last = qMin(index + count - 1, lastIndex); - index = qMax(index, visibleIndex); - count = last - index + 1; - - return true; - } - void updateViewport() { Q_Q(QDeclarativeListView); if (orient == QDeclarativeListView::Vertical) { @@ -544,6 +520,7 @@ public: bool lazyRelease : 1; bool deferredRelease : 1; bool layoutScheduled : 1; + bool currentIndexCleared : 1; mutable bool minExtentDirty : 1; mutable bool maxExtentDirty : 1; }; @@ -881,6 +858,7 @@ void QDeclarativeListViewPrivate::createHighlight() } else { highlight->item->setWidth(currentItem->item->width()); } + highlight->setPosition(currentItem->itemPosition()); } QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); @@ -1045,8 +1023,11 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) currentItem->attached->setIsCurrentItem(false); releaseItem(currentItem); currentItem = 0; - currentIndex = -1; + currentIndex = modelIndex; + emit q->currentIndexChanged(); updateHighlight(); + } else if (currentIndex != modelIndex) { + currentIndex = modelIndex; emit q->currentIndexChanged(); } return; @@ -1567,7 +1548,7 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); @@ -1598,7 +1579,7 @@ void QDeclarativeListView::setModel(const QVariant &model) if (isComponentComplete()) { updateSections(); refill(); - if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { + if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { d->moveReason = QDeclarativeListViewPrivate::SetIndex; @@ -1614,7 +1595,7 @@ void QDeclarativeListView::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); emit countChanged(); } @@ -1688,7 +1669,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) \qmlproperty Item ListView::currentItem The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. + \c currentItem holds the current item. Setting the currentIndex to -1 + will clear the highlight and set currentItem to null. If highlightFollowsCurrentItem is \c true, setting either of these properties will smoothly scroll the ListView so that the current @@ -1708,10 +1690,13 @@ void QDeclarativeListView::setCurrentIndex(int index) Q_D(QDeclarativeListView); if (d->requestedIndex >= 0) // currently creating item return; - if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + d->currentIndexCleared = (index == -1); + if (index == d->currentIndex) + return; + if (isComponentComplete() && d->isValid()) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(index); - } else if (index != d->currentIndex) { + } else { d->currentIndex = index; emit currentIndexChanged(); } @@ -2320,6 +2305,8 @@ void QDeclarativeListView::viewportMoved() { Q_D(QDeclarativeListView); QDeclarativeFlickable::viewportMoved(); + if (!d->itemCount) + return; d->lazyRelease = true; refill(); if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) @@ -2523,16 +2510,18 @@ void QDeclarativeListView::geometryChanged(const QRectF &newGeometry, Increments the current index. The current index will wrap if keyNavigationWraps is true and it is currently at the end. + This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeListView::incrementCurrentIndex() { Q_D(QDeclarativeListView); - if (currentIndex() < d->model->count() - 1 || d->wrap) { + int count = d->model ? d->model->count() : 0; + if (count && (currentIndex() < count - 1 || d->wrap)) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; int index = currentIndex()+1; - d->updateCurrent(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } @@ -2541,16 +2530,18 @@ void QDeclarativeListView::incrementCurrentIndex() Decrements the current index. The current index will wrap if keyNavigationWraps is true and it is currently at the beginning. + This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeListView::decrementCurrentIndex() { Q_D(QDeclarativeListView); - if (currentIndex() > 0 || d->wrap) { + int count = d->model ? d->model->count() : 0; + if (count && (currentIndex() > 0 || d->wrap)) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; int index = currentIndex()-1; - d->updateCurrent(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } @@ -2684,7 +2675,7 @@ void QDeclarativeListView::componentComplete() if (d->isValid()) { refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; - if (d->currentIndex < 0) + if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else d->updateCurrent(d->currentIndex); @@ -2784,13 +2775,13 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->moveReason = QDeclarativeListViewPrivate::Other; if (!d->visibleItems.count() || d->model->count() <= 1) { d->scheduleLayout(); - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; emit currentIndexChanged(); - } else if (d->currentIndex < 0) { + } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) { d->updateCurrent(0); } d->itemCount += count; @@ -2798,15 +2789,15 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) return; } - int overlapCount = count; - if (!d->mapRangeFromModel(modelIndex, overlapCount)) { + int index = d->mapFromModel(modelIndex); + if (index < 0) { int i = d->visibleItems.count() - 1; while (i > 0 && d->visibleItems.at(i)->index == -1) --i; if (d->visibleItems.at(i)->index + 1 == modelIndex && d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) { // Special case of appending an item to the model. - modelIndex = d->visibleIndex + d->visibleItems.count(); + index = d->visibleItems.count(); } else { if (modelIndex < d->visibleIndex) { // Insert before visible items @@ -2833,7 +2824,6 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) // At least some of the added items will be visible - int index = modelIndex - d->visibleIndex; // index can be the next item past the end of the visible items list (i.e. appended) int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position() : d->visibleItems.at(index-1)->endPosition()+d->spacing+1; @@ -2897,7 +2887,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) } diff = pos - initialPos; } - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) { diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 1533d55..1b7dce0 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -335,7 +335,7 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() If the \e accepted property of the \l {MouseEvent}{mouse} parameter is set to false in the handler, the onPressed/onReleased/onClicked handlers will be called for the second - click; otherwise they are supressed. The accepted property defaults to true. + click; otherwise they are suppressed. The accepted property defaults to true. */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index d526688..966c51b 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -871,7 +871,7 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path) */ /*! - \qmlproperty real value + \qmlproperty real PathPercent::value The proporation of items that should be laid out up to this point. This value should always be higher than the last value specified diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 81c84f5..dc3d5ee 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -467,7 +467,7 @@ void QDeclarativePathView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); for (int i=0; i<d->items.count(); i++){ QDeclarativeItem *p = d->items[i]; d->model->release(p); @@ -498,7 +498,7 @@ void QDeclarativePathView::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); d->modelCount = d->model->count(); if (d->model->count()) d->offset = qmlMod(d->offset, qreal(d->model->count())); diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index 15b91e5..d3ae926 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeBasePositionerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 9831d5f..1ffd3bd 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -261,9 +261,9 @@ void QDeclarativeRectangle::doUpdate() A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain - border smoothness. Also, the border is rendered evenly on either side of the + border smoothness. Also, the border is rendered evenly on either side of the rectangle's boundaries, and the spare pixel is rendered to the right and below the - rectangle (as documented for QRect rendering). This can cause unintended effects if + rectangle (as documented for QRect rendering). This can cause unintended effects if \c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item: \beginfloatright diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p.h index ecc3fbf..99dca1b 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle_p.h +++ b/src/declarative/graphicsitems/qdeclarativerectangle_p.h @@ -46,12 +46,14 @@ #include <QtGui/qbrush.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativePen : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePen : public QObject { Q_OBJECT @@ -131,7 +133,7 @@ private: }; class QDeclarativeRectanglePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeRectangle : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeRectangle : public QDeclarativeItem { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index cb64212..6f46c7b 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -202,7 +202,7 @@ void QDeclarativeRepeater::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); /* - disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); */ } @@ -230,7 +230,7 @@ void QDeclarativeRepeater::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); /* - connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); + connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); */ regenerate(); diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h index 42813dd..c6d4629 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h @@ -42,21 +42,22 @@ #ifndef QDECLARATIVESCALEGRID_H #define QDECLARATIVESCALEGRID_H -#include "private/qdeclarativeborderimage_p.h" - -#include <private/qdeclarativepixmapcache_p.h> #include <qdeclarative.h> #include <QtCore/QString> #include <QtCore/QObject> +#include <private/qdeclarativeborderimage_p.h> +#include <private/qdeclarativepixmapcache_p.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativeScaleGrid : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScaleGrid : public QObject { Q_OBJECT Q_ENUMS(TileRule) @@ -94,7 +95,7 @@ private: int _bottom; }; -class Q_DECLARATIVE_EXPORT QDeclarativeGridScaledImage +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeGridScaledImage { public: QDeclarativeGridScaledImage(); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 308aefa..0717b78 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -270,6 +270,7 @@ void QDeclarativeTextPrivate::updateSize() internalWidthUpdate = false; q->setImplicitHeight(size.height()); emit q->paintedSizeChanged(); + q->update(); } /*! @@ -1143,9 +1144,10 @@ QRectF QDeclarativeText::boundingRect() const void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QDeclarativeText); - if (!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width() && - (d->wrapMode != QDeclarativeText::NoWrap || d->elideMode != QDeclarativeText::ElideNone)) { - + if ((!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) + && (d->wrapMode != QDeclarativeText::NoWrap + || d->elideMode != QDeclarativeText::ElideNone + || d->hAlign != Qt::AlignLeft)) { if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && widthValid()) { // We need to re-elide d->updateLayout(); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index 2cc4d52..51434d5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -45,13 +45,15 @@ #include <QtGui/qtextoption.h> #include "qdeclarativeitem.h" +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeTextPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem { Q_OBJECT Q_ENUMS(HAlignment) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 0903427..2348478 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -792,7 +792,7 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) d->cursorComponent = c; if(!c){ //note that the components are owned by something else - disconnect(d->control, SIGNAL(cursorPositionChanged(int, int)), + disconnect(d->control, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(moveCursor())); delete d->cursorItem; }else{ @@ -805,7 +805,7 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) void QDeclarativeTextInputPrivate::startCreatingCursor() { Q_Q(QDeclarativeTextInput); - q->connect(control, SIGNAL(cursorPositionChanged(int, int)), + q->connect(control, SIGNAL(cursorPositionChanged(int,int)), q, SLOT(moveCursor())); if(cursorComponent->isReady()){ q->createCursor(); @@ -1446,7 +1446,7 @@ void QDeclarativeTextInputPrivate::init() q, SLOT(cursorPosChanged())); q->connect(control, SIGNAL(selectionChanged()), q, SLOT(selectionChanged())); - q->connect(control, SIGNAL(textChanged(const QString &)), + q->connect(control, SIGNAL(textChanged(QString)), q, SLOT(q_textChanged())); q->connect(control, SIGNAL(accepted()), q, SIGNAL(accepted())); diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp index e8b5fb2..89a2158 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp @@ -321,7 +321,7 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) priv->extended->type() == QPaintEngine::OpenVG || priv->extended->type() == QPaintEngine::OpenGL); - if (!paintEngineSupportsTransformations) { + if (!paintEngineSupportsTransformations || !priv->state->matrix.isAffine()) { QTextLayout::draw(painter, p); return; } diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index e569dd2..1f01a45 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -714,14 +714,14 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_itemsMoved(int,int,int))); d->m_listModelInterface = 0; } else if (d->m_abstractItemModel) { - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)), - this, SLOT(_q_rowsInserted(const QModelIndex &,int,int))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)), - this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), - this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), - this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(_q_rowsInserted(QModelIndex,int,int))); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); d->m_abstractItemModel = 0; @@ -762,14 +762,14 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) emit itemsInserted(0, d->m_listModelInterface->count()); return; } else if (object && (d->m_abstractItemModel = qobject_cast<QAbstractItemModel *>(object))) { - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(const QModelIndex &,int,int)), - this, SLOT(_q_rowsInserted(const QModelIndex &,int,int))); - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(const QModelIndex &,int,int)), - this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int))); - QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), - this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&))); - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), - this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); + QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(_q_rowsInserted(QModelIndex,int,int))); + QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); + QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); + QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); d->m_metaDataCacheable = true; |