diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-25 10:54:16 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-25 10:54:16 (GMT) |
commit | cb50699b39e016a64a2a06088042622546c428a2 (patch) | |
tree | 77d269a3103a6c140098b9caaafd17a29a81addd /src/declarative | |
parent | 89807f70656b95c1568ef183dd7f28c527fc3eaa (diff) | |
parent | 890c1110ec5e39bb6e63e99fe09c296c1ea824be (diff) | |
download | Qt-cb50699b39e016a64a2a06088042622546c428a2.zip Qt-cb50699b39e016a64a2a06088042622546c428a2.tar.gz Qt-cb50699b39e016a64a2a06088042622546c428a2.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
demos/declarative/snake/snake.qml
qmake/generators/symbian/symbiancommon.cpp
src/network/access/qnetworkaccessmanager.cpp
src/s60installs/s60installs.pro
tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
tests/auto/qnetworkreply/tst_qnetworkreply.cpp
Diffstat (limited to 'src/declarative')
57 files changed, 744 insertions, 398 deletions
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h index 3d83e8a..9b8572b 100644 --- a/src/declarative/debugger/qdeclarativedebug_p.h +++ b/src/declarative/debugger/qdeclarativedebug_p.h @@ -45,6 +45,8 @@ #include <QtCore/qurl.h> #include <QtCore/qvariant.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -65,7 +67,7 @@ class QDeclarativeDebugObjectReference; class QDeclarativeDebugFileReference; class QDeclarativeDebugEngineReference; class QDeclarativeEngineDebugPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeEngineDebug : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject { Q_OBJECT public: @@ -111,7 +113,7 @@ private: Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugWatch : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject { Q_OBJECT public: @@ -142,7 +144,7 @@ private: int m_objectDebugId; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch { Q_OBJECT public: @@ -155,7 +157,7 @@ private: QString m_name; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch { Q_OBJECT public: @@ -170,7 +172,7 @@ private: }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugQuery : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject { Q_OBJECT public: @@ -194,7 +196,7 @@ private: State m_state; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugFileReference +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference { public: QDeclarativeDebugFileReference(); @@ -215,7 +217,7 @@ private: int m_columnNumber; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugEngineReference +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference { public: QDeclarativeDebugEngineReference(); @@ -232,7 +234,7 @@ private: QString m_name; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectReference +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference { public: QDeclarativeDebugObjectReference(); @@ -263,7 +265,7 @@ private: QList<QDeclarativeDebugObjectReference> m_children; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugContextReference +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference { public: QDeclarativeDebugContextReference(); @@ -284,7 +286,7 @@ private: QList<QDeclarativeDebugContextReference> m_contexts; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugPropertyReference +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference { public: QDeclarativeDebugPropertyReference(); @@ -309,7 +311,7 @@ private: }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery { Q_OBJECT public: @@ -324,7 +326,7 @@ private: QList<QDeclarativeDebugEngineReference> m_engines; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery { Q_OBJECT public: @@ -339,7 +341,7 @@ private: QDeclarativeDebugContextReference m_context; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery { Q_OBJECT public: @@ -355,7 +357,7 @@ private: }; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery { Q_OBJECT public: diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h index 8d1706d..47f87a5 100644 --- a/src/declarative/debugger/qdeclarativedebugclient_p.h +++ b/src/declarative/debugger/qdeclarativedebugclient_p.h @@ -44,6 +44,8 @@ #include <QtNetwork/qtcpsocket.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -51,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeDebugConnectionPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugConnection : public QTcpSocket +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QTcpSocket { Q_OBJECT Q_DISABLE_COPY(QDeclarativeDebugConnection) @@ -67,7 +69,7 @@ private: }; class QDeclarativeDebugClientPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugClient : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugClient : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeDebugClient) diff --git a/src/declarative/debugger/qdeclarativedebuggerstatus_p.h b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h index a3ba40a..a1499d8 100644 --- a/src/declarative/debugger/qdeclarativedebuggerstatus_p.h +++ b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h @@ -44,13 +44,15 @@ #include <QtCore/qobject.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativeDebuggerStatus +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebuggerStatus { public: virtual ~QDeclarativeDebuggerStatus(); diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h index c9cb839..5689dff 100644 --- a/src/declarative/debugger/qdeclarativedebughelper_p.h +++ b/src/declarative/debugger/qdeclarativedebughelper_p.h @@ -44,6 +44,8 @@ #include <QtCore/qglobal.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -53,7 +55,7 @@ class QDeclarativeEngine; // Helper methods to access private API through a stable interface // This is used in the qmljsdebugger library of QtCreator. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugHelper { public: static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine); diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h index 0cadbe5..da27b9a 100644 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ b/src/declarative/debugger/qdeclarativedebugservice_p.h @@ -44,6 +44,8 @@ #include <QtCore/qobject.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -51,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeDebugServicePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugService : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeDebugService) diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h index cfdce4e..d153833 100644 --- a/src/declarative/debugger/qpacketprotocol_p.h +++ b/src/declarative/debugger/qpacketprotocol_p.h @@ -45,6 +45,8 @@ #include <QtCore/qobject.h> #include <QtCore/qdatastream.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -57,7 +59,7 @@ class QPacket; class QPacketAutoSend; class QPacketProtocolPrivate; -class Q_DECLARATIVE_EXPORT QPacketProtocol : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject { Q_OBJECT public: @@ -87,7 +89,7 @@ private: }; -class Q_DECLARATIVE_EXPORT QPacket : public QDataStream +class Q_DECLARATIVE_PRIVATE_EXPORT QPacket : public QDataStream { public: QPacket(); @@ -104,7 +106,7 @@ protected: QBuffer * buf; }; -class Q_DECLARATIVE_EXPORT QPacketAutoSend : public QPacket +class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket { public: virtual ~QPacketAutoSend(); diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p.h index c929797..8223b17 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h +++ b/src/declarative/graphicsitems/qdeclarativeanchors_p.h @@ -48,6 +48,8 @@ #include <QtCore/QObject> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -56,7 +58,7 @@ QT_MODULE(Declarative) class QDeclarativeAnchorsPrivate; class QDeclarativeAnchorLine; -class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp index dbfb3fb..61fd562 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents.cpp +++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp @@ -113,11 +113,13 @@ Item { \qmlclass MouseEvent QDeclarativeMouseEvent \since 4.7 \ingroup qml-event-elements - + \brief The MouseEvent object provides information about a mouse event. - The position of the mouse can be found via the x and y properties. - The button that caused the event is available via the button property. + The position of the mouse can be found via the \l x and \l y properties. + The button that caused the event is available via the \l button property. + + \sa MouseArea */ /*! @@ -129,7 +131,7 @@ Item { \qmlproperty int MouseEvent::x \qmlproperty int MouseEvent::y - These properties hold the position of the mouse event. + These properties hold the coordinates of the position supplied by the mouse event. */ @@ -186,7 +188,7 @@ Item { It contains a bitwise combination of: \list \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. + \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. \o Qt.AltModifier - An Alt key on the keyboard is pressed. \o Qt.MetaModifier - A Meta key on the keyboard is pressed. @@ -195,9 +197,12 @@ Item { For example, to react to a Shift key + Left mouse button click: \qml -MouseArea { - onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); } -} + MouseArea { + onClicked: { + if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) + doSomething(); + } + } \endqml */ diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index cdfdc58..6fe1522 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -85,7 +85,11 @@ qreal QDeclarativeFlickableVisibleArea::yPosition() const void QDeclarativeFlickableVisibleArea::updateVisible() { QDeclarativeFlickablePrivate *p = static_cast<QDeclarativeFlickablePrivate *>(QGraphicsItemPrivate::get(flickable)); - bool pageChange = false; + + bool changeX = false; + bool changeY = false; + bool changeWidth = false; + bool changeHeight = false; // Vertical const qreal viewheight = flickable->height(); @@ -95,11 +99,11 @@ void QDeclarativeFlickableVisibleArea::updateVisible() if (pageSize != m_heightRatio) { m_heightRatio = pageSize; - pageChange = true; + changeHeight = true; } if (pagePos != m_yPosition) { m_yPosition = pagePos; - pageChange = true; + changeY = true; } // Horizontal @@ -110,14 +114,21 @@ void QDeclarativeFlickableVisibleArea::updateVisible() if (pageSize != m_widthRatio) { m_widthRatio = pageSize; - pageChange = true; + changeWidth = true; } if (pagePos != m_xPosition) { m_xPosition = pagePos; - pageChange = true; + changeX = true; } - if (pageChange) - emit pageChanged(); + + if (changeX) + emit xPositionChanged(m_xPosition); + if (changeY) + emit yPositionChanged(m_yPosition); + if (changeWidth) + emit widthRatioChanged(m_widthRatio); + if (changeHeight) + emit heightRatioChanged(m_heightRatio); } @@ -472,9 +483,9 @@ qreal QDeclarativeFlickable::contentX() const void QDeclarativeFlickable::setContentX(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->hData.move); d->vTime = d->timeline.time(); + movementXEnding(); if (-pos != d->hData.move.value()) { d->hData.move.setValue(-pos); viewportMoved(); @@ -490,9 +501,9 @@ qreal QDeclarativeFlickable::contentY() const void QDeclarativeFlickable::setContentY(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->vData.move); d->vTime = d->timeline.time(); + movementYEnding(); if (-pos != d->vData.move.value()) { d->vData.move.setValue(-pos); viewportMoved(); @@ -1484,6 +1495,15 @@ void QDeclarativeFlickable::movementStarting() void QDeclarativeFlickable::movementEnding() { Q_D(QDeclarativeFlickable); + movementXEnding(); + movementYEnding(); + d->hData.smoothVelocity.setValue(0); + d->vData.smoothVelocity.setValue(0); +} + +void QDeclarativeFlickable::movementXEnding() +{ + Q_D(QDeclarativeFlickable); if (d->flickingHorizontally) { d->flickingHorizontally = false; emit flickingChanged(); @@ -1491,13 +1511,6 @@ void QDeclarativeFlickable::movementEnding() if (!d->flickingVertically) emit flickEnded(); } - if (d->flickingVertically) { - d->flickingVertically = false; - emit flickingChanged(); - emit flickingVerticallyChanged(); - if (!d->flickingHorizontally) - emit flickEnded(); - } if (!d->pressed && !d->stealMouse) { if (d->movingHorizontally) { d->movingHorizontally = false; @@ -1507,6 +1520,20 @@ void QDeclarativeFlickable::movementEnding() if (!d->movingVertically) emit movementEnded(); } + } +} + +void QDeclarativeFlickable::movementYEnding() +{ + Q_D(QDeclarativeFlickable); + if (d->flickingVertically) { + d->flickingVertically = false; + emit flickingChanged(); + emit flickingVerticallyChanged(); + if (!d->flickingHorizontally) + emit flickEnded(); + } + if (!d->pressed && !d->stealMouse) { if (d->movingVertically) { d->movingVertically = false; d->vMoved = false; @@ -1516,8 +1543,6 @@ void QDeclarativeFlickable::movementEnding() emit movementEnded(); } } - d->hData.smoothVelocity.setValue(0); - d->vData.smoothVelocity.setValue(0); } void QDeclarativeFlickablePrivate::updateVelocity() diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 44f2bcf..6e4d8ed 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -163,7 +163,6 @@ Q_SIGNALS: void horizontalVelocityChanged(); void verticalVelocityChanged(); void isAtBoundaryChanged(); - void pageChanged(); void flickableDirectionChanged(); void interactiveChanged(); void boundsBehaviorChanged(); @@ -191,6 +190,8 @@ protected Q_SLOTS: void movementEnding(); protected: + void movementXEnding(); + void movementYEnding(); virtual qreal minXExtent() const; virtual qreal minYExtent() const; virtual qreal maxXExtent() const; diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index beee741..afefde2 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -182,10 +182,10 @@ class QDeclarativeFlickableVisibleArea : public QObject { Q_OBJECT - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) + Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged) + Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged) + Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged) + Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) public: QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent=0); @@ -198,7 +198,10 @@ public: void updateVisible(); signals: - void pageChanged(); + void xPositionChanged(qreal xPosition); + void yPositionChanged(qreal yPosition); + void widthRatioChanged(qreal widthRatio); + void heightRatioChanged(qreal heightRatio); private: QDeclarativeFlickable *flickable; diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 4ecf87b..f118a85 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -83,27 +83,28 @@ public: \section1 Example Usage - \beginfloatright - \inlineimage flipable.gif - \endfloat - The following example shows a Flipable item that flips whenever it is clicked, rotating about the y-axis. - The \l Rotation element is used to specify the angle and axis of the flip. - When \c flipped is true, the item changes to the "back" state, where - the angle is changed to 180 degrees to produce the flipping effect. + This flipable item has a \c flipped boolean property that is toggled + whenever the MouseArea within the flipable is clicked. When + \c flipped is true, the item changes to the "back" state; in this + state, the \c angle of the \l Rotation item is changed to 180 + degrees to produce the flipping effect. When \c flipped is false, the + item reverts to the default state, in which the \c angle value is 0. + + \snippet doc/src/snippets/declarative/flipable/flipable.qml 0 - \clearfloat - \snippet doc/src/snippets/declarative/flipable/flipable-snippet.qml 0 + \image flipable.gif - The \l Transition creates the animation that changes the angle over the - duration of one second. When the item changes between its "back" and + The \l Transition creates the animation that changes the angle over + four seconds. When the item changes between its "back" and default states, the NumberAnimation animates the angle between its old and new values. - See the \l {QML States} and \l {QML Animation} documentation for more - details on state changes and how animations work within transitions. + See \l {QML States} for details on state changes and the default + state, and \l {QML Animation} for more information on how animations + work within transitions. \sa {declarative/ui-components/flipable}{Flipable example} */ diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 6ee6b0d..bbc03f3 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -112,7 +112,7 @@ public: , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarativeGridView::NoSnap) , ownModel(false), wrap(false), autoHighlight(true) , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) - , deferredRelease(false), haveHighlightRange(false) {} + , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {} void init(); void clear(); @@ -392,6 +392,7 @@ public: bool layoutScheduled : 1; bool deferredRelease : 1; bool haveHighlightRange : 1; + bool currentIndexCleared : 1; }; void QDeclarativeGridViewPrivate::init() @@ -730,6 +731,8 @@ void QDeclarativeGridViewPrivate::createHighlight() QDeclarative_setParent_noEvent(item, q->contentItem()); item->setParentItem(q->contentItem()); highlight = new FxGridItem(item, q); + if (currentItem) + highlight->setPosition(currentItem->colPos(), currentItem->rowPos()); highlightXAnimator = new QSmoothedAnimation(q); highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x")); highlightXAnimator->userDuration = highlightMoveDuration; @@ -771,8 +774,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) currentItem->attached->setIsCurrentItem(false); releaseItem(currentItem); currentItem = 0; - currentIndex = -1; + currentIndex = modelIndex; + emit q->currentIndexChanged(); updateHighlight(); + } else if (currentIndex != modelIndex) { + currentIndex = modelIndex; emit q->currentIndexChanged(); } return; @@ -1236,7 +1242,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore | QDeclarativeGridViewPrivate::BufferAfter; if (isComponentComplete()) { refill(); - if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { + if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; @@ -1324,7 +1330,8 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) \qmlproperty Item GridView::currentItem The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. + \c currentItem holds the current item. Setting the currentIndex to -1 + will clear the highlight and set currentItem to null. If highlightFollowsCurrentItem is \c true, setting either of these properties will smoothly scroll the GridView so that the current @@ -1344,10 +1351,13 @@ void QDeclarativeGridView::setCurrentIndex(int index) Q_D(QDeclarativeGridView); if (d->requestedIndex >= 0) // currently creating item return; - if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + d->currentIndexCleared = (index == -1); + if (index == d->currentIndex) + return; + if (isComponentComplete() && d->isValid()) { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(index); - } else if (index != d->currentIndex) { + } else { d->currentIndex = index; emit currentIndexChanged(); } @@ -1822,6 +1832,8 @@ void QDeclarativeGridView::viewportMoved() { Q_D(QDeclarativeGridView); QDeclarativeFlickable::viewportMoved(); + if (!d->itemCount) + return; d->lazyRelease = true; if (d->flickingHorizontally || d->flickingVertically) { if (yflick()) { @@ -1983,22 +1995,25 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) Move the currentIndex up one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexUp() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { if (currentIndex() >= d->columns || d->wrap) { int index = currentIndex() - d->columns; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } else { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } } @@ -2008,22 +2023,25 @@ void QDeclarativeGridView::moveCurrentIndexUp() Move the currentIndex down one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexDown() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { - if (currentIndex() < d->model->count() - d->columns || d->wrap) { + if (currentIndex() < count - d->columns || d->wrap) { int index = currentIndex()+d->columns; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } else { - if (currentIndex() < d->model->count() - 1 || d->wrap) { + if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } } @@ -2033,22 +2051,25 @@ void QDeclarativeGridView::moveCurrentIndexDown() Move the currentIndex left one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexLeft() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } else { if (currentIndex() >= d->columns || d->wrap) { int index = currentIndex() - d->columns; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } } @@ -2058,22 +2079,25 @@ void QDeclarativeGridView::moveCurrentIndexLeft() Move the currentIndex right one item in the view. The current index will wrap if keyNavigationWraps is true and it - is currently at the end. + is currently at the end. This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeGridView::moveCurrentIndexRight() { Q_D(QDeclarativeGridView); + const int count = d->model ? d->model->count() : 0; + if (!count) + return; if (d->flow == QDeclarativeGridView::LeftToRight) { - if (currentIndex() < d->model->count() - 1 || d->wrap) { + if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } else { - if (currentIndex() < d->model->count() - d->columns || d->wrap) { + if (currentIndex() < count - d->columns || d->wrap) { int index = currentIndex()+d->columns; - setCurrentIndex(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } } @@ -2201,7 +2225,7 @@ void QDeclarativeGridView::componentComplete() if (d->isValid()) { refill(); d->moveReason = QDeclarativeGridViewPrivate::SetIndex; - if (d->currentIndex < 0) + if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else d->updateCurrent(d->currentIndex); @@ -2276,13 +2300,13 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) return; if (!d->visibleItems.count() || d->model->count() <= 1) { d->scheduleLayout(); - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; emit currentIndexChanged(); - } else if (d->currentIndex < 0) { + } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) { d->updateCurrent(0); } d->itemCount += count; @@ -2390,7 +2414,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) } } - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) { @@ -2477,8 +2501,8 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) if (removedVisible && d->visibleItems.isEmpty()) { d->timeline.clear(); - d->setPosition(0); if (d->itemCount == 0) { + d->setPosition(0); d->updateHeader(); d->updateFooter(); update(); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 51eb5f2..95a4fd6 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -728,41 +728,39 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) \since 4.7 \brief The Keys attached property provides key handling to Items. - All visual primitives support key handling via the \e Keys - attached property. Keys can be handled via the \e onPressed - and \e onReleased signal properties. + All visual primitives support key handling via the Keys + attached property. Keys can be handled via the onPressed + and onReleased signal properties. The signal properties have a \l KeyEvent parameter, named \e event which contains details of the event. If a key is handled \e event.accepted should be set to true to prevent the event from propagating up the item hierarchy. - \code - Item { - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Left) { - console.log("move left"); - event.accepted = true; - } - } - } - \endcode + \section1 Example Usage + + The following example shows how the general onPressed handler can + be used to test for a certain key; in this case, the left cursor + key: + + \snippet doc/src/snippets/declarative/keys/keys-pressed.qml key item Some keys may alternatively be handled via specific signal properties, for example \e onSelectPressed. These handlers automatically set \e event.accepted to true. - \code - Item { - focus: true - Keys.onLeftPressed: console.log("move left") - } - \endcode + \snippet doc/src/snippets/declarative/keys/keys-handler.qml key item + + See \l{Qt::Key}{Qt.Key} for the list of keyboard codes. - See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. + \section1 Key Handling Priorities - If priority is Keys.BeforeItem (default) the order of key event processing is: + The Keys attached property can be configured to handle key events + before or after the item it is attached to. This makes it possible + to intercept events in order to override an item's default behavior, + or act as a fallback for keys not handled by the item. + + If \l priority is Keys.BeforeItem (default) the order of key event processing is: \list 1 \o Items specified in \c forwardTo @@ -773,6 +771,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) \endlist If priority is Keys.AfterItem the order of key event processing is: + \list 1 \o Item specific key handling, e.g. TextInput key handling \o Items specified in \c forwardTo diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 6fd3b71..e29f285 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -182,7 +182,8 @@ public: , bufferMode(BufferBefore | BufferAfter) , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false) , correctFlick(false), inFlickCorrection(false), lazyRelease(false) - , deferredRelease(false), layoutScheduled(false), minExtentDirty(true), maxExtentDirty(true) + , deferredRelease(false), layoutScheduled(false), currentIndexCleared(false) + , minExtentDirty(true), maxExtentDirty(true) {} void init(); @@ -393,44 +394,19 @@ public: } // map a model index to visibleItems index. - // These may differ if removed items are still present in the visible list, - // e.g. doing a removal animation int mapFromModel(int modelIndex) const { if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) return -1; for (int i = 0; i < visibleItems.count(); ++i) { FxListItem *listItem = visibleItems.at(i); if (listItem->index == modelIndex) - return i + visibleIndex; + return i; if (listItem->index > modelIndex) return -1; } return -1; // Not in visibleList } - bool mapRangeFromModel(int &index, int &count) const { - if (index + count < visibleIndex) - return false; - - int lastIndex = -1; - for (int i = visibleItems.count()-1; i >= 0; --i) { - FxListItem *listItem = visibleItems.at(i); - if (listItem->index != -1) { - lastIndex = listItem->index; - break; - } - } - - if (index > lastIndex) - return false; - - int last = qMin(index + count - 1, lastIndex); - index = qMax(index, visibleIndex); - count = last - index + 1; - - return true; - } - void updateViewport() { Q_Q(QDeclarativeListView); if (orient == QDeclarativeListView::Vertical) { @@ -544,6 +520,7 @@ public: bool lazyRelease : 1; bool deferredRelease : 1; bool layoutScheduled : 1; + bool currentIndexCleared : 1; mutable bool minExtentDirty : 1; mutable bool maxExtentDirty : 1; }; @@ -881,6 +858,7 @@ void QDeclarativeListViewPrivate::createHighlight() } else { highlight->item->setWidth(currentItem->item->width()); } + highlight->setPosition(currentItem->itemPosition()); } QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); @@ -1045,8 +1023,11 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) currentItem->attached->setIsCurrentItem(false); releaseItem(currentItem); currentItem = 0; - currentIndex = -1; + currentIndex = modelIndex; + emit q->currentIndexChanged(); updateHighlight(); + } else if (currentIndex != modelIndex) { + currentIndex = modelIndex; emit q->currentIndexChanged(); } return; @@ -1598,7 +1579,7 @@ void QDeclarativeListView::setModel(const QVariant &model) if (isComponentComplete()) { updateSections(); refill(); - if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { + if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { d->moveReason = QDeclarativeListViewPrivate::SetIndex; @@ -1688,7 +1669,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) \qmlproperty Item ListView::currentItem The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. + \c currentItem holds the current item. Setting the currentIndex to -1 + will clear the highlight and set currentItem to null. If highlightFollowsCurrentItem is \c true, setting either of these properties will smoothly scroll the ListView so that the current @@ -1708,10 +1690,13 @@ void QDeclarativeListView::setCurrentIndex(int index) Q_D(QDeclarativeListView); if (d->requestedIndex >= 0) // currently creating item return; - if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + d->currentIndexCleared = (index == -1); + if (index == d->currentIndex) + return; + if (isComponentComplete() && d->isValid()) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(index); - } else if (index != d->currentIndex) { + } else { d->currentIndex = index; emit currentIndexChanged(); } @@ -2320,6 +2305,8 @@ void QDeclarativeListView::viewportMoved() { Q_D(QDeclarativeListView); QDeclarativeFlickable::viewportMoved(); + if (!d->itemCount) + return; d->lazyRelease = true; refill(); if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) @@ -2523,16 +2510,18 @@ void QDeclarativeListView::geometryChanged(const QRectF &newGeometry, Increments the current index. The current index will wrap if keyNavigationWraps is true and it is currently at the end. + This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeListView::incrementCurrentIndex() { Q_D(QDeclarativeListView); - if (currentIndex() < d->model->count() - 1 || d->wrap) { + int count = d->model ? d->model->count() : 0; + if (count && (currentIndex() < count - 1 || d->wrap)) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; int index = currentIndex()+1; - d->updateCurrent(index < d->model->count() ? index : 0); + setCurrentIndex((index >= 0 && index < count) ? index : 0); } } @@ -2541,16 +2530,18 @@ void QDeclarativeListView::incrementCurrentIndex() Decrements the current index. The current index will wrap if keyNavigationWraps is true and it is currently at the beginning. + This method has no effect if the \l count is zero. \bold Note: methods should only be called after the Component has completed. */ void QDeclarativeListView::decrementCurrentIndex() { Q_D(QDeclarativeListView); - if (currentIndex() > 0 || d->wrap) { + int count = d->model ? d->model->count() : 0; + if (count && (currentIndex() > 0 || d->wrap)) { d->moveReason = QDeclarativeListViewPrivate::SetIndex; int index = currentIndex()-1; - d->updateCurrent(index >= 0 ? index : d->model->count()-1); + setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } @@ -2684,7 +2675,7 @@ void QDeclarativeListView::componentComplete() if (d->isValid()) { refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; - if (d->currentIndex < 0) + if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else d->updateCurrent(d->currentIndex); @@ -2784,13 +2775,13 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->moveReason = QDeclarativeListViewPrivate::Other; if (!d->visibleItems.count() || d->model->count() <= 1) { d->scheduleLayout(); - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; emit currentIndexChanged(); - } else if (d->currentIndex < 0) { + } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) { d->updateCurrent(0); } d->itemCount += count; @@ -2798,15 +2789,15 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) return; } - int overlapCount = count; - if (!d->mapRangeFromModel(modelIndex, overlapCount)) { + int index = d->mapFromModel(modelIndex); + if (index < 0) { int i = d->visibleItems.count() - 1; while (i > 0 && d->visibleItems.at(i)->index == -1) --i; if (d->visibleItems.at(i)->index + 1 == modelIndex && d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) { // Special case of appending an item to the model. - modelIndex = d->visibleIndex + d->visibleItems.count(); + index = d->visibleItems.count(); } else { if (modelIndex < d->visibleIndex) { // Insert before visible items @@ -2833,7 +2824,6 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) // At least some of the added items will be visible - int index = modelIndex - d->visibleIndex; // index can be the next item past the end of the visible items list (i.e. appended) int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position() : d->visibleItems.at(index-1)->endPosition()+d->spacing+1; @@ -2897,7 +2887,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) } diff = pos - initialPos; } - if (d->currentIndex >= modelIndex) { + if (d->itemCount && d->currentIndex >= modelIndex) { // adjust current item index d->currentIndex += count; if (d->currentItem) { diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index 15b91e5..d3ae926 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeBasePositionerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 9831d5f..1ffd3bd 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -261,9 +261,9 @@ void QDeclarativeRectangle::doUpdate() A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain - border smoothness. Also, the border is rendered evenly on either side of the + border smoothness. Also, the border is rendered evenly on either side of the rectangle's boundaries, and the spare pixel is rendered to the right and below the - rectangle (as documented for QRect rendering). This can cause unintended effects if + rectangle (as documented for QRect rendering). This can cause unintended effects if \c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item: \beginfloatright diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p.h index ecc3fbf..99dca1b 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle_p.h +++ b/src/declarative/graphicsitems/qdeclarativerectangle_p.h @@ -46,12 +46,14 @@ #include <QtGui/qbrush.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativePen : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePen : public QObject { Q_OBJECT @@ -131,7 +133,7 @@ private: }; class QDeclarativeRectanglePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeRectangle : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeRectangle : public QDeclarativeItem { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h index 42813dd..c6d4629 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h @@ -42,21 +42,22 @@ #ifndef QDECLARATIVESCALEGRID_H #define QDECLARATIVESCALEGRID_H -#include "private/qdeclarativeborderimage_p.h" - -#include <private/qdeclarativepixmapcache_p.h> #include <qdeclarative.h> #include <QtCore/QString> #include <QtCore/QObject> +#include <private/qdeclarativeborderimage_p.h> +#include <private/qdeclarativepixmapcache_p.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QDeclarativeScaleGrid : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScaleGrid : public QObject { Q_OBJECT Q_ENUMS(TileRule) @@ -94,7 +95,7 @@ private: int _bottom; }; -class Q_DECLARATIVE_EXPORT QDeclarativeGridScaledImage +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeGridScaledImage { public: QDeclarativeGridScaledImage(); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 308aefa..0717b78 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -270,6 +270,7 @@ void QDeclarativeTextPrivate::updateSize() internalWidthUpdate = false; q->setImplicitHeight(size.height()); emit q->paintedSizeChanged(); + q->update(); } /*! @@ -1143,9 +1144,10 @@ QRectF QDeclarativeText::boundingRect() const void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QDeclarativeText); - if (!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width() && - (d->wrapMode != QDeclarativeText::NoWrap || d->elideMode != QDeclarativeText::ElideNone)) { - + if ((!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) + && (d->wrapMode != QDeclarativeText::NoWrap + || d->elideMode != QDeclarativeText::ElideNone + || d->hAlign != Qt::AlignLeft)) { if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && widthValid()) { // We need to re-elide d->updateLayout(); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index 2cc4d52..51434d5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -45,13 +45,15 @@ #include <QtGui/qtextoption.h> #include "qdeclarativeitem.h" +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeTextPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem { Q_OBJECT Q_ENUMS(HAlignment) diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp index e8b5fb2..89a2158 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp @@ -321,7 +321,7 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) priv->extended->type() == QPaintEngine::OpenVG || priv->extended->type() == QPaintEngine::OpenGL); - if (!paintEngineSupportsTransformations) { + if (!paintEngineSupportsTransformations || !priv->state->matrix.isAffine()) { QTextLayout::draw(painter, p); return; } diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index 1eb42e4..52f6210 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -510,15 +510,18 @@ int Lexer::lex() setDone(Eof); } } else if (isLineTerminator()) { - shiftWindowsLineBreak(); - yylineno++; - yycolumn = 0; - bol = true; - terminator = true; - syncProhibitAutomaticSemicolon(); if (restrKeyword) { + // automatic semicolon insertion + recordStartPos(); token = QDeclarativeJSGrammar::T_SEMICOLON; setDone(Other); + } else { + shiftWindowsLineBreak(); + yylineno++; + yycolumn = 0; + bol = true; + terminator = true; + syncProhibitAutomaticSemicolon(); } } else if (current == '"' || current == '\'') { recordStartPos(); diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h index 941a1b3..0b9bde6 100644 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ b/src/declarative/qml/qdeclarativebinding_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE -class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBinding +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractBinding { public: typedef QWeakPointer<QDeclarativeAbstractBinding> Pointer; @@ -138,7 +138,7 @@ private: class QDeclarativeContext; class QDeclarativeBindingPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding { Q_OBJECT public: diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp index 5d73d89..a4ecc77 100644 --- a/src/declarative/qml/qdeclarativecompileddata.cpp +++ b/src/declarative/qml/qdeclarativecompileddata.cpp @@ -205,7 +205,7 @@ const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const return type->metaObject(); } else { Q_ASSERT(component); - return static_cast<QDeclarativeComponentPrivate *>(QObjectPrivate::get(component))->cc->root; + return component->root; } } diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 74bc5bd..b2740b8 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -590,7 +590,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine, COMPILE_EXCEPTION(parserRef->refObjects.first(), err); } } else if (tref.typeData) { - ref.component = tref.typeData->component(); + ref.component = tref.typeData->compiledData(); ref.ref = tref.typeData; ref.ref->addref(); } @@ -722,7 +722,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt) obj->metatype = tr.metaObject(); if (tr.component) - obj->url = tr.component->url(); + obj->url = tr.component->url; if (tr.type) obj->typeName = tr.type->qmlTypeName(); obj->className = tr.className; @@ -940,7 +940,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj) // ### Surely the creation of this property cache could be more efficient QDeclarativePropertyCache *propertyCache = 0; if (tr.component) - propertyCache = QDeclarativeComponentPrivate::get(tr.component)->cc->rootPropertyCache->copy(); + propertyCache = tr.component->rootPropertyCache->copy(); else propertyCache = enginePrivate->cache(obj->metaObject()->superClass())->copy(); @@ -957,7 +957,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj) output->bytecode << meta; } else if (obj == unitRoot) { if (tr.component) - output->rootPropertyCache = QDeclarativeComponentPrivate::get(tr.component)->cc->rootPropertyCache; + output->rootPropertyCache = tr.component->rootPropertyCache; else output->rootPropertyCache = enginePrivate->cache(obj->metaObject()); diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 89eef09..43a0901 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -93,10 +93,11 @@ public: QByteArray className; QDeclarativeType *type; - QDeclarativeComponent *component; +// QDeclarativeComponent *component; + QDeclarativeCompiledData *component; QDeclarativeRefCount *ref; - QObject *createInstance(QDeclarativeContextData *, const QBitField &) const; + QObject *createInstance(QDeclarativeContextData *, const QBitField &, QList<QDeclarativeError> *) const; const QMetaObject *metaObject() const; }; QList<TypeReference> types; diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index cfef9cf..0a2a6db 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -733,48 +733,45 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons return 0; } - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + return begin(context, creationContext, cc, start, count, &state, 0, bindings); +} + +QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentContext, + QDeclarativeContextData *componentCreationContext, + QDeclarativeCompiledData *component, int start, int count, + ConstructionState *state, QList<QDeclarativeError> *errors, + const QBitField &bindings) +{ + QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(parentContext->engine); + bool isRoot = !enginePriv->inBeginCreate; + + Q_ASSERT(!isRoot || state); // Either this isn't a root component, or a state data must be provided + Q_ASSERT((state != 0) ^ (errors != 0)); // One of state or errors (but not both) must be provided - bool isRoot = !ep->inBeginCreate; if (isRoot) QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating); - QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, cc->url); QDeclarativeContextData *ctxt = new QDeclarativeContextData; ctxt->isInternal = true; - ctxt->url = cc->url; - ctxt->imports = cc->importCache; + ctxt->url = component->url; + ctxt->imports = component->importCache; // Nested global imports - if (creationContext && start != -1) - ctxt->importedScripts = creationContext->importedScripts; - - cc->importCache->addref(); - ctxt->setParent(context); + if (componentCreationContext && start != -1) + ctxt->importedScripts = componentCreationContext->importedScripts; - QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings); + component->importCache->addref(); + ctxt->setParent(parentContext); - if (ep->isDebugging && rv) { - if (!context->isInternal) - context->asQDeclarativeContextPrivate()->instances.append(rv); - QDeclarativeEngineDebugServer::instance()->objectCreated(engine, rv); - } - - return rv; -} - -QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, - QDeclarativeCompiledData *component, int start, int count, - ConstructionState *state, const QBitField &bindings) -{ - bool isRoot = !enginePriv->inBeginCreate; enginePriv->inBeginCreate = true; QDeclarativeVME vme; QObject *rv = vme.run(ctxt, component, start, count, bindings); - if (vme.isError()) - state->errors = vme.errors(); + if (vme.isError()) { + if(errors) *errors = vme.errors(); + else state->errors = vme.errors(); + } if (isRoot) { enginePriv->inBeginCreate = false; @@ -794,6 +791,12 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe enginePriv->inProgressCreations++; } + if (enginePriv->isDebugging && rv) { + if (!parentContext->isInternal) + parentContext->asQDeclarativeContextPrivate()->instances.append(rv); + QDeclarativeEngineDebugServer::instance()->objectCreated(parentContext->engine, rv); + } + return rv; } diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index a551cc8..7b30bad 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -109,9 +109,10 @@ public: }; ConstructionState state; - static QObject *begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, - QDeclarativeCompiledData *component, int start, int count, - ConstructionState *state, const QBitField &bindings = QBitField()); + static QObject *begin(QDeclarativeContextData *parentContext, QDeclarativeContextData *componentCreationContext, + QDeclarativeCompiledData *component, int start, int count, + ConstructionState *state, QList<QDeclarativeError> *errors, + const QBitField &bindings = QBitField()); static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, ConstructionState *state); static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state); diff --git a/src/declarative/qml/qdeclarativedom_p.h b/src/declarative/qml/qdeclarativedom_p.h index 6043ead..ee3625c 100644 --- a/src/declarative/qml/qdeclarativedom_p.h +++ b/src/declarative/qml/qdeclarativedom_p.h @@ -58,6 +58,8 @@ #include <QtCore/qlist.h> #include <QtCore/qshareddata.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -76,7 +78,7 @@ class QIODevice; class QDeclarativeDomDocumentPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomDocument +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomDocument { public: QDeclarativeDomDocument(); @@ -96,7 +98,7 @@ private: }; class QDeclarativeDomPropertyPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomProperty +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomProperty { public: QDeclarativeDomProperty(); @@ -123,7 +125,7 @@ private: }; class QDeclarativeDomDynamicPropertyPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomDynamicProperty +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomDynamicProperty { public: QDeclarativeDomDynamicProperty(); @@ -151,7 +153,7 @@ private: }; class QDeclarativeDomObjectPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomObject { public: QDeclarativeDomObject(); @@ -196,7 +198,7 @@ private: class QDeclarativeDomValuePrivate; class QDeclarativeDomBasicValuePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomValueLiteral +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomValueLiteral { public: QDeclarativeDomValueLiteral(); @@ -211,7 +213,7 @@ private: QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomValueBinding +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomValueBinding { public: QDeclarativeDomValueBinding(); @@ -226,7 +228,7 @@ private: QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomValueValueSource +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomValueValueSource { public: QDeclarativeDomValueValueSource(); @@ -241,7 +243,7 @@ private: QSharedDataPointer<QDeclarativeDomBasicValuePrivate> d; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomValueValueInterceptor +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomValueValueInterceptor { public: QDeclarativeDomValueValueInterceptor(); @@ -257,7 +259,7 @@ private: }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomComponent : public QDeclarativeDomObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomComponent : public QDeclarativeDomObject { public: QDeclarativeDomComponent(); @@ -268,7 +270,7 @@ public: QDeclarativeDomObject componentRoot() const; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomValue +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomValue { public: enum Type { @@ -312,7 +314,7 @@ private: QSharedDataPointer<QDeclarativeDomValuePrivate> d; }; -class Q_DECLARATIVE_EXPORT QDeclarativeDomList +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomList { public: QDeclarativeDomList(); @@ -333,7 +335,7 @@ private: }; class QDeclarativeDomImportPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDomImport +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDomImport { public: enum Type { Library, File }; diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h index 613f1fe..97b8121 100644 --- a/src/declarative/qml/qdeclarativeenginedebug_p.h +++ b/src/declarative/qml/qdeclarativeenginedebug_p.h @@ -117,10 +117,10 @@ private: QList<QDeclarativeEngine *> m_engines; QDeclarativeWatcher *m_watch; }; -Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &); -Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectData &); -Q_DECLARATIVE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); -Q_DECLARATIVE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectData &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectData &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); +Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugServer::QDeclarativeObjectProperty &); QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h index 65d9b24..31fbb1e 100644 --- a/src/declarative/qml/qdeclarativeglobal_p.h +++ b/src/declarative/qml/qdeclarativeglobal_p.h @@ -64,6 +64,12 @@ QT_MODULE(Declarative) return status == Yes; \ } +#ifdef Q_OS_SYMBIAN +#define Q_DECLARATIVE_PRIVATE_EXPORT +#else +#define Q_DECLARATIVE_PRIVATE_EXPORT Q_DECLARATIVE_EXPORT +#endif + struct QDeclarativeGraphics_DerivedObject : public QObject { void setParent_noEvent(QObject *parent) { diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h index 382abd2..9c486d3 100644 --- a/src/declarative/qml/qdeclarativemetatype_p.h +++ b/src/declarative/qml/qdeclarativemetatype_p.h @@ -58,6 +58,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qvariant.h> #include <QtCore/qbitarray.h> +#include <private/qdeclarativeglobal_p.h> QT_BEGIN_NAMESPACE @@ -65,7 +66,7 @@ class QDeclarativeType; class QDeclarativeCustomParser; class QDeclarativeTypePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeMetaType +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMetaType { public: static bool copy(int type, void *data, const void *copy = 0); @@ -105,7 +106,7 @@ public: static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions(); }; -class Q_DECLARATIVE_EXPORT QDeclarativeType +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeType { public: QByteArray typeName() const; diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 61a1f55..ea92111 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -838,9 +838,19 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass:: { MethodData *method = static_cast<MethodData *>(o); - if (method->data.flags & QDeclarativePropertyCache::Data::HasArguments) { + if (method->data.relatedIndex == -1) + return callPrecise(method->object, method->data, ctxt); + else + return callOverloaded(method, ctxt); +} - QMetaMethod m = method->object->metaObject()->method(method->data.coreIndex); +QDeclarativeObjectMethodScriptClass::Value +QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclarativePropertyCache::Data &data, + QScriptContext *ctxt) +{ + if (data.flags & QDeclarativePropertyCache::Data::HasArguments) { + + QMetaMethod m = object->metaObject()->method(data.coreIndex); QList<QByteArray> argTypeNames = m.parameterTypes(); QVarLengthArray<int, 9> argTypes(argTypeNames.count()); @@ -848,7 +858,7 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass:: for (int ii = 0; ii < argTypeNames.count(); ++ii) { argTypes[ii] = QMetaType::type(argTypeNames.at(ii)); if (argTypes[ii] == QVariant::Invalid) - argTypes[ii] = enumType(method->object->metaObject(), QString::fromLatin1(argTypeNames.at(ii))); + argTypes[ii] = enumType(object->metaObject(), QString::fromLatin1(argTypeNames.at(ii))); if (argTypes[ii] == QVariant::Invalid) return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii))))); } @@ -856,39 +866,301 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass:: if (argTypes.count() > ctxt->argumentCount()) return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments"))); - QVarLengthArray<MetaCallArgument, 9> args(argTypes.count() + 1); - args[0].initAsType(method->data.propType, engine); + return callMethod(object, data.coreIndex, data.propType, argTypes.count(), argTypes.data(), ctxt); + + } else { + + return callMethod(object, data.coreIndex, data.propType, 0, 0, ctxt); + + } +} + +QDeclarativeObjectMethodScriptClass::Value +QDeclarativeObjectMethodScriptClass::callMethod(QObject *object, int index, + int returnType, int argCount, int *argTypes, + QScriptContext *ctxt) +{ + if (argCount > 0) { - for (int ii = 0; ii < argTypes.count(); ++ii) + QVarLengthArray<MetaCallArgument, 9> args(argCount + 1); + args[0].initAsType(returnType, engine); + + for (int ii = 0; ii < argCount; ++ii) args[ii + 1].fromScriptValue(argTypes[ii], engine, ctxt->argument(ii)); QVarLengthArray<void *, 9> argData(args.count()); for (int ii = 0; ii < args.count(); ++ii) argData[ii] = args[ii].dataPtr(); - QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, argData.data()); + QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, argData.data()); return args[0].toValue(engine); - } else if (method->data.propType != 0) { - + } else if (returnType != 0) { + MetaCallArgument arg; - arg.initAsType(method->data.propType, engine); + arg.initAsType(returnType, engine); void *args[] = { arg.dataPtr() }; - QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args); + QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args); return arg.toValue(engine); } else { void *args[] = { 0 }; - QMetaObject::metacall(method->object, QMetaObject::InvokeMetaMethod, method->data.coreIndex, args); + QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, index, args); return Value(); } - return Value(); +} + +/*! +Resolve the overloaded method to call. The algorithm works conceptually like this: + 1. Resolve the set of overloads it is *possible* to call. + Impossible overloads include those that have too many parameters or have parameters + of unknown type. + 2. Filter the set of overloads to only contain those with the closest number of + parameters. + For example, if we are called with 3 parameters and there are 2 overloads that + take 2 parameters and one that takes 3, eliminate the 2 parameter overloads. + 3. Find the best remaining overload based on its match score. + If two or more overloads have the same match score, call the last one. The match + score is constructed by adding the matchScore() result for each of the parameters. +*/ +QDeclarativeObjectMethodScriptClass::Value +QDeclarativeObjectMethodScriptClass::callOverloaded(MethodData *method, QScriptContext *ctxt) +{ + int argumentCount = ctxt->argumentCount(); + + QDeclarativePropertyCache::Data *best = 0; + int bestParameterScore = INT_MAX; + int bestMatchScore = INT_MAX; + + QDeclarativePropertyCache::Data dummy; + QDeclarativePropertyCache::Data *attempt = &method->data; + + do { + QList<QByteArray> methodArgTypeNames; + + if (attempt->flags & QDeclarativePropertyCache::Data::HasArguments) + methodArgTypeNames = method->object->metaObject()->method(attempt->coreIndex).parameterTypes(); + + int methodArgumentCount = methodArgTypeNames.count(); + + if (methodArgumentCount > argumentCount) + continue; // We don't have sufficient arguments to call this method + + int methodParameterScore = argumentCount - methodArgumentCount; + if (methodParameterScore > bestParameterScore) + continue; // We already have a better option + + int methodMatchScore = 0; + QVarLengthArray<int, 9> methodArgTypes(methodArgumentCount); + + bool unknownArgument = false; + for (int ii = 0; ii < methodArgumentCount; ++ii) { + methodArgTypes[ii] = QMetaType::type(methodArgTypeNames.at(ii)); + if (methodArgTypes[ii] == QVariant::Invalid) + methodArgTypes[ii] = enumType(method->object->metaObject(), + QString::fromLatin1(methodArgTypeNames.at(ii))); + if (methodArgTypes[ii] == QVariant::Invalid) { + unknownArgument = true; + break; + } + methodMatchScore += matchScore(ctxt->argument(ii), methodArgTypes[ii], methodArgTypeNames.at(ii)); + } + if (unknownArgument) + continue; // We don't understand all the parameters + + if (bestParameterScore > methodParameterScore || bestMatchScore > methodMatchScore) { + best = attempt; + bestParameterScore = methodParameterScore; + bestMatchScore = methodMatchScore; + } + + if (bestParameterScore == 0 && bestMatchScore == 0) + break; // We can't get better than that + + } while((attempt = relatedMethod(method->object, attempt, dummy)) != 0); + + if (best) { + return callPrecise(method->object, *best, ctxt); + } else { + QString error = QLatin1String("Unable to determine callable overload. Candidates are:"); + QDeclarativePropertyCache::Data *candidate = &method->data; + while (candidate) { + error += QLatin1String("\n ") + QString::fromUtf8(method->object->metaObject()->method(candidate->coreIndex).signature()); + candidate = relatedMethod(method->object, candidate, dummy); + } + return Value(ctxt, ctxt->throwError(error)); + } +} + +/*! + Returns the match score for converting \a actual to be of type \a conversionType. A + zero score means "perfect match" whereas a higher score is worse. + + The conversion table is copied out of the QtScript callQtMethod() function. +*/ +int QDeclarativeObjectMethodScriptClass::matchScore(const QScriptValue &actual, int conversionType, + const QByteArray &conversionTypeName) +{ + if (actual.isNumber()) { + switch (conversionType) { + case QMetaType::Double: + return 0; + case QMetaType::Float: + return 1; + case QMetaType::LongLong: + case QMetaType::ULongLong: + return 2; + case QMetaType::Long: + case QMetaType::ULong: + return 3; + case QMetaType::Int: + case QMetaType::UInt: + return 4; + case QMetaType::Short: + case QMetaType::UShort: + return 5; + break; + case QMetaType::Char: + case QMetaType::UChar: + return 6; + default: + return 10; + } + } else if (actual.isString()) { + switch (conversionType) { + case QMetaType::QString: + return 0; + default: + return 10; + } + } else if (actual.isBoolean()) { + switch (conversionType) { + case QMetaType::Bool: + return 0; + default: + return 10; + } + } else if (actual.isDate()) { + switch (conversionType) { + case QMetaType::QDateTime: + return 0; + case QMetaType::QDate: + return 1; + case QMetaType::QTime: + return 2; + default: + return 10; + } + } else if (actual.isRegExp()) { + switch (conversionType) { + case QMetaType::QRegExp: + return 0; + default: + return 10; + } + } else if (actual.isVariant()) { + if (conversionType == qMetaTypeId<QVariant>()) + return 0; + else if (actual.toVariant().userType() == conversionType) + return 0; + else + return 10; + } else if (actual.isArray()) { + switch (conversionType) { + case QMetaType::QStringList: + case QMetaType::QVariantList: + return 5; + default: + return 10; + } + } else if (actual.isQObject()) { + switch (conversionType) { + case QMetaType::QObjectStar: + return 0; + default: + return 10; + } + } else if (actual.isNull()) { + switch (conversionType) { + case QMetaType::VoidStar: + case QMetaType::QObjectStar: + return 0; + default: + if (!conversionTypeName.endsWith('*')) + return 10; + else + return 0; + } + } else { + return 10; + } +} + +static inline int QMetaObject_methods(const QMetaObject *metaObject) +{ + struct Private + { + int revision; + int className; + int classInfoCount, classInfoData; + int methodCount, methodData; + }; + + return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount; +} + +static QByteArray QMetaMethod_name(const QMetaMethod &m) +{ + QByteArray sig = m.signature(); + int paren = sig.indexOf('('); + if (paren == -1) + return sig; + else + return sig.left(paren); +} + +/*! +Returns the next related method, if one, or 0. +*/ +QDeclarativePropertyCache::Data * +QDeclarativeObjectMethodScriptClass::relatedMethod(QObject *object, QDeclarativePropertyCache::Data *current, + QDeclarativePropertyCache::Data &dummy) +{ + QDeclarativePropertyCache *cache = QDeclarativeData::get(object)->propertyCache; + if (current->relatedIndex == -1) + return 0; + + if (cache) { + return cache->method(current->relatedIndex); + } else { + const QMetaObject *mo = object->metaObject(); + int methodOffset = mo->methodCount() - QMetaObject_methods(mo); + + while (methodOffset > current->relatedIndex) { + mo = mo->superClass(); + methodOffset -= QMetaObject_methods(mo); + } + + QMetaMethod method = mo->method(current->relatedIndex); + dummy.load(method); + + // Look for overloaded methods + QByteArray methodName = QMetaMethod_name(method); + for (int ii = current->relatedIndex - 1; ii >= methodOffset; --ii) { + if (methodName == QMetaMethod_name(mo->method(ii))) { + dummy.relatedIndex = ii; + return &dummy; + } + } + + return &dummy; + } } QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h index 75e384c..7956c40 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h @@ -65,6 +65,7 @@ class QDeclarativeEngine; class QScriptContext; class QScriptEngine; class QDeclarativeContextData; +class MethodData; class Q_AUTOTEST_EXPORT QDeclarativeObjectMethodScriptClass : public QScriptDeclarativeClass { @@ -82,6 +83,14 @@ protected: private: int enumType(const QMetaObject *, const QString &); + Value callPrecise(QObject *, const QDeclarativePropertyCache::Data &, QScriptContext *); + Value callOverloaded(MethodData *, QScriptContext *); + Value callMethod(QObject *, int index, int returnType, int argCount, int *argTypes, QScriptContext *ctxt); + + int matchScore(const QScriptValue &, int, const QByteArray &); + QDeclarativePropertyCache::Data *relatedMethod(QObject *, QDeclarativePropertyCache::Data *current, + QDeclarativePropertyCache::Data &dummy); + PersistentIdentifier m_connectId; PersistentIdentifier m_disconnectId; QScriptValue m_connect; diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h index c58aebc..b4753df 100644 --- a/src/declarative/qml/qdeclarativeparser_p.h +++ b/src/declarative/qml/qdeclarativeparser_p.h @@ -54,7 +54,6 @@ // #include "qdeclarative.h" -#include "private/qdeclarativerefcount_p.h" #include <QtCore/qbytearray.h> #include <QtCore/qlist.h> @@ -63,6 +62,8 @@ #include <QtCore/qstringlist.h> #include <private/qobject_p.h> +#include <private/qdeclarativerefcount_p.h> +#include <private/qdeclarativeglobal_p.h> QT_BEGIN_HEADER diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index b5fb619..1395e97 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1408,8 +1408,8 @@ static inline void flush_vme_signal(const QObject *object, int index) int methodOffset = metaObject->methodOffset(); while (methodOffset > index) { - methodOffset -= QMetaObject_methods(metaObject); metaObject = metaObject->d.superdata; + methodOffset -= QMetaObject_methods(metaObject); } QDeclarativeVMEMetaObject *vme = diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index a8438c8..a9d6979 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -55,17 +55,17 @@ #include "qdeclarativeproperty.h" -#include "private/qdeclarativepropertycache_p.h" -#include "private/qdeclarativeguard_p.h" - #include <private/qobject_p.h> +#include <private/qdeclarativeglobal_p.h> +#include <private/qdeclarativepropertycache_p.h> +#include <private/qdeclarativeguard_p.h> QT_BEGIN_NAMESPACE class QDeclarativeContext; class QDeclarativeEnginePrivate; class QDeclarativeExpression; -class Q_DECLARATIVE_EXPORT QDeclarativePropertyPrivate +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate { public: enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 }; diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 9e1ceb8..0adcdbd 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -93,6 +93,7 @@ void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeE void QDeclarativePropertyCache::Data::load(const QMetaMethod &m) { coreIndex = m.methodIndex(); + relatedIndex = -1; flags |= Data::IsFunction; if (m.methodType() == QMetaMethod::Signal) flags |= Data::IsSignal; @@ -140,15 +141,25 @@ void QDeclarativePropertyCache::clear() if (indexCache.at(ii)) indexCache.at(ii)->release(); } + for (int ii = 0; ii < methodIndexCache.count(); ++ii) { + RData *data = methodIndexCache.at(ii); + if (data) data->release(); + } + for (StringCache::ConstIterator iter = stringCache.begin(); - iter != stringCache.end(); ++iter) - (*iter)->release(); + iter != stringCache.end(); ++iter) { + RData *data = (*iter); + data->release(); + } for (IdentifierCache::ConstIterator iter = identifierCache.begin(); - iter != identifierCache.end(); ++iter) - (*iter)->release(); + iter != identifierCache.end(); ++iter) { + RData *data = (*iter); + data->release(); + } indexCache.clear(); + methodIndexCache.clear(); stringCache.clear(); identifierCache.clear(); } @@ -202,12 +213,16 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const { QDeclarativePropertyCache *cache = new QDeclarativePropertyCache(engine); cache->indexCache = indexCache; + cache->methodIndexCache = methodIndexCache; cache->stringCache = stringCache; cache->identifierCache = identifierCache; for (int ii = 0; ii < indexCache.count(); ++ii) { if (indexCache.at(ii)) indexCache.at(ii)->addref(); } + for (int ii = 0; ii < methodIndexCache.count(); ++ii) { + if (methodIndexCache.at(ii)) methodIndexCache.at(ii)->addref(); + } for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter) (*iter)->addref(); for (IdentifierCache::ConstIterator iter = identifierCache.begin(); iter != identifierCache.end(); ++iter) @@ -221,43 +236,14 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb { QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - int propCount = metaObject->propertyCount(); - int propOffset = metaObject->propertyOffset(); - - indexCache.resize(propCount); - for (int ii = propOffset; ii < propCount; ++ii) { - QMetaProperty p = metaObject->property(ii); - if (!p.isScriptable()) - continue; - - QString propName = QString::fromUtf8(p.name()); - - RData *data = new RData; - data->identifier = enginePriv->objectClass->createPersistentIdentifier(propName); - - data->load(p, engine); - data->flags |= propertyFlags; - - indexCache[ii] = data; - - if (stringCache.contains(propName)) { - stringCache[propName]->release(); - identifierCache[data->identifier.identifier]->release(); - } - - stringCache.insert(propName, data); - identifierCache.insert(data->identifier.identifier, data); - data->addref(); - data->addref(); - } - int methodCount = metaObject->methodCount(); - int methodOffset = qMax(2, metaObject->methodOffset()); // 2 to block the destroyed signal + // 3 to block the destroyed signal and the deleteLater() slot + int methodOffset = qMax(3, metaObject->methodOffset()); methodIndexCache.resize(methodCount); for (int ii = methodOffset; ii < methodCount; ++ii) { QMetaMethod m = metaObject->method(ii); - if (m.access() == QMetaMethod::Private) + if (m.access() == QMetaMethod::Private) continue; QString methodName = QString::fromUtf8(m.signature()); @@ -267,11 +253,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb RData *data = new RData; data->identifier = enginePriv->objectClass->createPersistentIdentifier(methodName); - - if (stringCache.contains(methodName)) { - stringCache[methodName]->release(); - identifierCache[data->identifier.identifier]->release(); - } + methodIndexCache[ii] = data; data->load(m); if (m.methodType() == QMetaMethod::Slot || m.methodType() == QMetaMethod::Method) @@ -279,73 +261,74 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb else if (m.methodType() == QMetaMethod::Signal) data->flags |= signalFlags; - methodIndexCache[ii] = data; + if (stringCache.contains(methodName)) { + RData *old = stringCache[methodName]; + // We only overload methods in the same class, exactly like C++ + if (old->flags & Data::IsFunction && old->coreIndex >= methodOffset) + data->relatedIndex = old->coreIndex; + stringCache[methodName]->release(); + identifierCache[data->identifier.identifier]->release(); + } stringCache.insert(methodName, data); identifierCache.insert(data->identifier.identifier, data); data->addref(); + data->addref(); } -} -void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaObject *metaObject) -{ - Q_ASSERT(engine); - Q_ASSERT(metaObject); - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - - clear(); - - // ### The properties/methods should probably be spliced on a per-metaobject basis int propCount = metaObject->propertyCount(); + int propOffset = metaObject->propertyOffset(); indexCache.resize(propCount); - for (int ii = propCount - 1; ii >= 0; --ii) { + for (int ii = propOffset; ii < propCount; ++ii) { QMetaProperty p = metaObject->property(ii); - if (!p.isScriptable()) { - indexCache[ii] = 0; + if (!p.isScriptable()) continue; - } + QString propName = QString::fromUtf8(p.name()); RData *data = new RData; data->identifier = enginePriv->objectClass->createPersistentIdentifier(propName); + indexCache[ii] = data; data->load(p, engine); + data->flags |= propertyFlags; - indexCache[ii] = data; - - if (stringCache.contains(propName)) - continue; + if (stringCache.contains(propName)) { + stringCache[propName]->release(); + identifierCache[data->identifier.identifier]->release(); + } stringCache.insert(propName, data); identifierCache.insert(data->identifier.identifier, data); data->addref(); data->addref(); } +} - int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 3; --ii) { // >=3 to block the destroyed signal and deleteLater() slot - QMetaMethod m = metaObject->method(ii); - if (m.access() == QMetaMethod::Private) - continue; - QString methodName = QString::fromUtf8(m.signature()); +void QDeclarativePropertyCache::updateRecur(QDeclarativeEngine *engine, const QMetaObject *metaObject) +{ + if (!metaObject) + return; - int parenIdx = methodName.indexOf(QLatin1Char('(')); - Q_ASSERT(parenIdx != -1); - methodName = methodName.left(parenIdx); + updateRecur(engine, metaObject->superClass()); - if (stringCache.contains(methodName)) - continue; + append(engine, metaObject); +} - RData *data = new RData; - data->identifier = enginePriv->objectClass->createPersistentIdentifier(methodName); +void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaObject *metaObject) +{ + Q_ASSERT(engine); + Q_ASSERT(metaObject); + QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - data->load(m); + clear(); - stringCache.insert(methodName, data); - identifierCache.insert(data->identifier.identifier, data); - data->addref(); - } + // Optimization to prevent unnecessary reallocation of lists + indexCache.reserve(metaObject->propertyCount()); + methodIndexCache.reserve(metaObject->methodCount()); + + updateRecur(engine,metaObject); } QDeclarativePropertyCache::Data * diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 79b126d..922010d 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -96,7 +96,7 @@ public: IsVMEFunction = 0x00000400, HasArguments = 0x00000800, IsSignal = 0x00001000, - IsVMESignal = 0x00002000, + IsVMESignal = 0x00002000 }; Q_DECLARE_FLAGS(Flags, Flag) @@ -105,7 +105,10 @@ public: Flags flags; int propType; int coreIndex; - int notifyIndex; + union { + int notifyIndex; // When !IsFunction + int relatedIndex; // When IsFunction + }; static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0); void load(const QMetaProperty &, QDeclarativeEngine *engine = 0); @@ -152,6 +155,8 @@ private: typedef QHash<QString, RData *> StringCache; typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache; + void updateRecur(QDeclarativeEngine *, const QMetaObject *); + QDeclarativeEngine *engine; IndexCache indexCache; IndexCache methodIndexCache; diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h index e6b0abe..b632222 100644 --- a/src/declarative/qml/qdeclarativestringconverters_p.h +++ b/src/declarative/qml/qdeclarativestringconverters_p.h @@ -56,6 +56,8 @@ #include <QtCore/qglobal.h> #include <QtCore/qvariant.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_NAMESPACE class QColor; @@ -69,19 +71,19 @@ class QVector3D; // XXX - Bauhaus currently uses these methods which is why they're exported namespace QDeclarativeStringConverters { - QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &); - QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0); + QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &); + QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0); - QColor Q_DECLARATIVE_EXPORT colorFromString(const QString &, bool *ok = 0); + QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok = 0); #ifndef QT_NO_DATESTRING - QDate Q_DECLARATIVE_EXPORT dateFromString(const QString &, bool *ok = 0); - QTime Q_DECLARATIVE_EXPORT timeFromString(const QString &, bool *ok = 0); - QDateTime Q_DECLARATIVE_EXPORT dateTimeFromString(const QString &, bool *ok = 0); + QDate Q_DECLARATIVE_PRIVATE_EXPORT dateFromString(const QString &, bool *ok = 0); + QTime Q_DECLARATIVE_PRIVATE_EXPORT timeFromString(const QString &, bool *ok = 0); + QDateTime Q_DECLARATIVE_PRIVATE_EXPORT dateTimeFromString(const QString &, bool *ok = 0); #endif - QPointF Q_DECLARATIVE_EXPORT pointFFromString(const QString &, bool *ok = 0); - QSizeF Q_DECLARATIVE_EXPORT sizeFFromString(const QString &, bool *ok = 0); - QRectF Q_DECLARATIVE_EXPORT rectFFromString(const QString &, bool *ok = 0); - QVector3D Q_DECLARATIVE_EXPORT vector3DFromString(const QString &, bool *ok = 0); + QPointF Q_DECLARATIVE_PRIVATE_EXPORT pointFFromString(const QString &, bool *ok = 0); + QSizeF Q_DECLARATIVE_PRIVATE_EXPORT sizeFFromString(const QString &, bool *ok = 0); + QRectF Q_DECLARATIVE_PRIVATE_EXPORT rectFFromString(const QString &, bool *ok = 0); + QVector3D Q_DECLARATIVE_PRIVATE_EXPORT vector3DFromString(const QString &, bool *ok = 0); } QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index c8e1a07..c015519 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -719,7 +719,7 @@ void QDeclarativeTypeLoader::clearCache() QDeclarativeTypeData::QDeclarativeTypeData(const QUrl &url, QDeclarativeTypeLoader::Options options, QDeclarativeTypeLoader *manager) : QDeclarativeDataBlob(url, QmlFile), m_options(options), m_typesResolved(false), - m_compiledData(0), m_component(0), m_typeLoader(manager) + m_compiledData(0), m_typeLoader(manager) { } @@ -768,23 +768,6 @@ QDeclarativeCompiledData *QDeclarativeTypeData::compiledData() const return m_compiledData; } -QDeclarativeComponent *QDeclarativeTypeData::component() const -{ - if (!m_component) { - - if (m_compiledData) { - m_component = new QDeclarativeComponent(typeLoader()->engine(), m_compiledData, -1, -1, 0); - } else { - m_component = new QDeclarativeComponent(typeLoader()->engine()); - QDeclarativeComponentPrivate::get(m_component)->url = finalUrl(); - QDeclarativeComponentPrivate::get(m_component)->state.errors = errors(); - } - - } - - return m_component; -} - void QDeclarativeTypeData::registerCallback(TypeDataCallback *callback) { Q_ASSERT(!m_callbacks.contains(callback)); diff --git a/src/declarative/qml/qdeclarativetypeloader_p.h b/src/declarative/qml/qdeclarativetypeloader_p.h index 7381f28..718537a 100644 --- a/src/declarative/qml/qdeclarativetypeloader_p.h +++ b/src/declarative/qml/qdeclarativetypeloader_p.h @@ -243,7 +243,6 @@ public: const QList<ScriptReference> &resolvedScripts() const; QDeclarativeCompiledData *compiledData() const; - QDeclarativeComponent *component() const; // Used by QDeclarativeComponent to get notifications struct TypeDataCallback { @@ -278,7 +277,6 @@ private: bool m_typesResolved:1; QDeclarativeCompiledData *m_compiledData; - mutable QDeclarativeComponent *m_component; QList<TypeDataCallback *> m_callbacks; diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 4b1bbd6..06c8669 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE -class Q_DECLARATIVE_EXPORT QDeclarativeValueType : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueType : public QObject { Q_OBJECT public: @@ -81,7 +81,7 @@ public: virtual void setValue(QVariant) = 0; }; -class Q_DECLARATIVE_EXPORT QDeclarativeValueTypeFactory +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueTypeFactory { public: QDeclarativeValueTypeFactory(); diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 360186c..db90aff 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -185,12 +185,9 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, bindings = bindings.united(bindingSkipList); QObject *o = - types.at(instr.create.type).createInstance(ctxt, bindings); + types.at(instr.create.type).createInstance(ctxt, bindings, &vmeErrors); if (!o) { - if(types.at(instr.create.type).component) - vmeErrors << types.at(instr.create.type).component->errors(); - VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className))); } @@ -933,8 +930,9 @@ QList<QDeclarativeError> QDeclarativeVME::errors() const } QObject * -QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData *ctxt, - const QBitField &bindings) const +QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData *ctxt, + const QBitField &bindings, + QList<QDeclarativeError> *errors) const { if (type) { QObject *rv = 0; @@ -948,7 +946,7 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData return rv; } else { Q_ASSERT(component); - return QDeclarativeComponentPrivate::get(component)->create(ctxt, bindings); + return QDeclarativeComponentPrivate::begin(ctxt, 0, component, -1, -1, 0, errors, bindings); } } diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h index dbaf9e6..a90ba63 100644 --- a/src/declarative/qml/qmetaobjectbuilder_p.h +++ b/src/declarative/qml/qmetaobjectbuilder_p.h @@ -58,6 +58,8 @@ #include <QtCore/qdatastream.h> #include <QtCore/qmap.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_NAMESPACE class QMetaObjectBuilderPrivate; @@ -68,7 +70,7 @@ class QMetaPropertyBuilderPrivate; class QMetaEnumBuilder; class QMetaEnumBuilderPrivate; -class Q_DECLARATIVE_EXPORT QMetaObjectBuilder +class Q_DECLARATIVE_PRIVATE_EXPORT QMetaObjectBuilder { public: enum AddMember @@ -193,7 +195,7 @@ private: friend class QMetaEnumBuilder; }; -class Q_DECLARATIVE_EXPORT QMetaMethodBuilder +class Q_DECLARATIVE_PRIVATE_EXPORT QMetaMethodBuilder { public: QMetaMethodBuilder() : _mobj(0), _index(0) {} @@ -231,7 +233,7 @@ private: QMetaMethodBuilderPrivate *d_func() const; }; -class Q_DECLARATIVE_EXPORT QMetaPropertyBuilder +class Q_DECLARATIVE_PRIVATE_EXPORT QMetaPropertyBuilder { public: QMetaPropertyBuilder() : _mobj(0), _index(0) {} @@ -282,7 +284,7 @@ private: QMetaPropertyBuilderPrivate *d_func() const; }; -class Q_DECLARATIVE_EXPORT QMetaEnumBuilder +class Q_DECLARATIVE_PRIVATE_EXPORT QMetaEnumBuilder { public: QMetaEnumBuilder() : _mobj(0), _index(0) {} diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 8cb17e4..cd90417 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -63,7 +63,7 @@ QT_MODULE(Declarative) class QDeclarativeAbstractAnimationPrivate; class QDeclarativeAnimationGroup; -class Q_DECLARATIVE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation) @@ -165,7 +165,7 @@ protected: }; class QDeclarativeScriptActionPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeScriptAction : public QDeclarativeAbstractAnimation +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScriptAction : public QDeclarativeAbstractAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeScriptAction) diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h index 9801fb2..80ed984 100644 --- a/src/declarative/util/qdeclarativebehavior_p.h +++ b/src/declarative/util/qdeclarativebehavior_p.h @@ -57,7 +57,7 @@ QT_MODULE(Declarative) class QDeclarativeAbstractAnimation; class QDeclarativeBehaviorPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeBehavior : public QObject, public QDeclarativePropertyValueInterceptor +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBehavior : public QObject, public QDeclarativePropertyValueInterceptor { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeBehavior) diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h index e9673c8..90036f9 100644 --- a/src/declarative/util/qdeclarativelistmodel_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p.h @@ -64,7 +64,7 @@ class NestedListModel; class QDeclarativeListModelWorkerAgent; struct ModelNode; class FlatListScriptClass; -class Q_DECLARATIVE_EXPORT QDeclarativeListModel : public QListModelInterface +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeListModel : public QListModelInterface { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) diff --git a/src/declarative/util/qdeclarativeopenmetaobject_p.h b/src/declarative/util/qdeclarativeopenmetaobject_p.h index c18fa3d..dff6776 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject_p.h +++ b/src/declarative/util/qdeclarativeopenmetaobject_p.h @@ -42,10 +42,11 @@ #ifndef QDECLARATIVEOPENMETAOBJECT_H #define QDECLARATIVEOPENMETAOBJECT_H -#include <private/qdeclarativerefcount_p.h> #include <QtCore/QMetaObject> #include <QtCore/QObject> +#include <private/qdeclarativerefcount_p.h> +#include <private/qdeclarativeglobal_p.h> #include <private/qobject_p.h> QT_BEGIN_HEADER @@ -57,7 +58,7 @@ QT_MODULE(Declarative) class QDeclarativeEngine; class QMetaPropertyBuilder; class QDeclarativeOpenMetaObjectTypePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObjectType : public QDeclarativeRefCount +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeOpenMetaObjectType : public QDeclarativeRefCount { public: QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine); @@ -78,7 +79,7 @@ private: }; class QDeclarativeOpenMetaObjectPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObject : public QAbstractDynamicMetaObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeOpenMetaObject : public QAbstractDynamicMetaObject { public: QDeclarativeOpenMetaObject(QObject *, bool = true); diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 4fc52f5..a07b1bb 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -93,6 +93,7 @@ public: QDeclarativePixmapData *data; QDeclarativePixmapReader *reader; + QSize requestSize; bool loading; int redirectCount; @@ -366,7 +367,7 @@ void QDeclarativePixmapReader::networkRequestDone(QNetworkReply *reply) QByteArray all = reply->readAll(); QBuffer buff(&all); buff.open(QIODevice::ReadOnly); - if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->data->requestSize)) { + if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize)) { error = QDeclarativePixmapReply::Decoding; } } @@ -683,7 +684,7 @@ void QDeclarativePixmapStore::timerEvent(QTimerEvent *) } QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativePixmapData *d) -: data(d), reader(0), loading(false), redirectCount(0) +: data(d), reader(0), loading(false), redirectCount(0), requestSize(d->requestSize) { if (finishedIndex == -1) { finishedIndex = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()"); diff --git a/src/declarative/util/qdeclarativepropertychanges_p.h b/src/declarative/util/qdeclarativepropertychanges_p.h index 199928f..449574c 100644 --- a/src/declarative/util/qdeclarativepropertychanges_p.h +++ b/src/declarative/util/qdeclarativepropertychanges_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativePropertyChangesPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativePropertyChanges : public QDeclarativeStateOperation +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyChanges : public QDeclarativeStateOperation { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativePropertyChanges) diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index a0ab11b..d01af4e 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -45,6 +45,7 @@ #include <qdeclarative.h> #include <qdeclarativeproperty.h> #include <QtCore/qobject.h> +#include <private/qdeclarativeglobal_p.h> QT_BEGIN_HEADER @@ -56,7 +57,7 @@ class QDeclarativeActionEvent; class QDeclarativeAbstractBinding; class QDeclarativeBinding; class QDeclarativeExpression; -class Q_DECLARATIVE_EXPORT QDeclarativeAction +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAction { public: QDeclarativeAction(); @@ -113,7 +114,7 @@ public: class QDeclarativeStateGroup; class QDeclarativeState; class QDeclarativeStateOperationPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeStateOperation : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeStateOperation : public QObject { Q_OBJECT public: @@ -138,7 +139,7 @@ typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions; class QDeclarativeTransition; class QDeclarativeStatePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeState : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeState : public QObject { Q_OBJECT diff --git a/src/declarative/util/qdeclarativestategroup_p.h b/src/declarative/util/qdeclarativestategroup_p.h index cac23f4..0222cf2 100644 --- a/src/declarative/util/qdeclarativestategroup_p.h +++ b/src/declarative/util/qdeclarativestategroup_p.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeStateGroupPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus { Q_OBJECT Q_INTERFACES(QDeclarativeParserStatus) diff --git a/src/declarative/util/qdeclarativetimer_p.h b/src/declarative/util/qdeclarativetimer_p.h index 08c3d4e..ee3d038 100644 --- a/src/declarative/util/qdeclarativetimer_p.h +++ b/src/declarative/util/qdeclarativetimer_p.h @@ -47,6 +47,8 @@ #include <QtCore/qobject.h> #include <QtCore/qabstractanimation.h> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -54,7 +56,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeTimerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarativeParserStatus +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeTimer : public QObject, public QDeclarativeParserStatus { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeTimer) diff --git a/src/declarative/util/qdeclarativetransition_p.h b/src/declarative/util/qdeclarativetransition_p.h index fc7a577..5b20cb2 100644 --- a/src/declarative/util/qdeclarativetransition_p.h +++ b/src/declarative/util/qdeclarativetransition_p.h @@ -57,7 +57,7 @@ QT_MODULE(Declarative) class QDeclarativeAbstractAnimation; class QDeclarativeTransitionPrivate; class QDeclarativeTransitionManager; -class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeTransition : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeTransition) diff --git a/src/declarative/util/qlistmodelinterface_p.h b/src/declarative/util/qlistmodelinterface_p.h index 8c8ebb3..8b62fc4 100644 --- a/src/declarative/util/qlistmodelinterface_p.h +++ b/src/declarative/util/qlistmodelinterface_p.h @@ -45,13 +45,15 @@ #include <QtCore/QHash> #include <QtCore/QVariant> +#include <private/qdeclarativeglobal_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QListModelInterface : public QObject { Q_OBJECT public: |