diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-13 08:09:53 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-13 08:33:13 (GMT) |
commit | 5114fcb45d584ea50da7397088f084dfd74922b9 (patch) | |
tree | 18cb40f048186ebf0eac568e2ae53ec092044c55 /src/declarative | |
parent | 55e47566dd1ac83ff674401dfd6284f07490cd8b (diff) | |
parent | ee62807198a2525577c14f718b98d07ae0ec7bec (diff) | |
download | Qt-5114fcb45d584ea50da7397088f084dfd74922b9.zip Qt-5114fcb45d584ea50da7397088f084dfd74922b9.tar.gz Qt-5114fcb45d584ea50da7397088f084dfd74922b9.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
src/gui/painting/qpainter.cpp
src/gui/text/qtextengine.cpp
tests/auto/qimage/tst_qimage.cpp
tests/auto/qpainter/tst_qpainter.cpp
tools/qdoc3/test/assistant.qdocconf
tools/qdoc3/test/designer.qdocconf
tools/qdoc3/test/linguist.qdocconf
tools/qdoc3/test/qmake.qdocconf
tools/qdoc3/test/qt-build-docs.qdocconf
tools/qdoc3/test/qt-html-templates.qdocconf
tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
tools/qdoc3/test/qt.qdocconf
Diffstat (limited to 'src/declarative')
63 files changed, 807 insertions, 475 deletions
diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index 6241922..c2f7709 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -125,7 +125,7 @@ public: QObject::connect(this, SIGNAL(invalidPacket()), parent, SIGNAL(invalidPacket())); QObject::connect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); + this, SLOT(readyToRead()), Qt::QueuedConnection); QObject::connect(dev, SIGNAL(aboutToClose()), this, SLOT(aboutToClose())); QObject::connect(dev, SIGNAL(bytesWritten(qint64)), @@ -422,7 +422,7 @@ QPacket::~QPacket() /*! Creates a copy of \a other. The initial stream positions are shared, but the - two packets are otherwise independant. + two packets are otherwise independent. */ QPacket::QPacket(const QPacket & other) : QDataStream(), b(other.b), buf(0) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 03ba740..61b4dcd 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -681,12 +681,15 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) { - if (newY > minY) - newY = minY; - else if (newY < maxY) + rejectY = true; + if (newY < maxY) { newY = maxY; - else - rejectY = true; + rejectY = false; + } + if (newY > minY) { + newY = minY; + rejectY = false; + } } if (!rejectY && stealMouse) { vData.move.setValue(qRound(newY)); @@ -708,12 +711,15 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) { - if (newX > minX) - newX = minX; - else if (newX < maxX) + rejectX = true; + if (newX < maxX) { newX = maxX; - else - rejectX = true; + rejectX = false; + } + if (newX > minX) { + newX = minX; + rejectX = false; + } } if (!rejectX && stealMouse) { hData.move.setValue(qRound(newX)); @@ -1466,21 +1472,23 @@ void QDeclarativeFlickable::movementEnding() if (!d->flickingHorizontally) emit flickEnded(); } - if (d->movingHorizontally) { - d->movingHorizontally = false; - d->hMoved = false; - emit movingChanged(); - emit movingHorizontallyChanged(); - if (!d->movingVertically) - emit movementEnded(); - } - if (d->movingVertically) { - d->movingVertically = false; - d->vMoved = false; - emit movingChanged(); - emit movingVerticallyChanged(); - if (!d->movingHorizontally) - emit movementEnded(); + if (!d->pressed && !d->stealMouse) { + if (d->movingHorizontally) { + d->movingHorizontally = false; + d->hMoved = false; + emit movingChanged(); + emit movingHorizontallyChanged(); + if (!d->movingVertically) + emit movementEnded(); + } + if (d->movingVertically) { + d->movingVertically = false; + d->vMoved = false; + emit movingChanged(); + emit movingVerticallyChanged(); + if (!d->movingHorizontally) + emit movementEnded(); + } } d->hData.smoothVelocity.setValue(0); d->vData.smoothVelocity.setValue(0); diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 8c9d2dd..b266273 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -83,10 +83,16 @@ public: \image flipable.gif - The \l Rotation element is used to specify the angle and axis of the flip, - and the \l State defines the changes in angle which produce the flipping - effect. Finally, the \l Transition creates the animation that changes the - angle over one second. + The \l Rotation element is used to specify the angle and axis of the flip. + When \c flipped is \c true, the item changes to the "back" state, where + the angle is changed to 180 degrees to produce the flipping effect. + Finally, the \l Transition creates the animation that changes the + angle over one second: 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. \sa {declarative/ui-components/flipable}{Flipable example} */ diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 89b3958..68a4c64 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1085,13 +1085,15 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \c portrait data directly. An improved grid view is shown below. The delegate is visually improved and is moved - into a separate \c contactDelegate component. Also, the currently selected item is highlighted - with a blue \l Rectangle using the \l highlight property, and \c focus is set to \c true - to enable keyboard navigation for the grid view. + into a separate \c contactDelegate component. \snippet doc/src/snippets/declarative/gridview/gridview.qml classdocs advanced \image gridview-highlight.png + The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property, + and \c focus is set to \c true to enable keyboard navigation for the grid view. + The grid view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). + Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. @@ -1276,6 +1278,11 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); if (isComponentComplete()) { + for (int i = 0; i < d->visibleItems.count(); ++i) + d->releaseItem(d->visibleItems.at(i)); + d->visibleItems.clear(); + d->releaseItem(d->currentItem); + d->currentItem = 0; refill(); d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 83f9b20..cc7c673 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -423,7 +423,7 @@ void QDeclarativeItemKeyFilter::componentComplete() \brief The KeyNavigation attached property supports key navigation by arrow keys. It is common in key-based UIs to use arrow keys to navigate - between focussed items. The KeyNavigation property provides a + between focused items. The KeyNavigation property provides a convenient way of specifying which item will gain focus when an arrow key is pressed. The following example provides key navigation for a 2x2 grid of items. @@ -511,8 +511,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::left() const void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->left == i) + return; d->left = i; - emit changed(); + emit leftChanged(); } QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const @@ -524,8 +526,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->right == i) + return; d->right = i; - emit changed(); + emit rightChanged(); } QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const @@ -537,8 +541,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->up == i) + return; d->up = i; - emit changed(); + emit upChanged(); } QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const @@ -550,8 +556,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->down == i) + return; d->down = i; - emit changed(); + emit downChanged(); } QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const @@ -563,8 +571,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->tab == i) + return; d->tab = i; - emit changed(); + emit tabChanged(); } QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const @@ -576,8 +586,10 @@ QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) { Q_D(QDeclarativeKeyNavigationAttached); + if (d->backtab == i) + return; d->backtab = i; - emit changed(); + emit backtabChanged(); } /*! @@ -1420,11 +1432,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec */ /*! - \fn void QDeclarativeItem::childrenChanged() - \internal -*/ - -/*! \fn void QDeclarativeItem::focusChanged(bool) \internal */ @@ -2399,18 +2406,7 @@ void QDeclarativeItemPrivate::focusChanged(bool flag) Q_Q(QDeclarativeItem); if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent) emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange() - - bool inScope = false; - QGraphicsItem *p = parent; - while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - inScope = true; - break; - } - p = p->parentItem(); - } - if (!inScope) - emit q->focusChanged(flag); + emit q->focusChanged(flag); } /*! \internal */ @@ -2458,7 +2454,7 @@ QDeclarativeListProperty<QDeclarativeState> QDeclarativeItemPrivate::states() } \endqml - \sa {state-transitions}{Transitions} + \sa {qdeclarativeanimation.html#transitions}{QML Transitions} */ @@ -2482,7 +2478,7 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi Item { filter: [ Blur { ... }, - Relection { ... } + Reflection { ... } ... ] } @@ -2504,7 +2500,9 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi This property holds whether clipping is enabled. if clipping is enabled, an item will clip its own painting, as well - as the painting of its children, to its bounding rectangle. + as the painting of its children, to its bounding rectangle. If you set + clipping during an item's paint operation, remember to re-set it to + prevent clipping the rest of your scene. Non-rectangular clipping regions are not supported for performance reasons. */ @@ -2728,12 +2726,12 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, } break; case ItemChildAddedChange: - if (d->_contents) + if (d->_contents && d->componentComplete) d->_contents->childAdded(qobject_cast<QDeclarativeItem*>( value.value<QGraphicsItem*>())); break; case ItemChildRemovedChange: - if (d->_contents) + if (d->_contents && d->componentComplete) d->_contents->childRemoved(qobject_cast<QDeclarativeItem*>( value.value<QGraphicsItem*>())); break; @@ -2843,6 +2841,41 @@ void QDeclarativeItem::setSmooth(bool smooth) } /*! + \property QDeclarativeItem::anchors + \internal +*/ + +/*! + \property QDeclarativeItem::left + \internal +*/ + +/*! + \property QDeclarativeItem::right + \internal +*/ + +/*! + \property QDeclarativeItem::horizontalCenter + \internal +*/ + +/*! + \property QDeclarativeItem::top + \internal +*/ + +/*! + \property QDeclarativeItem::bottom + \internal +*/ + +/*! + \property QDeclarativeItem::verticalCenter + \internal +*/ + +/*! \property QDeclarativeItem::focus \internal */ @@ -2863,6 +2896,41 @@ void QDeclarativeItem::setSmooth(bool smooth) */ /*! + \property QDeclarativeItem::baseline + \internal +*/ + +/*! + \property QDeclarativeItem::data + \internal +*/ + +/*! + \property QDeclarativeItem::resources + \internal +*/ + +/*! + \property QDeclarativeItem::state + \internal +*/ + +/*! + \property QDeclarativeItem::states + \internal +*/ + +/*! + \property QDeclarativeItem::transformOriginPoint + \internal +*/ + +/*! + \property QDeclarativeItem::transitions + \internal +*/ + +/*! \internal Return the width of the item */ @@ -3130,8 +3198,7 @@ bool QDeclarativeItem::hasActiveFocus() const { Q_D(const QDeclarativeItem); return focusItem() == this || - (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) || - (!parentItem() && focusItem() != 0); + (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0); } /*! @@ -3151,10 +3218,8 @@ bool QDeclarativeItem::hasActiveFocus() const } \endqml - For the purposes of this property, the top level item in the scene - is assumed to act like a focus scope, and to always have active focus - when the scene has focus. On a practical level, that means the following - QML will give active focus to \c input on startup. + For the purposes of this property, the scene as a whole is assumed to act like a focus scope. + On a practical level, that means the following QML will give active focus to \c input on startup. \qml Rectangle { @@ -3180,7 +3245,7 @@ bool QDeclarativeItem::hasFocus() const p = p->parentItem(); } - return hasActiveFocus() ? true : (!QGraphicsItem::parentItem() ? true : false); + return hasActiveFocus(); } /*! \internal */ diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 8c3e084..fffb4f7 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -363,12 +363,12 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeKeyNavigationAttached) - Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY changed) - Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY changed) - Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY changed) - Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed) - Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed) - Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed) + Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY leftChanged) + Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY rightChanged) + Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY upChanged) + Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY downChanged) + Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY tabChanged) + Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged) Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) Q_ENUMS(Priority) @@ -396,7 +396,12 @@ public: static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: - void changed(); + void leftChanged(); + void rightChanged(); + void upChanged(); + void downChanged(); + void tabChanged(); + void backtabChanged(); void priorityChanged(); private: diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 5d623dc..783eff1 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -142,7 +142,9 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType<QGraphicsScale>("Qt",4,7,"Scale"); qmlRegisterType<QDeclarativeText>("Qt",4,7,"Text"); qmlRegisterType<QDeclarativeTextEdit>("Qt",4,7,"TextEdit"); +#ifndef QT_NO_LINEEDIT qmlRegisterType<QDeclarativeTextInput>("Qt",4,7,"TextInput"); +#endif qmlRegisterType<QDeclarativeViewSection>("Qt",4,7,"ViewSection"); qmlRegisterType<QDeclarativeVisualDataModel>("Qt",4,7,"VisualDataModel"); qmlRegisterType<QDeclarativeVisualItemModel>("Qt",4,7,"VisualItemModel"); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 8b616ce..e1dd1c0 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -60,7 +60,7 @@ void QDeclarativeViewSection::setProperty(const QString &property) { if (property != m_property) { m_property = property; - emit changed(); + emit propertyChanged(); } } @@ -68,7 +68,7 @@ void QDeclarativeViewSection::setCriteria(QDeclarativeViewSection::SectionCriter { if (criteria != m_criteria) { m_criteria = criteria; - emit changed(); + emit criteriaChanged(); } } @@ -575,9 +575,11 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) listItem->attached->m_prevSection = item->attached->section(); else listItem->attached->m_prevSection = sectionAt(modelIndex-1); + } + if (modelIndex < model->count()-1) { if (FxListItem *item = visibleItem(modelIndex+1)) listItem->attached->m_nextSection = item->attached->section(); - else if (modelIndex < model->count()-1) + else listItem->attached->m_nextSection = sectionAt(modelIndex+1); } } @@ -1019,7 +1021,7 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); if (currentItem) { - if (modelIndex == visibleIndex - 1) { + if (modelIndex == visibleIndex - 1 && visibleItems.count()) { // We can calculate exact postion in this case currentItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing); } else { @@ -1385,14 +1387,16 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m the delegate is able to access the model's \c name and \c number data directly. An improved list view is shown below. The delegate is visually improved and is moved - into a separate \c contactDelegate component. Also, the currently selected item is highlighted - with a blue \l Rectangle using the \l highlight property, and \c focus is set to \c true - to enable keyboard navigation for the list view. + into a separate \c contactDelegate component. \snippet doc/src/snippets/declarative/listview/listview.qml classdocs advanced \image listview-highlight.png - In a GridView, delegates are instantiated as needed and may be destroyed at any time. + The currently selected item is highlighted with a blue \l Rectangle using the \l highlight property, + and \c focus is set to \c true to enable keyboard navigation for the list view. + The list view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). + + Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. \note Views do not enable \e clip automatically. If the view @@ -1616,6 +1620,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) for (int i = 0; i < d->visibleItems.count(); ++i) d->releaseItem(d->visibleItems.at(i)); d->visibleItems.clear(); + d->releaseItem(d->currentItem); + d->currentItem = 0; refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 9941040..b264861 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -53,8 +53,8 @@ QT_MODULE(Declarative) class Q_AUTOTEST_EXPORT QDeclarativeViewSection : public QObject { Q_OBJECT - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY changed) - Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY changed) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) + Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_ENUMS(SectionCriteria) public: @@ -73,7 +73,8 @@ public: QString sectionString(const QString &value); Q_SIGNALS: - void changed(); + void propertyChanged(); + void criteriaChanged(); void delegateChanged(); private: diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index cc7f8e5..d28181e 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -159,6 +159,9 @@ void QDeclarativeLoaderPrivate::initResize() unloads "Page1.qml" and frees resources consumed by it. + Note that Loader is a focus scope. Its \c focus property must be set to \c true for any of its children + to get the \e {active focus} (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). + \sa {dynamic-object-creation}{Dynamic Object Creation} */ diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index 80196a1..c48011d3 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -474,6 +474,7 @@ void QDeclarativeCurve::setX(qreal x) { if (_x != x) { _x = x; + emit xChanged(); emit changed(); } } @@ -487,6 +488,7 @@ void QDeclarativeCurve::setY(qreal y) { if (_y != y) { _y = y; + emit yChanged(); emit changed(); } } @@ -576,6 +578,7 @@ void QDeclarativePathAttribute::setValue(qreal value) { if (_value != value) { _value = value; + emit valueChanged(); emit changed(); } } @@ -678,6 +681,7 @@ void QDeclarativePathQuad::setControlX(qreal x) { if (_controlX != x) { _controlX = x; + emit controlXChanged(); emit changed(); } } @@ -695,6 +699,7 @@ void QDeclarativePathQuad::setControlY(qreal y) { if (_controlY != y) { _controlY = y; + emit controlYChanged(); emit changed(); } } @@ -761,6 +766,7 @@ void QDeclarativePathCubic::setControl1X(qreal x) { if (_control1X != x) { _control1X = x; + emit control1XChanged(); emit changed(); } } @@ -774,6 +780,7 @@ void QDeclarativePathCubic::setControl1Y(qreal y) { if (_control1Y != y) { _control1Y = y; + emit control1YChanged(); emit changed(); } } @@ -793,6 +800,7 @@ void QDeclarativePathCubic::setControl2X(qreal x) { if (_control2X != x) { _control2X = x; + emit control2XChanged(); emit changed(); } } @@ -806,6 +814,7 @@ void QDeclarativePathCubic::setControl2Y(qreal y) { if (_control2Y != y) { _control2Y = y; + emit control2YChanged(); emit changed(); } } diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h index 001bcdf..5ab5cfd 100644 --- a/src/declarative/graphicsitems/qdeclarativepath_p.h +++ b/src/declarative/graphicsitems/qdeclarativepath_p.h @@ -68,7 +68,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePathAttribute : public QDeclarativePathEleme Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed) + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) public: QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {} @@ -81,6 +81,7 @@ public: Q_SIGNALS: void nameChanged(); + void valueChanged(); private: QString _name; @@ -91,8 +92,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeCurve : public QDeclarativePathElement { Q_OBJECT - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY changed) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY changed) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) public: QDeclarativeCurve(QObject *parent=0) : QDeclarativePathElement(parent), _x(0), _y(0) {} @@ -104,6 +105,10 @@ public: virtual void addToPath(QPainterPath &) {} +Q_SIGNALS: + void xChanged(); + void yChanged(); + private: qreal _x; qreal _y; @@ -122,8 +127,8 @@ class Q_AUTOTEST_EXPORT QDeclarativePathQuad : public QDeclarativeCurve { Q_OBJECT - Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY changed) - Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY changed) + Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged) + Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged) public: QDeclarativePathQuad(QObject *parent=0) : QDeclarativeCurve(parent), _controlX(0), _controlY(0) {} @@ -135,6 +140,10 @@ public: void addToPath(QPainterPath &path); +Q_SIGNALS: + void controlXChanged(); + void controlYChanged(); + private: qreal _controlX; qreal _controlY; @@ -144,10 +153,10 @@ class Q_AUTOTEST_EXPORT QDeclarativePathCubic : public QDeclarativeCurve { Q_OBJECT - Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY changed) - Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY changed) - Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY changed) - Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY changed) + Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY control1XChanged) + Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY control1YChanged) + Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY control2XChanged) + Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY control2YChanged) public: QDeclarativePathCubic(QObject *parent=0) : QDeclarativeCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {} @@ -165,11 +174,17 @@ public: void addToPath(QPainterPath &path); +Q_SIGNALS: + void control1XChanged(); + void control1YChanged(); + void control2XChanged(); + void control2YChanged(); + private: - int _control1X; - int _control1Y; - int _control2X; - int _control2Y; + qreal _control1X; + qreal _control1Y; + qreal _control2X; + qreal _control2Y; }; class Q_AUTOTEST_EXPORT QDeclarativePathPercent : public QDeclarativePathElement diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index acf9827..380c6ad 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -90,6 +90,26 @@ void QDeclarativePathViewAttached::setValue(const QByteArray &name, const QVaria m_metaobject->setValue(name, val); } + +void QDeclarativePathViewPrivate::init() +{ + Q_Q(QDeclarativePathView); + offset = 0; + q->setAcceptedMouseButtons(Qt::LeftButton); + q->setFlag(QGraphicsItem::ItemIsFocusScope); + q->setFiltersChildEvents(true); + q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); + lastPosTime.invalidate(); + static int timelineCompletedIdx = -1; + static int movementEndingIdx = -1; + if (timelineCompletedIdx == -1) { + timelineCompletedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("completed()"); + movementEndingIdx = QDeclarativePathView::staticMetaObject.indexOfSlot("movementEnding()"); + } + QMetaObject::connect(&tl, timelineCompletedIdx, + q, movementEndingIdx, Qt::DirectConnection); +} + QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex) { Q_Q(QDeclarativePathView); @@ -314,7 +334,7 @@ void QDeclarativePathViewPrivate::regenerate() and XmlListModel, or custom model classes defined in C++ that inherit from QAbstractListModel. - A ListView has a \l model, which defines the data to be displayed, and + The view has a \l model, which defines the data to be displayed, and a \l delegate, which defines how the data should be displayed. The \l delegate is instantiated for each item on the \l path. The items may be flicked to move them along the path. @@ -333,6 +353,9 @@ void QDeclarativePathViewPrivate::regenerate() opacity of the items as they rotate. This additional code can be seen in the PathAttribute documentation.) + The \c focus can be set to \c true to enable keyboard navigation. + The path view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). + Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. @@ -341,7 +364,7 @@ void QDeclarativePathViewPrivate::regenerate() to set \e {clip: true} in order to have the out of view items clipped nicely. - \sa Path + \sa Path, {declarative/modelviews/pathview}{PathView example} */ QDeclarativePathView::QDeclarativePathView(QDeclarativeItem *parent) @@ -403,7 +426,7 @@ QDeclarativePathView::~QDeclarativePathView() The model provides a set of data that is used to create the items for the view. For large or dynamic datasets the model is usually provided by a C++ model object. - Models can also be created directly in XML, using the ListModel element. + Models can also be created directly in QML, using the ListModel element. \sa {qmlmodels}{Data Models} */ @@ -627,8 +650,8 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) so as to stay with the current item. The below example demonstrates how to make a simple highlight. Note the use - of the PathView.onPath property to ensure that the highlight is hidden - when flicked off of the path. + of the \l{PathView::onPath}{PathView.onPath} attached property to ensure that + the highlight is hidden when flicked away from the path. \code Component { @@ -848,6 +871,61 @@ void QDeclarativePathView::setInteractive(bool interactive) } /*! + \qmlproperty bool PathView::moving + + This property holds whether the view is currently moving + due to the user either dragging or flicking the view. +*/ +bool QDeclarativePathView::isMoving() const +{ + Q_D(const QDeclarativePathView); + return d->moving; +} + +/*! + \qmlproperty bool PathView::flicking + + This property holds whether the view is currently moving + due to the user flicking the view. +*/ +bool QDeclarativePathView::isFlicking() const +{ + Q_D(const QDeclarativePathView); + return d->flicking; +} + +/*! + \qmlsignal PathView::onMovementStarted() + + This handler is called when the view begins moving due to user + interaction. +*/ + +/*! + \qmlsignal PathView::onMovementEnded() + + This handler is called when the view stops moving due to user + interaction. If a flick was generated, this handler will + be triggered once the flick stops. If a flick was not + generated, the handler will be triggered when the + user stops dragging - i.e. a mouse or touch release. +*/ + +/*! + \qmlsignal PathView::onFlickStarted() + + This handler is called when the view is flicked. A flick + starts from the point that the mouse or touch is released, + while still in motion. +*/ + +/*! + \qmlsignal PathView::onFlickEnded() + + This handler is called when the view stops moving due to a flick. +*/ + +/*! \qmlproperty Component PathView::delegate The delegate provides a template defining each item instantiated by the view. @@ -964,7 +1042,11 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) return; } - d->stealMouse = false; + if (d->tl.isActive() && d->flicking) + d->stealMouse = true; // If we've been flicked then steal the click. + else + d->stealMouse = false; + d->lastElapsed = 0; d->lastDist = 0; QDeclarativeItemPrivate::start(d->lastPosTime); @@ -979,7 +1061,7 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (!d->stealMouse) { QPointF delta = event->pos() - d->startPoint; - if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance()) + if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) d->stealMouse = true; } @@ -1000,6 +1082,11 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) d->lastDist = diff; d->startPc = newPc; } + if (!d->moving) { + d->moving = true; + emit movingChanged(); + emit movementStarted(); + } } } @@ -1039,12 +1126,19 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) d->moveOffset.setValue(d->offset); d->tl.accel(d->moveOffset, velocity, accel, dist); d->tl.callback(QDeclarativeTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d)); + if (!d->flicking) { + d->flicking = true; + emit flickingChanged(); + emit flickStarted(); + } } else { d->fixOffset(); } d->lastPosTime.invalidate(); ungrabMouse(); + if (!d->tl.isActive()) + movementEnding(); } bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) @@ -1372,6 +1466,21 @@ void QDeclarativePathView::ticked() d->updateCurrent(); } +void QDeclarativePathView::movementEnding() +{ + Q_D(QDeclarativePathView); + if (d->flicking) { + d->flicking = false; + emit flickingChanged(); + emit flickEnded(); + } + if (d->moving && !d->stealMouse) { + d->moving = false; + emit movingChanged(); + emit movementEnded(); + } +} + // find the item closest to the snap position int QDeclarativePathViewPrivate::calcCurrentIndex() { diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index d2980c6..035a64b 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -74,6 +74,9 @@ class Q_AUTOTEST_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) + Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) + Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) @@ -122,6 +125,9 @@ public: bool isInteractive() const; void setInteractive(bool); + bool isMoving() const; + bool isFlicking() const; + int count() const; QDeclarativeComponent *delegate() const; @@ -151,9 +157,15 @@ Q_SIGNALS: void pathItemCountChanged(); void flickDecelerationChanged(); void interactiveChanged(); + void movingChanged(); + void flickingChanged(); void highlightChanged(); void highlightItemChanged(); void highlightMoveDurationChanged(); + void movementStarted(); + void movementEnded(); + void flickStarted(); + void flickEnded(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -167,6 +179,7 @@ protected: private Q_SLOTS: void refill(); void ticked(); + void movementEnding(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int,int,int); diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index a0d2610..9abec2e 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -78,6 +78,7 @@ public: , lastElapsed(0), mappedRange(1.0) , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) , autoHighlight(true), highlightUp(false), layoutScheduled(false) + , moving(false), flicking(false) , dragMargin(0), deceleration(100) , moveOffset(this, &QDeclarativePathViewPrivate::setOffset) , firstIndex(-1), pathItems(-1), requestedIndex(-1) @@ -90,15 +91,7 @@ public: { } - void init() { - Q_Q(QDeclarativePathView); - offset = 0; - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFiltersChildEvents(true); - q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); - lastPosTime.invalidate(); - } + void init(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { if ((newGeometry.size() != oldGeometry.size()) @@ -155,6 +148,8 @@ public: bool autoHighlight : 1; bool highlightUp : 1; bool layoutScheduled : 1; + bool moving : 1; + bool flicking : 1; QElapsedTimer lastPosTime; QPointF lastPos; qreal dragMargin; diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 2b268fb..68e7e9a 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -133,13 +133,13 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() create items as they are required. Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. - For example, it cannot be used to repeat QtObjects: + For example, it cannot be used to repeat QObjects: \badcode Item { - //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. + //XXX does not work! Can't repeat QObject as it doesn't derive from Item. Repeater { model: 10 - QtObject {} + QObject {} } } \endcode diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 34f5897..90f5a70 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -51,6 +51,8 @@ #include <QFontMetrics> #include <QPainter> +#ifndef QT_NO_LINEEDIT + QT_BEGIN_NAMESPACE /*! @@ -1537,3 +1539,5 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw) QT_END_NAMESPACE +#endif // QT_NO_LINEEDIT + diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index ba3f5b1..06f77e5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -48,6 +48,8 @@ #include <QGraphicsSceneMouseEvent> #include <QIntValidator> +#ifndef QT_NO_LINEEDIT + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -263,4 +265,6 @@ QML_DECLARE_TYPE(QRegExpValidator) QT_END_HEADER +#endif // QT_NO_LINEEDIT + #endif // QDECLARATIVETEXTINPUT_H diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 4ac5134..5ad6a3b 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -62,6 +62,8 @@ // // We mean it. +#ifndef QT_NO_LINEEDIT + QT_BEGIN_NAMESPACE class QDeclarativeTextInputPrivate : public QDeclarativePaintedItemPrivate @@ -132,5 +134,7 @@ public: QT_END_NAMESPACE +#endif // QT_NO_LINEEDIT + #endif diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index 16a1127..0bae0cd 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -90,7 +90,7 @@ void QDeclarativeTranslate::setX(qreal x) return; d->x = x; update(); - emit positionChanged(); + emit xChanged(); } /*! @@ -113,7 +113,7 @@ void QDeclarativeTranslate::setY(qreal y) return; d->y = y; update(); - emit positionChanged(); + emit yChanged(); } /*! @@ -125,12 +125,4 @@ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const matrix->translate(d->x, d->y, 0); } -/*! - \fn QDeclarativeTranslate::positionChanged() - - QDeclarativeTranslate emits this signal when its position changes. - - \sa QDeclarativeTranslate::x, QDeclarativeTranslate::y -*/ - QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h index 0207dce..b871518 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h +++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h @@ -56,8 +56,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeTranslate : public QGraphicsTransform { Q_OBJECT - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY positionChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY positionChanged) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) public: QDeclarativeTranslate(QObject *parent = 0); @@ -72,7 +72,8 @@ public: void applyTo(QMatrix4x4 *matrix) const; Q_SIGNALS: - void positionChanged(); + void xChanged(); + void yChanged(); private: Q_DECLARE_PRIVATE(QDeclarativeTranslate) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 7952b97..a489b5a 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -78,7 +78,7 @@ public: static void children_append(QDeclarativeListProperty<QDeclarativeItem> *prop, QDeclarativeItem *item) { QDeclarative_setParent_noEvent(item, prop->object); - static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.append(item); + static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.append(Item(item)); static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->itemAppended(); static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged(); } @@ -88,12 +88,12 @@ public: } static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index) { - return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index); + return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index).item; } void itemAppended() { Q_Q(QDeclarativeVisualItemModel); - QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last()); + QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last().item); attached->setIndex(children.count()-1); emit q->itemsInserted(children.count()-1, 1); emit q->countChanged(); @@ -104,7 +104,25 @@ public: emit q->childrenChanged(); } - QList<QDeclarativeItem *> children; + int indexOf(QDeclarativeItem *item) const { + for (int i = 0; i < children.count(); ++i) + if (children.at(i).item == item) + return i; + return -1; + } + + class Item { + public: + Item(QDeclarativeItem *i) : item(i), ref(0) {} + + void addRef() { ++ref; } + bool deref() { return --ref == 0; } + + QDeclarativeItem *item; + int ref; + }; + + QList<Item> children; }; @@ -182,14 +200,22 @@ bool QDeclarativeVisualItemModel::isValid() const QDeclarativeItem *QDeclarativeVisualItemModel::item(int index, bool) { Q_D(QDeclarativeVisualItemModel); - return d->children.at(index); + QDeclarativeVisualItemModelPrivate::Item &item = d->children[index]; + item.addRef(); + return item.item; } QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDeclarativeItem *item) { - if (item->scene()) - item->scene()->removeItem(item); - QDeclarative_setParent_noEvent(item, this); + Q_D(QDeclarativeVisualItemModel); + int idx = d->indexOf(item); + if (idx >= 0) { + if (d->children[idx].deref()) { + if (item->scene()) + item->scene()->removeItem(item); + QDeclarative_setParent_noEvent(item, this); + } + } return 0; } @@ -208,7 +234,7 @@ QString QDeclarativeVisualItemModel::stringValue(int index, const QString &name) Q_D(QDeclarativeVisualItemModel); if (index < 0 || index >= d->children.count()) return QString(); - return QDeclarativeEngine::contextForObject(d->children.at(index))->contextProperty(name).toString(); + return QDeclarativeEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString(); } QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext) @@ -218,7 +244,7 @@ QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &express return QVariant(); QDeclarativeContext *ccontext = qmlContext(this); QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); - ctxt->setContextObject(d->children.at(index)); + ctxt->setContextObject(d->children.at(index).item); QDeclarativeExpression e(ctxt, objectContext, expression); QVariant value = e.evaluate(); delete ctxt; @@ -228,7 +254,7 @@ QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &express int QDeclarativeVisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const { Q_D(const QDeclarativeVisualItemModel); - return d->children.indexOf(item); + return d->indexOf(item); } QDeclarativeVisualItemModelAttached *QDeclarativeVisualItemModel::qmlAttachedProperties(QObject *obj) @@ -418,6 +444,9 @@ public: int propForRole(int) const; void setValue(int, const QVariant &); + bool hasValue(int id) const { + return m_meta->hasValue(id); + } void ensureProperties(); @@ -496,7 +525,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) QVariant value = model->m_listModelInterface->data(data->m_index, *it); return value; } else if (model->m_roles.count() == 1 && propName == "modelData") { - //for compatability with other lists, assign modelData if there is only a single role + //for compatibility with other lists, assign modelData if there is only a single role QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first()); return value; } @@ -1190,11 +1219,13 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, int role = roles.at(roleIdx); int propId = data->propForRole(role); if (propId != -1) { - if (d->m_listModelInterface) { - data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role)); - } else if (d->m_abstractItemModel) { - QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root); - data->setValue(propId, d->m_abstractItemModel->data(index, role)); + if (data->hasValue(propId)) { + if (d->m_listModelInterface) { + data->setValue(propId, d->m_listModelInterface->data(idx, QList<int>() << role).value(role)); + } else if (d->m_abstractItemModel) { + QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root); + data->setValue(propId, d->m_abstractItemModel->data(index, role)); + } } } else { QString roleName; diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 507e47b..723da94 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -1628,7 +1628,7 @@ void QDeclarativeBindingCompiler::dump(const QByteArray &programData) /*! Clear the state associated with attempting to compile a specific binding. -This does not clear the global "commited binding" states. +This does not clear the global "committed binding" states. */ void QDeclarativeBindingCompilerPrivate::resetInstanceState() { diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index febcdef..2b4a4a5 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1070,6 +1070,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj) store.storeSignal.value = output->indexForString(v->value.asScript().trimmed()); store.storeSignal.context = ctxt.stack; + store.storeSignal.name = output->indexForByteArray(prop->name); output->bytecode << store; } @@ -2214,10 +2215,11 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) if (propNames.contains(prop.name)) COMPILE_EXCEPTION(&prop, tr("Duplicate property name")); - if (QString::fromUtf8(prop.name).at(0).isUpper()) + QString propName = QString::fromUtf8(prop.name); + if (propName.at(0).isUpper()) COMPILE_EXCEPTION(&prop, tr("Property names cannot begin with an upper case letter")); - if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(prop.name)) + if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(propName)) COMPILE_EXCEPTION(&prop, tr("Illegal property name")); propNames.insert(prop.name); @@ -2227,9 +2229,10 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) QByteArray name = obj->dynamicSignals.at(ii).name; if (methodNames.contains(name)) COMPILE_EXCEPTION(obj, tr("Duplicate signal name")); - if (QString::fromUtf8(name).at(0).isUpper()) + QString nameStr = QString::fromUtf8(name); + if (nameStr.at(0).isUpper()) COMPILE_EXCEPTION(obj, tr("Signal names cannot begin with an upper case letter")); - if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name)) + if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(nameStr)) COMPILE_EXCEPTION(obj, tr("Illegal signal name")); methodNames.insert(name); } @@ -2237,9 +2240,10 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj) QByteArray name = obj->dynamicSlots.at(ii).name; if (methodNames.contains(name)) COMPILE_EXCEPTION(obj, tr("Duplicate method name")); - if (QString::fromUtf8(name).at(0).isUpper()) + QString nameStr = QString::fromUtf8(name); + if (nameStr.at(0).isUpper()) COMPILE_EXCEPTION(obj, tr("Method names cannot begin with an upper case letter")); - if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name)) + if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(nameStr)) COMPILE_EXCEPTION(obj, tr("Illegal method name")); methodNames.insert(name); } @@ -2765,6 +2769,7 @@ bool QDeclarativeCompiler::completeComponentBuild() bool isSharable = sharableTest.isSharable(expression); QDeclarativeRewrite::RewriteBinding rewriteBinding; + rewriteBinding.setName('$'+binding.property->name); expression = rewriteBinding(expression); quint32 length = expression.length(); diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 7bc6184..5f4a063 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -115,26 +115,10 @@ class QByteArray; a small component within a QML file, or for defining a component that logically belongs with other QML components within a file. - For example, here is a component that is used by multiple \l Loader objects: + For example, here is a component that is used by multiple \l Loader objects. + It contains a top level \l Rectangle item: - \qml - Item { - width: 100; height: 100 - - Component { - id: redSquare - - Rectangle { - color: "red" - width: 10 - height: 10 - } - } - - Loader { sourceComponent: redSquare } - Loader { sourceComponent: redSquare; x: 20 } - } - \endqml + \snippet doc/src/snippets/declarative/component.qml 0 Notice that while a \l Rectangle by itself would be automatically rendered and displayed, this is not the case for the above rectangle @@ -143,12 +127,16 @@ class QByteArray; file, and is not loaded until requested (in this case, by the two \l Loader objects). + A Component cannot contain anything other + than an \c id and a single top level item. While the \c id is optional, + the top level item is not; you cannot define an empty component. + The Component element is commonly used to provide graphical components for views. For example, the ListView::delegate property requires a Component to specify how each list item is to be displayed. - Component objects can also be dynamically generated using - \l{Qt::createComponent()}{Qt.createComponent()}. + Component objects can also be dynamically created using + \l{QML:Qt::createComponent()}{Qt.createComponent()}. */ /*! @@ -204,7 +192,7 @@ class QByteArray; \value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content. \value Ready This QDeclarativeComponent is ready and create() may be called. \value Loading This QDeclarativeComponent is loading network data. - \value Error An error has occured. Call errors() to retrieve a list of \{QDeclarativeError}{errors}. + \value Error An error has occurred. Call errors() to retrieve a list of \{QDeclarativeError}{errors}. */ void QDeclarativeComponentPrivate::typeDataReady() @@ -530,7 +518,7 @@ void QDeclarativeComponent::loadUrl(const QUrl &url) } /*! - Return the list of errors that occured during the last compile or create + Return the list of errors that occurred during the last compile or create operation. An empty list is returned if isError() is not set. */ QList<QDeclarativeError> QDeclarativeComponent::errors() const @@ -609,6 +597,9 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q the \a parent value. Note that if the returned object is to be displayed, you must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent} property, or else the object will not be visible. + + Dynamically created instances can be deleted with the \c destroy() method. + See \l {Dynamic Object Management} for more information. */ /*! diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 3d25291..a58dc6c 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -80,10 +80,12 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() \code QDeclarativeEngine engine; + QStringListModel modelData; QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextProperty("myModel", modelData); + context->setContextProperty("myModel", &modelData); - QDeclarativeComponent component(&engine, "ListView { model=myModel }"); + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.7\nListView { model: myModel }", QUrl()); component.create(context); \endcode @@ -104,12 +106,13 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() ... }; - MyDataSet *myDataSet = new MyDataSet; + MyDataSet myDataSet; QDeclarativeEngine engine; QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextObject(myDataSet); + context->setContextObject(&myDataSet); - QDeclarativeComponent component(&engine, "ListView { model=myModel }"); + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.7\nListView { model: myModel }", QUrl()); component.create(context); \endcode diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index a5b5fcc..3fe89a5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -184,11 +184,12 @@ void QDeclarativeEnginePrivate::defineModule() } /*! -\keyword QmlGlobalQtObject -\qmlclass Qt QDeclarativeEnginePrivate +\qmlclass QML:Qt QDeclarativeEnginePrivate \brief The QML global Qt object provides useful enums and functions from Qt. -The \c Qt object provides useful enums and functions from Qt, for use in all QML files. +\keyword QmlGlobalQtObject + +\brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files. The \c Qt object is not a QML element; it cannot be instantiated. It is a global object with enums and functions. To use it, call the members of the global \c Qt object directly. @@ -206,10 +207,9 @@ Text { \section1 Enums -The Qt object contains all enums in the Qt namespace. For example, you can -access the \c AlignLeft member of the \c Qt::AlignmentFlag enum with \c Qt.AlignLeft. +The Qt object contains enums that declared into Qt's Meta-Object System. For example, you can access +the \c Leftbutton member of the \c Qt::MouseButton enum with \c Qt.LeftButton. -For a full list of enums, see the \l{Qt Namespace} documentation. \section1 Types The Qt object also contains helper functions for creating objects of specific @@ -301,7 +301,9 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr + QDir::separator() + QLatin1String("OfflineStorage"); #endif +#ifndef QT_NO_XMLSTREAMREADER qt_add_qmlxmlhttprequest(this); +#endif qt_add_qmlsqldatabase(this); // XXX A Multimedia "Qt.Sound" class also needs to be made available, // XXX but we don't want a dependency in that cirection. @@ -1104,29 +1106,20 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url) \qmlmethod object Qt::createComponent(url) Returns a \l Component object created using the QML file at the specified \a url, -or \c null if there was an error in creating the component. +or \c null if an empty string was given. + +The returned component's \l Component::status property indicates whether the +component was successfully created. If the status is \c Component.Error, +see \l Component::errorString() for an error description. Call \l {Component::createObject()}{Component.createObject()} on the returned component to create an object instance of the component. -Here is an example. Notice it checks whether the component \l{Component::status}{status} is -\c Component.Ready before calling \l {Component::createObject()}{createObject()} -in case the QML file is loaded over a network and thus is not ready immediately. - -\snippet doc/src/snippets/declarative/componentCreation.js vars -\codeline -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js remote -\snippet doc/src/snippets/declarative/componentCreation.js func-end -\codeline -\snippet doc/src/snippets/declarative/componentCreation.js finishCreation +For example: -If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() -function and call \l {Component::createObject()}{createObject()} immediately: +\snippet doc/src/snippets/declarative/createComponent-simple.qml 0 -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js local -\snippet doc/src/snippets/declarative/componentCreation.js func-end +See \l {Dynamic Object Management} for more information on using this function. To create a QML object from an arbitrary string of QML (instead of a file), use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}. @@ -1177,6 +1170,8 @@ Each object in this array has the members \c lineNumber, \c columnNumber, \c fil Note that this function returns immediately, and therefore may not work if the \a qml string loads new components (that is, external QML files that have not yet been loaded). If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead. + +See \l {Dynamic Object Management} for more information on using this function. */ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp index 8717f56..0ab5cd9 100644 --- a/src/declarative/qml/qdeclarativeerror.cpp +++ b/src/declarative/qml/qdeclarativeerror.cpp @@ -250,7 +250,9 @@ QDebug operator<<(QDebug debug, const QDeclarativeError &error) if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); QTextStream stream(data, QIODevice::ReadOnly); +#ifndef QT_NO_TEXTCODEC stream.setCodec("UTF-8"); +#endif const QString code = stream.readAll(); const QStringList lines = code.split(QLatin1Char('\n')); diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 9935e38..6fc4df0 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -143,16 +143,12 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *ex } else { -#if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work? if (!dd->cachedPrograms.at(progIdx)) { dd->cachedPrograms[progIdx] = new QScriptProgram(expression, url, line); } expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx), &expressionContext); -#else - expressionFunction = evalInObjectScope(ctxt, me, expression, &expressionContext); -#endif expressionFunctionMode = ExplicitContext; expressionFunctionValid = true; @@ -604,6 +600,7 @@ QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, scriptContext->pushScope(ep->globalClass->staticGlobalObject()); QDeclarativeRewrite::RewriteBinding rewriteBinding; + rewriteBinding.setName(name); bool ok = true; const QString code = rewriteBinding(expression, &ok); if (ok) diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index b629e20..1700335 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -194,6 +194,7 @@ public: QString url; // This is a QString for a reason. QUrls are slooooooow... int line; + QByteArray name; //function name, hint for the debugger }; QDeclarativeQtScriptExpression::DeleteWatcher::DeleteWatcher(QDeclarativeQtScriptExpression *data) diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp index 448fde2..9b5eb61 100644 --- a/src/declarative/qml/qdeclarativeextensionplugin.cpp +++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE \o Subclass QDeclarativeExtensionPlugin, implement registerTypes() method to register types using qmlRegisterType(), and export the class using the Q_EXPORT_PLUGIN2() macro \o Write an appropriate project file for the plugin - \o Create a \l{The qmldir file}{qmldir file} to describe the plugin + \o Create a \l{Writing a qmldir file}{qmldir file} to describe the plugin \endlist QML extension plugins can be used to provide either application-specific or @@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE \dots To make this class available as a QML type, create a plugin that registers - this type using qmlRegisterType(). For this example the plugin + this type with a specific \l {QML Modules}{module} using qmlRegisterType(). For this example the plugin module will be named \c com.nokia.TimeExample (as defined in the project file further below). @@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE ... \endcode - Finally, a \l{The qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory + Finally, a \l{Writing a qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory that describes the plugin. This directory includes a \c Clock.qml file that should be bundled with the plugin, so it needs to be specified in the \c qmldir file: diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index 241df87..ea68327 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -59,13 +59,13 @@ public: \list \o Loaded using QPixmaps rather than actual image files - \o Loaded asynchronously in a separate thread, if imageType() is \l ImageType::Image + \o Loaded asynchronously in a separate thread, if imageType() is \l{QDeclarativeImageProvider::ImageType}{ImageType::Image} \endlist To specify that an image should be loaded by an image provider, use the \bold {"image:"} scheme for the URL source of the image, followed by the identifiers of the image provider and the requested image. For example: - + \qml Image { source: "image://myimageprovider/image.png" } \endqml @@ -83,7 +83,7 @@ public: and "red", respectively: \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0 - + When these images are loaded by QML, it looks for a matching image provider and calls its requestImage() or requestPixmap() method (depending on its imageType()) to load the image. The method is called with the \c id @@ -112,7 +112,7 @@ public: } \endcode - Now the images can be succesfully loaded in QML: + Now the images can be successfully loaded in QML: \image imageprovider.png @@ -136,7 +136,7 @@ public: main thread. In this case, if \l {Image::}{asynchronous} is set to \c true, the value is ignored and the image is loaded synchronously. - + \sa QDeclarativeEngine::addImageProvider() */ diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp index c980a2a..c6560dd 100644 --- a/src/declarative/qml/qdeclarativeinfo.cpp +++ b/src/declarative/qml/qdeclarativeinfo.cpp @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE /*! \fn QDeclarativeInfo qmlInfo(const QObject *object) + \relates QDeclarativeEngine \brief Prints warnings messages that include the file and line number for QML types. diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp index 0f7b09d..1767d2f 100644 --- a/src/declarative/qml/qdeclarativeinstruction.cpp +++ b/src/declarative/qml/qdeclarativeinstruction.cpp @@ -218,7 +218,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) qWarning().nospace() << idx << "\t\t" << line << "\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount; break; default: - qWarning().nospace() << idx << "\t\t" << line << "\t" << "XXX UNKOWN INSTRUCTION" << "\t" << instr->type; + qWarning().nospace() << idx << "\t\t" << line << "\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instr->type; break; } #endif // QT_NO_DEBUG_STREAM diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h index d1a0a0a..f0b032c 100644 --- a/src/declarative/qml/qdeclarativeinstruction_p.h +++ b/src/declarative/qml/qdeclarativeinstruction_p.h @@ -292,7 +292,8 @@ public: struct StoreSignalInstruction { int signalIndex; int value; - int context; + short context; + int name; }; struct AssignSignalObjectInstruction { int signal; diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 399b2a1..c10bc11 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -98,16 +98,16 @@ public: private: static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList<T *> *)p->data)->append(v); + reinterpret_cast<QList<T *> *>(p->data)->append(v); } static int qlist_count(QDeclarativeListProperty *p) { - return ((QList<T *> *)p->data)->count(); + return reinterpret_cast<QList<T *> *>(p->data)->count(); } static T *qlist_at(QDeclarativeListProperty *p, int idx) { - return ((QList<T *> *)p->data)->at(idx); + return reinterpret_cast<QList<T *> *>(p->data)->at(idx); } static void qlist_clear(QDeclarativeListProperty *p) { - return ((QList<T *> *)p->data)->clear(); + return reinterpret_cast<QList<T *> *>(p->data)->clear(); } }; #endif diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index b2d7451..d45ddbc 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -105,7 +105,7 @@ namespace QDeclarativePrivate template<class From, class To> struct StaticCastSelectorClass<From, To, sizeof(int)> { - static inline int cast() { return (int)((intptr_t)static_cast<To *>((From *)0x10000000)) - 0x10000000; } + static inline int cast() { return int(reinterpret_cast<intptr_t>(static_cast<To *>(reinterpret_cast<From *>(0x10000000)))) - 0x10000000; } }; template<class From, class To> @@ -119,7 +119,7 @@ namespace QDeclarativePrivate static inline int cast() { - return StaticCastSelectorClass<From, To, sizeof(check((From *)0))>::cast(); + return StaticCastSelectorClass<From, To, sizeof(check(reinterpret_cast<From *>(0)))>::cast(); } }; @@ -132,6 +132,7 @@ namespace QDeclarativePrivate template <typename T, bool hasMember> class has_attachedPropertiesMethod { + public: typedef int yes_type; typedef char no_type; @@ -139,7 +140,6 @@ namespace QDeclarativePrivate static yes_type check(ReturnType *(*)(QObject *)); static no_type check(...); - public: static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type); }; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 071dd07..515c4d6 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -640,7 +640,7 @@ QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that) is assumed by the caller. \a flags is passed through to the binding and is used for the initial update (when - the binding sets the intial value, it will use these flags for the write). + the binding sets the initial value, it will use these flags for the write). */ QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::setBinding(const QDeclarativeProperty &that, diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp index 3d40e77..bc9a114 100644 --- a/src/declarative/qml/qdeclarativerewrite.cpp +++ b/src/declarative/qml/qdeclarativerewrite.cpp @@ -102,7 +102,7 @@ QString RewriteBinding::rewrite(QString code, unsigned position, unsigned startOfStatement = node->firstSourceLocation().begin() - _position; unsigned endOfStatement = node->lastSourceLocation().end() - _position; - _writer->replace(startOfStatement, 0, QLatin1String("(function() { ")); + _writer->replace(startOfStatement, 0, QLatin1String("(function ") + QString::fromUtf8(_name) + QLatin1String("() { ")); _writer->replace(endOfStatement, 0, QLatin1String(" })")); if (rewriteDump()) { diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h index 33b168c..6f3c46e 100644 --- a/src/declarative/qml/qdeclarativerewrite_p.h +++ b/src/declarative/qml/qdeclarativerewrite_p.h @@ -78,10 +78,14 @@ class RewriteBinding: protected AST::Visitor { unsigned _position; TextWriter *_writer; + QByteArray _name; public: QString operator()(const QString &code, bool *ok = 0); + //name of the function: used for the debugger + void setName(const QByteArray &name) { _name = name; } + protected: using AST::Visitor::visit; diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp index 4d98ca8..0657f49 100644 --- a/src/declarative/qml/qdeclarativescriptparser.cpp +++ b/src/declarative/qml/qdeclarativescriptparser.cpp @@ -760,7 +760,7 @@ bool ProcessAST::visit(AST::UiArrayBinding *node) prop->listValueRange.offset = node->lbracketToken.offset; prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset; - // Store the positions of the comma token too, again for the DOM to be able to retreive it. + // Store the positions of the comma token too, again for the DOM to be able to retrieve it. prop->listCommaPositions = collectCommas(node->members); while (propertyCount--) @@ -831,7 +831,9 @@ bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url) _scriptFile = fileName; QTextStream stream(qmldata, QIODevice::ReadOnly); +#ifndef QT_NO_TEXTCODEC stream.setCodec("UTF-8"); +#endif const QString code = stream.readAll(); data = new QDeclarativeScriptParserJsASTData(fileName); diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 3247f85..4e41c22 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -621,14 +621,15 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, case QDeclarativeInstruction::StoreSignal: { QObject *target = stack.top(); - QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context); - + QObject *context = stack.at(stack.count() - 1 - instr.storeSignal.context); + QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex); QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target); QDeclarativeExpression *expr = new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value)); expr->setSourceLocation(comp->name, instr.line); + static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = datas.at(instr.storeSignal.name); bs->setExpression(expr); } break; diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index ff3b13b..8c97e29 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -58,6 +58,8 @@ #include <QtCore/qstack.h> #include <QtCore/qdebug.h> +#ifndef QT_NO_XMLSTREAMREADER + // From DOM-Level-3-Core spec // http://www.w3.org/TR/DOM-Level-3-Core/core.html #define INDEX_SIZE_ERR 1 @@ -1304,10 +1306,11 @@ QString QDeclarativeXMLHttpRequest::responseBody() const { QXmlStreamReader reader(m_responseEntityBody); reader.readNext(); +#ifndef QT_NO_TEXTCODEC QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8()); if (codec) return codec->toUnicode(m_responseEntityBody); - +#endif return QString::fromUtf8(m_responseEntityBody); } @@ -1662,4 +1665,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine) QT_END_NAMESPACE +#endif // QT_NO_XMLSTREAMREADER + #include <qdeclarativexmlhttprequest.moc> diff --git a/src/declarative/qml/qdeclarativexmlhttprequest_p.h b/src/declarative/qml/qdeclarativexmlhttprequest_p.h index 068cd0f..f340c1c 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest_p.h +++ b/src/declarative/qml/qdeclarativexmlhttprequest_p.h @@ -56,6 +56,8 @@ #include <QtCore/qglobal.h> +#ifndef QT_NO_XMLSTREAMREADER + QT_BEGIN_NAMESPACE class QScriptEngine; @@ -63,5 +65,7 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine); QT_END_NAMESPACE +#endif // QT_NO_XMLSTREAMREADER + #endif // QDECLARATIVEXMLHTTPREQUEST_P_H diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 9806957..a747706 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -645,12 +645,13 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation() Like any other animation element, a ColorAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. - When used in a transition, ColorAnimation will by default animate - all properties of type color that have changed. If a \l{PropertyAnimation::}{property} - or \l{PropertyAnimation::}{properties} are explicitly set for the animation, + For convenience, when a ColorAnimation is used in a \l Transition, it will + animate any \c color properties that have been modified during the state + change. If a \l{PropertyAnimation::}{property} or + \l{PropertyAnimation::}{properties} are explicitly set for the animation, then those are used instead. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} @@ -939,7 +940,7 @@ void QDeclarativePropertyAction::setTarget(QObject *o) if (d->target == o) return; d->target = o; - emit targetChanged(d->target, d->propertyName); + emit targetChanged(); } QString QDeclarativePropertyAction::property() const @@ -954,7 +955,7 @@ void QDeclarativePropertyAction::setProperty(const QString &n) if (d->propertyName == n) return; d->propertyName = n; - emit targetChanged(d->target, d->propertyName); + emit propertyChanged(); } /*! @@ -1143,7 +1144,7 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions, Like any other animation element, a NumberAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. Note that NumberAnimation may not animate smoothly if there are irregular @@ -1244,6 +1245,11 @@ void QDeclarativeNumberAnimation::setTo(qreal t) Vector3dAnimation is a specialized PropertyAnimation that defines an animation to be applied when a Vector3d value changes. + Like any other animation element, a Vector3dAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation} documentation shows a variety of methods + for creating animations. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1323,7 +1329,7 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t) \snippet doc/src/snippets/declarative/rotationanimation.qml 0 - Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target} + Notice the RotationAnimation did not need to set a \l target value. As a convenience, when used in a transition, RotationAnimation will rotate all properties named "rotation" or "angle". You can override this by providing your own properties via \l {PropertyAnimation::properties}{properties} or @@ -1331,7 +1337,7 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t) Like any other animation element, a RotationAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} @@ -1554,7 +1560,7 @@ QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGro Like any other animation element, a SequentialAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. \note Once an animation has been grouped into a SequentialAnimation or @@ -1623,7 +1629,7 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio Like any other animation element, a ParallelAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. \note Once an animation has been grouped into a SequentialAnimation or @@ -1937,15 +1943,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \o \inlineimage qeasingcurve-inquart.png \row \o \c Easing.OutQuart - \o Easing curve for a cubic (t^4) function: decelerating from zero velocity. + \o Easing curve for a quartic (t^4) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquart.png \row \o \c Easing.InOutQuart - \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration. + \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquart.png \row \o \c Easing.OutInQuart - \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration. + \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquart.png \row \o \c Easing.InQuint @@ -1953,15 +1959,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \o \inlineimage qeasingcurve-inquint.png \row \o \c Easing.OutQuint - \o Easing curve for a cubic (t^5) function: decelerating from zero velocity. + \o Easing curve for a quintic (t^5) function: decelerating from zero velocity. \o \inlineimage qeasingcurve-outquint.png \row \o \c Easing.InOutQuint - \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration. + \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration. \o \inlineimage qeasingcurve-inoutquint.png \row \o \c Easing.OutInQuint - \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration. + \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinquint.png \row \o \c Easing.InSine @@ -2104,7 +2110,7 @@ void QDeclarativePropertyAnimation::setTarget(QObject *o) if (d->target == o) return; d->target = o; - emit targetChanged(d->target, d->propertyName); + emit targetChanged(); } QString QDeclarativePropertyAnimation::property() const @@ -2119,7 +2125,7 @@ void QDeclarativePropertyAnimation::setProperty(const QString &n) if (d->propertyName == n) return; d->propertyName = n; - emit targetChanged(d->target, d->propertyName); + emit propertyChanged(); } QString QDeclarativePropertyAnimation::properties() const @@ -2396,8 +2402,7 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions \inherits Animation \brief The ParentAnimation element animates changes in parent values. - ParentAnimation defines an animation to applied when a ParentChange - occurs. This allows parent changes to be smoothly animated. + ParentAnimation is used to animate a parent change for an \l Item. For example, the following ParentChange changes \c blueRect to become a child of \c redRect when it is clicked. The inclusion of the @@ -2415,10 +2420,16 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions to animate the parent change via another item that does not have clipping enabled. Such an item can be set using the \l via property. - By default, when used in a transition, ParentAnimation animates all parent - changes. This can be overriden by setting a specific target item using the + For convenience, when a ParentAnimation is used in a \l Transition, it will + animate any ParentChange that has occurred during the state change. + This can be overridden by setting a specific target item using the \l target property. + Like any other animation element, a ParentAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation} documentation shows a variety of methods + for creating animations. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -2750,14 +2761,23 @@ QAbstractAnimation *QDeclarativeParentAnimation::qtAnimation() \inherits Animation \brief The AnchorAnimation element animates changes in anchor values. - AnchorAnimation is used to animate an AnchorChange. It will anchor all - anchor changes specified in a \l State. + AnchorAnimation is used to animate an anchor change. In the following snippet we animate the addition of a right anchor to a \l Rectangle: \snippet doc/src/snippets/declarative/anchoranimation.qml 0 - \sa AnchorChanges + For convenience, when an AnchorAnimation is used in a \l Transition, it will + animate any AnchorChanges that have occurred during the state change. + This can be overridden by setting a specific target item using the + \l target property. + + Like any other animation element, an AnchorAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation} documentation shows a variety of methods + for creating animations. + + \sa {QML Animation}, AnchorChanges */ QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent) diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 28b0a6f..a1bb64f 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -197,7 +197,7 @@ class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation Q_DECLARE_PRIVATE(QDeclarativePropertyAction) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets) Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude) @@ -225,7 +225,8 @@ public: Q_SIGNALS: void valueChanged(const QVariant &); void propertiesChanged(const QString &); - void targetChanged(QObject *, const QString &); + void targetChanged(); + void propertyChanged(); protected: virtual void transition(QDeclarativeStateActions &actions, @@ -246,7 +247,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstr Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets) Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude) @@ -292,7 +293,8 @@ Q_SIGNALS: void toChanged(QVariant); void easingChanged(const QEasingCurve &); void propertiesChanged(const QString &); - void targetChanged(QObject *, const QString &); + void targetChanged(); + void propertyChanged(); }; class Q_AUTOTEST_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index fadb2ae..1e7f81a 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -84,12 +84,15 @@ public: \snippet doc/src/snippets/declarative/behavior.qml 0 - To run multiple animations within a Behavior, use ParallelAnimation or + Note that a property cannot have more than one assigned Behavior. To provide + multiple animations within a Behavior, use ParallelAnimation or SequentialAnimation. - Note that a property cannot have more than one assigned Behavior. + If a \l{QML States}{state change} has a \l Transition that matches the same property as a + Behavior, the \l Transition animation overrides the Behavior for that + state change. - \sa {Property Behaviors}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative + \sa {QML Animation}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative */ diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 6b969e3..3a6a5b0 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -108,9 +108,9 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM \snippet doc/src/snippets/declarative/listmodel-modify.qml delegate - When creating content dynamically, note that the set of available properties cannot be changed - except by first clearing the model. Whatever properties are first added to the model are then the - only permitted properties in the model until it is cleared. + Note that when creating content dynamically the set of available properties cannot be changed + once set. Whatever properties are first added to the model are the + only permitted properties in the model. \section2 Using threaded list models with WorkerScript @@ -283,8 +283,7 @@ int QDeclarativeListModel::count() const /*! \qmlmethod ListModel::clear() - Deletes all content from the model. The properties are cleared such that - different properties may be set on subsequent additions. + Deletes all content from the model. \sa append() remove() */ @@ -945,13 +944,14 @@ bool FlatListModel::addValue(const QScriptValue &value, QHash<int, QVariant> *ro } NestedListModel::NestedListModel(QDeclarativeListModel *base) - : _root(0), m_listModel(base), _rolesOk(false) + : _root(0), m_ownsRoot(false), m_listModel(base), _rolesOk(false) { } NestedListModel::~NestedListModel() { - delete _root; + if (m_ownsRoot) + delete _root; } QVariant NestedListModel::valueForNode(ModelNode *node, bool *hasNested) const @@ -1051,8 +1051,8 @@ void NestedListModel::clear() _rolesOk = false; roleStrings.clear(); - delete _root; - _root = 0; + if (_root) + _root->clear(); } void NestedListModel::remove(int index) @@ -1067,8 +1067,10 @@ void NestedListModel::remove(int index) bool NestedListModel::insert(int index, const QScriptValue& valuemap) { - if (!_root) + if (!_root) { _root = new ModelNode; + m_ownsRoot = true; + } ModelNode *mn = new ModelNode; mn->setObjectValue(valuemap); @@ -1099,8 +1101,10 @@ void NestedListModel::move(int from, int to, int n) bool NestedListModel::append(const QScriptValue& valuemap) { - if (!_root) + if (!_root) { _root = new ModelNode; + m_ownsRoot = true; + } ModelNode *mn = new ModelNode; mn->setObjectValue(valuemap); _root->values << QVariant::fromValue(mn); @@ -1205,16 +1209,22 @@ ModelNode::ModelNode() ModelNode::~ModelNode() { - qDeleteAll(properties.values()); + clear(); + if (modelCache) { modelCache->m_nested->_root = 0/* ==this */; delete modelCache; modelCache = 0; } + if (objectCache) { delete objectCache; objectCache = 0; } +} +void ModelNode::clear() +{ ModelNode *node; for (int ii = 0; ii < values.count(); ++ii) { node = qvariant_cast<ModelNode *>(values.at(ii)); if (node) { delete node; node = 0; } } + values.clear(); - if (modelCache) { modelCache->m_nested->_root = 0/* ==this */; delete modelCache; modelCache = 0; } - if (objectCache) { delete objectCache; objectCache = 0; } + qDeleteAll(properties.values()); + properties.clear(); } void ModelNode::setObjectValue(const QScriptValue& valuemap) { diff --git a/src/declarative/util/qdeclarativelistmodel_p_p.h b/src/declarative/util/qdeclarativelistmodel_p_p.h index 532eefa..8231414 100644 --- a/src/declarative/util/qdeclarativelistmodel_p_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p_p.h @@ -130,6 +130,7 @@ public: void checkRoles() const; ModelNode *_root; + bool m_ownsRoot; QDeclarativeListModel *m_listModel; private: @@ -157,6 +158,8 @@ struct ModelNode QList<QVariant> values; QHash<QString, ModelNode *> properties; + void clear(); + QDeclarativeListModel *model(const NestedListModel *model) { if (!modelCache) { modelCache = new QDeclarativeListModel; diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp index ba5d534..40485bd 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject.cpp +++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp @@ -161,6 +161,12 @@ public: prop.second = true; } + inline bool hasData(int idx) const { + if (idx >= data.count()) + return false; + return data[idx].second; + } + bool autoCreate; QDeclarativeOpenMetaObject *q; QAbstractDynamicMetaObject *parent; @@ -295,6 +301,12 @@ void QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant activate(d->object, id + d->type->d->signalOffset, 0); } +// returns true if this value has been initialized by a call to either value() or setValue() +bool QDeclarativeOpenMetaObject::hasValue(int id) const +{ + return d->hasData(id); +} + void QDeclarativeOpenMetaObject::setCached(bool c) { if (c == d->cacheProperties || !d->type->d->engine) diff --git a/src/declarative/util/qdeclarativeopenmetaobject_p.h b/src/declarative/util/qdeclarativeopenmetaobject_p.h index 9bb4c34..c18fa3d 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject_p.h +++ b/src/declarative/util/qdeclarativeopenmetaobject_p.h @@ -91,6 +91,7 @@ public: void setValue(int, const QVariant &); QVariant &operator[](const QByteArray &); QVariant &operator[](int); + bool hasValue(int) const; int count() const; QByteArray name(int) const; diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index a83cac8..de2de21 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -70,6 +70,16 @@ QT_BEGIN_NAMESPACE +// The cache limit describes the maximum "junk" in the cache. +// These are the same defaults as QPixmapCache +#if defined(Q_OS_SYMBIAN) +static int cache_limit = 1024 * 1024; // 1048 KB cache limit for symbian +#elif defined(Q_WS_QWS) || defined(Q_WS_WINCE) +static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded +#else +static int cache_limit = 10240 * 1024; // 10 MB cache limit for desktop +#endif + class QDeclarativePixmapReader; class QDeclarativePixmapData; class QDeclarativePixmapReply : public QObject @@ -515,6 +525,7 @@ void QDeclarativePixmapReader::cancel(QDeclarativePixmapReply *reply) mutex.lock(); if (reply->loading) { cancelled.append(reply); + reply->data = 0; // XXX if (threadObject) threadObject->processJobs(); } else { @@ -580,6 +591,8 @@ public: QHash<QDeclarativePixmapKey, QDeclarativePixmapData *> m_cache; private: + void shrinkCache(int remove); + QDeclarativePixmapData *m_unreferencedPixmaps; QDeclarativePixmapData *m_lastUnreferencedPixmap; @@ -613,7 +626,9 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data) m_unreferencedCost += data->cost(); - if (m_timerId == -1) + shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit + + if (m_timerId == -1 && m_unreferencedPixmaps) m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000); } @@ -636,11 +651,9 @@ void QDeclarativePixmapStore::referencePixmap(QDeclarativePixmapData *data) m_unreferencedCost -= data->cost(); } -void QDeclarativePixmapStore::timerEvent(QTimerEvent *) +void QDeclarativePixmapStore::shrinkCache(int remove) { - int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION; - - while (removalCost > 0 && m_lastUnreferencedPixmap) { + while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) { QDeclarativePixmapData *data = m_lastUnreferencedPixmap; Q_ASSERT(data->nextUnreferenced == 0); @@ -649,10 +662,17 @@ void QDeclarativePixmapStore::timerEvent(QTimerEvent *) data->prevUnreferencedPtr = 0; data->prevUnreferenced = 0; - removalCost -= data->cost(); + remove -= data->cost(); data->removeFromCache(); delete data; } +} + +void QDeclarativePixmapStore::timerEvent(QTimerEvent *) +{ + int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION; + + shrinkCache(removalCost); if (m_unreferencedPixmaps == 0) { killTimer(m_timerId); @@ -702,7 +722,7 @@ bool QDeclarativePixmapReply::event(QEvent *event) int QDeclarativePixmapData::cost() const { - return pixmap.width() * pixmap.height() * pixmap.depth(); + return (pixmap.width() * pixmap.height() * pixmap.depth()) / 8; } void QDeclarativePixmapData::addref() @@ -719,7 +739,6 @@ void QDeclarativePixmapData::release() if (refCount == 0) { if (reply) { - reply->data = 0; reply->reader->cancel(reply); reply = 0; } diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp index 919727f..6b43040 100644 --- a/src/declarative/util/qdeclarativepropertymap.cpp +++ b/src/declarative/util/qdeclarativepropertymap.cpp @@ -104,22 +104,25 @@ void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilde The following example shows how you might declare data in C++ and then access it in QML. - Setup in C++: + In the C++ file: \code - //create our data + // create our data QDeclarativePropertyMap ownerData; ownerData.insert("name", QVariant(QString("John Smith"))); ownerData.insert("phone", QVariant(QString("555-5555"))); - //expose it to the UI layer - QDeclarativeContext *ctxt = view->rootContext(); - ctxt->setProperty("owner", &data); + // expose it to the UI layer + QDeclarativeView view; + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("owner", &ownerData); + + view.setSource(QUrl::fromLocalFile("main.qml")); + view.show(); \endcode - Then, in QML: + Then, in \c main.qml: \code - Text { text: owner.name } - Text { text: owner.phone } + Text { text: owner.name + " " + owner.phone } \endcode The binding is dynamic - whenever a key's value is updated, anything bound to that diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 11c3d4b..30e1491 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -287,7 +287,7 @@ void QSmoothedAnimation::init() Like any other animation element, a SmoothedAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. \sa SpringAnimation, NumberAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} @@ -375,7 +375,7 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions \list \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction - \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, begining with a velocity of 0 + \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0 \o SmoothedAnimation.Sync - the property is immediately set to the target value \endlist */ diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp index 8ce4832..6f4ac51 100644 --- a/src/declarative/util/qdeclarativespringanimation.cpp +++ b/src/declarative/util/qdeclarativespringanimation.cpp @@ -54,36 +54,32 @@ QT_BEGIN_NAMESPACE - -class QDeclarativeSpringAnimationPrivate : public QDeclarativeAbstractAnimationPrivate +class QDeclarativeSpringAnimationPrivate : public QDeclarativePropertyAnimationPrivate { Q_DECLARE_PUBLIC(QDeclarativeSpringAnimation) public: - QDeclarativeSpringAnimationPrivate() - : currentValue(0), to(0), from(0), maxVelocity(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01) - , modulus(0.0), useMass(false), haveModulus(false), enabled(true) - , fromDefined(false), toDefined(false) - , mode(Track), clock(this) {} - - qreal currentValue; - qreal to; - qreal from; + + + struct SpringAnimation { + SpringAnimation() + : currentValue(0), to(0), velocity(0){} + qreal currentValue; + qreal to; + qreal velocity; + }; + QHash<QDeclarativeProperty, SpringAnimation> activeAnimations; + qreal maxVelocity; qreal velocityms; int lastTime; qreal mass; qreal spring; qreal damping; - qreal velocity; qreal epsilon; qreal modulus; bool useMass : 1; bool haveModulus : 1; - bool enabled : 1; - bool fromDefined : 1; - bool toDefined : 1; enum Mode { Track, @@ -92,38 +88,68 @@ public: }; Mode mode; - void tick(int); + QDeclarativeSpringAnimationPrivate() + : maxVelocity(0), velocityms(0), lastTime(0) + , mass(1.0), spring(0.), damping(0.), epsilon(0.01) + , modulus(0.0), useMass(false), haveModulus(false) + , mode(Track), clock(0) + { } + + void tick(int time); + bool animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed); void updateMode(); - QTickAnimationProxy<QDeclarativeSpringAnimationPrivate, &QDeclarativeSpringAnimationPrivate::tick> clock; + typedef QTickAnimationProxy<QDeclarativeSpringAnimationPrivate, &QDeclarativeSpringAnimationPrivate::tick> Clock; + Clock *clock; }; void QDeclarativeSpringAnimationPrivate::tick(int time) { if (mode == Track) { - clock.stop(); + clock->stop(); return; } - int elapsed = time - lastTime; if (!elapsed) return; - qreal srcVal = to; + + if (mode == Spring) { + if (elapsed < 16) // capped at 62fps. + return; + int count = elapsed / 16; + lastTime = time - (elapsed - count * 16); + } else { + lastTime = time; + } + + QMutableHashIterator<QDeclarativeProperty, SpringAnimation> it(activeAnimations); + while (it.hasNext()) { + it.next(); + if (animate(it.key(), it.value(), elapsed)) + it.remove(); + } + + if (activeAnimations.isEmpty()) + clock->stop(); +} + +bool QDeclarativeSpringAnimationPrivate::animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed) +{ + + qreal srcVal = animation.to; bool stop = false; if (haveModulus) { - currentValue = fmod(currentValue, modulus); + animation.currentValue = fmod(animation.currentValue, modulus); srcVal = fmod(srcVal, modulus); } if (mode == Spring) { - if (elapsed < 16) // capped at 62fps. - return; // Real men solve the spring DEs using RK4. // We'll do something much simpler which gives a result that looks fine. int count = elapsed / 16; for (int i = 0; i < count; ++i) { - qreal diff = srcVal - currentValue; + qreal diff = srcVal - animation.currentValue; if (haveModulus && qAbs(diff) > modulus / 2) { if (diff < 0) diff += modulus; @@ -131,32 +157,31 @@ void QDeclarativeSpringAnimationPrivate::tick(int time) diff -= modulus; } if (useMass) - velocity = velocity + (spring * diff - damping * velocity) / mass; + animation.velocity = animation.velocity + (spring * diff - damping * animation.velocity) / mass; else - velocity = velocity + spring * diff - damping * velocity; + animation.velocity = animation.velocity + spring * diff - damping * animation.velocity; if (maxVelocity > 0.) { // limit velocity - if (velocity > maxVelocity) - velocity = maxVelocity; - else if (velocity < -maxVelocity) - velocity = -maxVelocity; + if (animation.velocity > maxVelocity) + animation.velocity = maxVelocity; + else if (animation.velocity < -maxVelocity) + animation.velocity = -maxVelocity; } - currentValue += velocity * 16.0 / 1000.0; + animation.currentValue += animation.velocity * 16.0 / 1000.0; if (haveModulus) { - currentValue = fmod(currentValue, modulus); - if (currentValue < 0.0) - currentValue += modulus; + animation.currentValue = fmod(animation.currentValue, modulus); + if (animation.currentValue < 0.0) + animation.currentValue += modulus; } } - if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) { - velocity = 0.0; - currentValue = srcVal; + if (qAbs(animation.velocity) < epsilon && qAbs(srcVal - animation.currentValue) < epsilon) { + animation.velocity = 0.0; + animation.currentValue = srcVal; stop = true; } - lastTime = time - (elapsed - count * 16); } else { qreal moveBy = elapsed * velocityms; - qreal diff = srcVal - currentValue; + qreal diff = srcVal - animation.currentValue; if (haveModulus && qAbs(diff) > modulus / 2) { if (diff < 0) diff += modulus; @@ -164,33 +189,31 @@ void QDeclarativeSpringAnimationPrivate::tick(int time) diff -= modulus; } if (diff > 0) { - currentValue += moveBy; + animation.currentValue += moveBy; if (haveModulus) - currentValue = fmod(currentValue, modulus); - if (currentValue > to) { - currentValue = to; + animation.currentValue = fmod(animation.currentValue, modulus); + if (animation.currentValue > animation.to) { + animation.currentValue = animation.to; stop = true; } } else { - currentValue -= moveBy; - if (haveModulus && currentValue < 0.0) - currentValue = fmod(currentValue, modulus) + modulus; - if (currentValue < to) { - currentValue = to; + animation.currentValue -= moveBy; + if (haveModulus && animation.currentValue < 0.0) + animation.currentValue = fmod(animation.currentValue, modulus) + modulus; + if (animation.currentValue < animation.to) { + animation.currentValue = animation.to; stop = true; } } - lastTime = time; } - qreal old_to = to; + qreal old_to = animation.to; - QDeclarativePropertyPrivate::write(defaultProperty, currentValue, + QDeclarativePropertyPrivate::write(property, animation.currentValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - if (stop && old_to == to) // do not stop if we got restarted - clock.stop(); + return (stop && old_to == animation.to); // do not stop if we got restarted } void QDeclarativeSpringAnimationPrivate::updateMode() @@ -205,6 +228,7 @@ void QDeclarativeSpringAnimationPrivate::updateMode() /*! \qmlclass SpringAnimation QDeclarativeSpringAnimation + \inherits Animation \since 4.7 \brief The SpringAnimation element allows a property to track a value in a spring-like motion. @@ -223,86 +247,23 @@ void QDeclarativeSpringAnimationPrivate::updateMode() Like any other animation element, a SpringAnimation can be applied in a number of ways, including transitions, behaviors and property value - sources. The \l PropertyAnimation documentation shows a variety of methods + sources. The \l {QML Animation} documentation shows a variety of methods for creating animations. \sa SmoothedAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} */ QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent) -: QDeclarativeAbstractAnimation(*(new QDeclarativeSpringAnimationPrivate),parent) -{ -} - -QDeclarativeSpringAnimation::~QDeclarativeSpringAnimation() -{ -} - -void QDeclarativeSpringAnimation::setTarget(const QDeclarativeProperty &property) +: QDeclarativeNumberAnimation(*(new QDeclarativeSpringAnimationPrivate),parent) { Q_D(QDeclarativeSpringAnimation); - d->defaultProperty = property; - d->currentValue = property.read().toReal(); - if (!d->avoidPropertyValueSourceStart) { - setRunning(true); - } -} - -qreal QDeclarativeSpringAnimation::to() const -{ - Q_D(const QDeclarativeSpringAnimation); - return d->toDefined ? d->to : 0; -} - -/*! - \qmlproperty real SpringAnimation::to - - This property holds the value at which the animation will end. - - If not set, the animation will continue until it reaches the - value that is being tracked. -*/ - -void QDeclarativeSpringAnimation::setTo(qreal value) -{ - Q_D(QDeclarativeSpringAnimation); - if (d->to == value) - return; - - d->to = value; - d->toDefined = true; - d->lastTime = 0; - emit toChanged(value); + d->clock = new QDeclarativeSpringAnimationPrivate::Clock(d, this); } -qreal QDeclarativeSpringAnimation::from() const -{ - Q_D(const QDeclarativeSpringAnimation); - return d->fromDefined ? d->from : 0; -} - -/*! - \qmlproperty real SpringAnimation::from - - This property holds the value from which the animation will begin. - - If not set, the animation will start whenever the tracked value has - changed, regardless of its value. -*/ - -void QDeclarativeSpringAnimation::setFrom(qreal value) +QDeclarativeSpringAnimation::~QDeclarativeSpringAnimation() { - Q_D(QDeclarativeSpringAnimation); - if (d->from == value) - return; - - d->currentValue = d->from = value; - d->fromDefined = true; - d->lastTime = 0; - emit fromChanged(value); } - /*! \qmlproperty real SpringAnimation::velocity @@ -452,17 +413,25 @@ void QDeclarativeSpringAnimation::transition(QDeclarativeStateActions &actions, Q_D(QDeclarativeSpringAnimation); Q_UNUSED(direction); - if (d->clock.state() != QAbstractAnimation::Running) + if (d->clock->state() != QAbstractAnimation::Running) { d->lastTime = 0; + } - if (!actions.isEmpty()) { - for (int i = 0; i < actions.size(); ++i) { - if (!d->toDefined) - d->to = actions.at(i).toValue.toReal(); - if (!d->fromDefined) - d->currentValue = actions.at(i).fromValue.toReal(); - if (d->mode != QDeclarativeSpringAnimationPrivate::Track) - modified << d->defaultProperty; + QDeclarativeNumberAnimation::transition(actions, modified, direction); + + if (!d->actions) + return; + + if (!d->actions->isEmpty()) { + for (int i = 0; i < d->actions->size(); ++i) { + const QDeclarativeProperty &property = d->actions->at(i).property; + QDeclarativeSpringAnimationPrivate::SpringAnimation &animation + = d->activeAnimations[property]; + animation.to = d->actions->at(i).toValue.toReal(); + if (d->fromIsDefined) + animation.currentValue = d->actions->at(i).fromValue.toReal(); + else + animation.currentValue = property.read().toReal(); } } } @@ -471,7 +440,7 @@ void QDeclarativeSpringAnimation::transition(QDeclarativeStateActions &actions, QAbstractAnimation *QDeclarativeSpringAnimation::qtAnimation() { Q_D(QDeclarativeSpringAnimation); - return &d->clock; + return d->clock; } QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativespringanimation_p.h b/src/declarative/util/qdeclarativespringanimation_p.h index 6f574ef..ee276ec 100644 --- a/src/declarative/util/qdeclarativespringanimation_p.h +++ b/src/declarative/util/qdeclarativespringanimation_p.h @@ -54,14 +54,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeSpringAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeSpringAnimation : public QDeclarativeAbstractAnimation +class Q_AUTOTEST_EXPORT QDeclarativeSpringAnimation : public QDeclarativeNumberAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeSpringAnimation) Q_INTERFACES(QDeclarativePropertyValueSource) - Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) Q_PROPERTY(qreal spring READ spring WRITE setSpring) Q_PROPERTY(qreal damping READ damping WRITE setDamping) @@ -73,14 +71,6 @@ public: QDeclarativeSpringAnimation(QObject *parent=0); ~QDeclarativeSpringAnimation(); - virtual void setTarget(const QDeclarativeProperty &); - - qreal to() const; - void setTo(qreal value); - - qreal from() const; - void setFrom(qreal value); - qreal velocity() const; void setVelocity(qreal velocity); @@ -99,9 +89,6 @@ public: qreal modulus() const; void setModulus(qreal modulus); - bool enabled() const; - void setEnabled(bool enabled); - virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction); @@ -110,8 +97,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); Q_SIGNALS: - void toChanged(qreal); - void fromChanged(qreal); void modulusChanged(); void massChanged(); void syncChanged(); diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 9f4cc39..028bacb 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -154,13 +154,14 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje Notice the default state is referred to using an empty string (""). - States are commonly used together with \l {state-transitions}{Transitions} to provide + States are commonly used together with \l {Transitions} to provide animations when state changes occur. \note Setting the state of an object from within another state of the same object is not allowed. - \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, QtDeclarative + \sa {declarative/animation/states}{states example}, {qmlstates}{States}, + {qdeclarativeanimation.html#transitions}{QML Transitions}, QtDeclarative */ /*! @@ -229,20 +230,7 @@ bool QDeclarativeState::isWhenKnown() const be applied. For example, the following \l Rectangle changes in and out of the "hidden" state when the \l MouseArea is pressed: - \qml - Rectangle { - id: myRect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "hidden"; when: mouseArea.pressed - PropertyChanges { target: myRect; opacity: 0 } - } - } - \endqml + \snippet doc/src/snippets/declarative/state-when.qml 0 If multiple states in a group have \c when clauses that evaluate to \c true at the same time, the first matching state will be applied. For example, in the following snippet @@ -358,8 +346,10 @@ QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) cons if (!extends.isEmpty()) { QList<QDeclarativeState *> states = group->states(); for (int ii = 0; ii < states.count(); ++ii) - if (states.at(ii)->name() == extends) + if (states.at(ii)->name() == extends) { + qmlExecuteDeferred(states.at(ii)); applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList(group); + } } foreach(QDeclarativeStateOperation *op, operations) diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 67cd12e..1c1e964 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -112,7 +112,7 @@ public: } \endqml - \sa {qmlstate}{States} {state-transitions}{Transitions}, {QtDeclarative} + \sa {qmlstate}{States} {Transitions}, {QtDeclarative} */ QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent) @@ -204,7 +204,7 @@ void QDeclarativeStateGroupPrivate::clear_states(QDeclarativeListProperty<QDecla } \endqml - \sa {state-transitions}{Transitions} + \sa {Transitions} */ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty() { diff --git a/src/declarative/util/qdeclarativetimeline.cpp b/src/declarative/util/qdeclarativetimeline.cpp index 0258b3c..378c539 100644 --- a/src/declarative/util/qdeclarativetimeline.cpp +++ b/src/declarative/util/qdeclarativetimeline.cpp @@ -524,7 +524,7 @@ int QDeclarativeTimeLine::duration() const Following operations on \a timeLineValue in this timeline will be scheduled after all the currently scheduled actions on \a syncTo are complete. In - psuedo-code this is equivalent to: + pseudo-code this is equivalent to: \code QDeclarativeTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue))) \endcode @@ -549,7 +549,7 @@ void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue, QDecla Synchronize the end point of \a timeLineValue to the endpoint of the longest action cursrently scheduled in the timeline. - In psuedo-code, this is equivalent to: + In pseudo-code, this is equivalent to: \code QDeclarativeTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue)) \endcode diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 582191b..aa1426c 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -60,12 +60,25 @@ QT_BEGIN_NAMESPACE For example, the following \l Rectangle has two states: the default state, and an added "moved" state. In the "moved state, the rectangle's position changes - to (50, 50). The added \l Transition specifies that when the rectangle + to (50, 50). The added Transition specifies that when the rectangle changes between the default and the "moved" state, any changes to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. - + \snippet doc/src/snippets/declarative/transition.qml 0 + Notice the example does not require \l{PropertyAnimation::}{to} and + \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience, + these properties are automatically set to the values of \c x and \c y before + and after the state change; the \c from values are provided by + the current values of \c x and \c y, and the \c to values are provided by + the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and + \l{PropertyAnimation::}{from} values anyway to override the default values. + + By default, a Transition's animations are applied for any state change in the + parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to} + values can be set to restrict the animations to only be applied when changing + from one particular state to another. + To define multiple transitions, specify \l Item::transitions as a list: \qml @@ -78,7 +91,11 @@ QT_BEGIN_NAMESPACE } \endqml - \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} + If a state change has a Transition that matches the same property as a + \l Behavior, the Transition animation overrides the \l Behavior for that + state change. + + \sa {QML Animation}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative} */ /*! diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 7546a50..8f06858 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -365,7 +365,7 @@ QDeclarativeContext* QDeclarativeView::rootContext() const \value Null This QDeclarativeView has no source set. \value Ready This QDeclarativeView has loaded and created the QML component. \value Loading This QDeclarativeView is loading network data. - \value Error An error has occured. Call errorDescription() to retrieve a description. + \value Error An error has occurred. Call errorDescription() to retrieve a description. */ /*! \enum QDeclarativeView::ResizeMode @@ -391,7 +391,7 @@ QDeclarativeView::Status QDeclarativeView::status() const } /*! - Return the list of errors that occured during the last compile or create + Return the list of errors that occurred during the last compile or create operation. An empty list is returned if isError() is not set. */ QList<QDeclarativeError> QDeclarativeView::errors() const diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 05f751d..ece3d3a 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -560,7 +560,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla ListView { width: 180; height: 300 model: xmlModel - delegate: Text { text: title + " (" + pubDate + ")" } + delegate: Text { text: title + ": " + pubDate } } \endqml @@ -855,6 +855,12 @@ qreal QDeclarativeXmlListModel::progress() const return d->progress; } +/*! + \qmlmethod void XmlListModel::errorString() + + Returns a string description of the last error that occurred + if \l status is XmlListModel::Error. +*/ QString QDeclarativeXmlListModel::errorString() const { Q_D(const QDeclarativeXmlListModel); diff --git a/src/declarative/util/qlistmodelinterface.cpp b/src/declarative/util/qlistmodelinterface.cpp index 98d6a5b..acf4dd6 100644 --- a/src/declarative/util/qlistmodelinterface.cpp +++ b/src/declarative/util/qlistmodelinterface.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE */ /*! \fn QHash<int,QVariant> QListModelInterface::data(int index, const QList<int>& roles) const - Returns the data at the given \a index for the specifed \a roles. + Returns the data at the given \a index for the specified \a roles. */ /*! \fn bool QListModelInterface::setData(int index, const QHash<int,QVariant>& values) |