From 9ec14dcfa1d53b209e7a34b6163aac876771751e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 16 Apr 2010 11:40:20 +1000 Subject: Class documentation fixes for declarative. --- .../qdeclarativenetworkaccessmanagerfactory.cpp | 5 ++++ src/declarative/qml/qdeclarativeparserstatus.cpp | 32 +++++++++++++++++++-- src/declarative/qml/qdeclarativescriptstring.cpp | 33 ++++++++++++++-------- src/declarative/util/qdeclarativepropertymap.cpp | 4 +-- src/declarative/util/qdeclarativeview.cpp | 6 ++-- 5 files changed, 62 insertions(+), 18 deletions(-) diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp index 9dd7d39..f5f1a1f 100644 --- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp +++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp @@ -56,12 +56,17 @@ QT_BEGIN_NAMESPACE To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and implement the create() method. + To use a factory, assign it to the relevant QDeclarativeEngine using + QDeclarativeEngine::setNetworkAccessManagerFactory(). + If the created QNetworkAccessManager becomes invalid, due to a change in proxy settings, for example, call the invalidate() method. This will cause all QNetworkAccessManagers to be recreated. Note: the create() method may be called by multiple threads, so ensure the implementation of this method is reentrant. + + \sa QDeclarativeEngine::setNetworkAccessManagerFactory() */ /*! diff --git a/src/declarative/qml/qdeclarativeparserstatus.cpp b/src/declarative/qml/qdeclarativeparserstatus.cpp index ec6260e..978bfb4 100644 --- a/src/declarative/qml/qdeclarativeparserstatus.cpp +++ b/src/declarative/qml/qdeclarativeparserstatus.cpp @@ -45,8 +45,36 @@ QT_BEGIN_NAMESPACE /*! \class QDeclarativeParserStatus - \since 4.7 - \brief The QDeclarativeParserStatus class provides updates on the parser state. + \since 4.7 + \brief The QDeclarativeParserStatus class provides updates on the QML parser state. + + QDeclarativeParserStatus provides a mechanism for classes instantiated by + a QDeclarativeEngine to receive notification at key points in their creation. + + This class is often used for optimization purposes, as it allows you to defer an + expensive operation until after all the properties have been set on an + object. For example, QML's \l {Text} element uses the parser status + to defer text layout until all of its properties have been set (we + don't want to layout when the \c text is assigned, and then relayout + when the \c font is assigned, and relayout again when the \c width is assigned, + and so on). + + To use QDeclarativeParserStatus, you must inherit both a QObject-derived class + and QDeclarativeParserStatus, and use the Q_INTERFACES() macro. + + \code + class MyObject : public QObject, public QDeclarativeParserStatus + { + Q_OBJECT + Q_INTERFACES(QDeclarativeParserStatus) + + public: + MyObject(QObject *parent = 0); + ... + void classBegin(); + void componentComplete(); + } + \endcode */ /*! \internal */ diff --git a/src/declarative/qml/qdeclarativescriptstring.cpp b/src/declarative/qml/qdeclarativescriptstring.cpp index 5b9afe9..8f717d1 100644 --- a/src/declarative/qml/qdeclarativescriptstring.cpp +++ b/src/declarative/qml/qdeclarativescriptstring.cpp @@ -55,24 +55,35 @@ public: /*! \class QDeclarativeScriptString - \since 4.7 +\since 4.7 \brief The QDeclarativeScriptString class encapsulates a script and its context. -The QDeclarativeScriptString is used by properties that want to accept a script "assignment" from QML. +QDeclarativeScriptString is used to create QObject properties that accept a script "assignment" from QML. -Normally, the following code would result in a binding being established for the \c script -property. If the property had a type of QDeclarativeScriptString, the script - \e {console.log(1921)} - itself -would be passed to the property and it could choose how to handle it. +Normally, the following QML would result in a binding being established for the \c script +property; i.e. \c script would be assigned the value obtained from running \c {myObj.value = Math.max(myValue, 100)} -\code +\qml MyType { - script: console.log(1921) + script: myObj.value = Math.max(myValue, 100) } +\endqml + +If instead the property had a type of QDeclarativeScriptString, +the script itself -- \e {myObj.value = Math.max(myValue, 100)} -- would be passed to the \c script property +and the class could choose how to handle it. Typically, the class will evaluate +the script at some later time using a QDeclarativeExpression. + +\code +QDeclarativeExpression expr(scriptString.context(), scriptString.script(), scriptStr.scopeObject()); +expr.value(); \endcode + +\sa QDeclarativeExpression */ /*! -Construct an empty instance. +Constructs an empty instance. */ QDeclarativeScriptString::QDeclarativeScriptString() : d(new QDeclarativeScriptStringPrivate) @@ -80,7 +91,7 @@ QDeclarativeScriptString::QDeclarativeScriptString() } /*! -Copy \a other. +Copies \a other. */ QDeclarativeScriptString::QDeclarativeScriptString(const QDeclarativeScriptString &other) : d(other.d) @@ -95,7 +106,7 @@ QDeclarativeScriptString::~QDeclarativeScriptString() } /*! -Assign \a other to this. +Assigns \a other to this. */ QDeclarativeScriptString &QDeclarativeScriptString::operator=(const QDeclarativeScriptString &other) { @@ -104,7 +115,7 @@ QDeclarativeScriptString &QDeclarativeScriptString::operator=(const QDeclarative } /*! -Return the context for the script. +Returns the context for the script. */ QDeclarativeContext *QDeclarativeScriptString::context() const { diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp index 0e477b1..c8161a7 100644 --- a/src/declarative/util/qdeclarativepropertymap.cpp +++ b/src/declarative/util/qdeclarativepropertymap.cpp @@ -98,7 +98,7 @@ void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilde /*! \class QDeclarativePropertyMap \since 4.7 - \brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in bindings. + \brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in QML bindings. QDeclarativePropertyMap provides a convenient way to expose domain data to the UI layer. The following example shows how you might declare data in C++ and then @@ -112,7 +112,7 @@ void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilde ownerData.insert("phone", QVariant(QString("555-5555"))); //expose it to the UI layer - QDeclarativeContext *ctxt = view->bindContext(); + QDeclarativeContext *ctxt = view->rootContext(); ctxt->setProperty("owner", &data); \endcode diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index c0425ef..f786898 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -338,15 +338,15 @@ QDeclarativeContext* QDeclarativeView::rootContext() \value Null This QDeclarativeView has no source set. \value Ready This QDeclarativeView has loaded and created the QML component. \value Loading This QDeclarativeView is loading network data. - \value Error An error has occured. Calling errorDescription() to retrieve a description. + \value Error An error has occured. Call errorDescription() to retrieve a description. */ /*! \enum QDeclarativeView::ResizeMode This enum specifies how to resize the view. - \value SizeViewToRootObject - \value SizeRootObjectToView + \value SizeViewToRootObject The view resizes with the root item in the QML. + \value SizeRootObjectToView The view will automatically resize the root item to the size of the view. */ /*! -- cgit v0.12 From de435ffb63c39bc44045ab4e96282c1bc1836feb Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 16 Apr 2010 12:41:46 +1000 Subject: Cleanup --- src/declarative/qml/qdeclarativeengine.cpp | 4 ++-- src/declarative/qml/qdeclarativeengine_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 96145fb..76cd810 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1284,7 +1284,7 @@ QScriptValue QDeclarativeEnginePrivate::consoleLog(QScriptContext *ctxt, QScript return e->newVariant(QVariant(true)); } -void QDeclarativeEnginePrivate::sendQuit () +void QDeclarativeEnginePrivate::sendQuit() { Q_Q(QDeclarativeEngine); emit q->quit(); @@ -1293,7 +1293,7 @@ void QDeclarativeEnginePrivate::sendQuit () QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e) { QDeclarativeEnginePrivate *qe = get (e); - qe->sendQuit (); + qe->sendQuit(); return QScriptValue(); } diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index b3bba43..43d329c 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -311,7 +311,7 @@ public: QScriptValue scriptValueFromVariant(const QVariant &); QVariant scriptValueToVariant(const QScriptValue &, int hint = QVariant::Invalid); - void sendQuit (); + void sendQuit(); static QScriptValue qmlScriptObject(QObject*, QDeclarativeEngine*); -- cgit v0.12 From 575f0064bd91e26daa75805c142c10a04a32c2fd Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 13:25:35 +1000 Subject: Avoid calling QGraphicsItem::setTransformOriginPoint() until needed Task-number: QTBUG-9772 Reviewed-by: Alexis --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 24 ++++++++++++++++++---- src/declarative/graphicsitems/qdeclarativeitem_p.h | 6 +++++- src/gui/graphicsview/qgraphicsitem.cpp | 10 +++++++++ src/gui/graphicsview/qgraphicsitem_p.h | 1 + 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 86dbaf0..0e4e327 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1794,9 +1794,13 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, if (transformOrigin() != QDeclarativeItem::TopLeft && (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) { - QPointF origin = d->computeTransformOrigin(); - if (transformOriginPoint() != origin) - setTransformOriginPoint(origin); + if (d->transformData) { + QPointF origin = d->computeTransformOrigin(); + if (transformOriginPoint() != origin) + setTransformOriginPoint(origin); + } else { + d->transformOriginDirty = true; + } } if (newGeometry.x() != oldGeometry.x()) @@ -2656,11 +2660,23 @@ void QDeclarativeItem::setTransformOrigin(TransformOrigin origin) Q_D(QDeclarativeItem); if (origin != d->origin) { d->origin = origin; - QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + if (d->transformData) + QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + else + d->transformOriginDirty = true; emit transformOriginChanged(d->origin); } } +void QDeclarativeItemPrivate::transformChanged() +{ + Q_Q(QDeclarativeItem); + if (transformOriginDirty) { + q->QGraphicsItem::setTransformOriginPoint(computeTransformOrigin()); + transformOriginDirty = false; + } +} + /*! \property QDeclarativeItem::smooth \brief whether the item is smoothly transformed. diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index cf138c3..3f5bf1a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -116,7 +116,7 @@ public: _stateGroup(0), origin(QDeclarativeItem::Center), widthValid(false), heightValid(false), _componentComplete(true), _keepMouse(false), - smooth(false), keyHandler(0), + smooth(false), transformOriginDirty(true), keyHandler(0), mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; @@ -233,6 +233,7 @@ public: bool _componentComplete:1; bool _keepMouse:1; bool smooth:1; + bool transformOriginDirty : 1; QDeclarativeItemKeyFilter *keyHandler; @@ -269,6 +270,9 @@ public: } } + // Reimplemented from QGraphicsItemPrivate + virtual void transformChanged(); + virtual void focusChanged(bool); static int consistentTime; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9759b39..e290c7e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1237,6 +1237,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } dirtySceneTransform = 1; + if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData))) + transformChanged(); // Restore the sub focus chain. if (subFocusItem) { @@ -3622,6 +3624,7 @@ void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform) q_ptr->prepareGeometryChange(); transformData->transform = transform; dirtySceneTransform = 1; + transformChanged(); } /*! @@ -3812,6 +3815,8 @@ void QGraphicsItem::setRotation(qreal angle) if (d_ptr->isObject) emit static_cast(this)->rotationChanged(); + + d_ptr->transformChanged(); } /*! @@ -3876,6 +3881,8 @@ void QGraphicsItem::setScale(qreal factor) if (d_ptr->isObject) emit static_cast(this)->scaleChanged(); + + d_ptr->transformChanged(); } @@ -3931,6 +3938,7 @@ void QGraphicsItem::setTransformations(const QList &transf transformations.at(i)->d_func()->setItem(this); d_ptr->transformData->onlyTransform = false; d_ptr->dirtySceneTransform = 1; + d_ptr->transformChanged(); } /*! @@ -3947,6 +3955,7 @@ void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) t->d_func()->setItem(q); transformData->onlyTransform = false; dirtySceneTransform = 1; + transformChanged(); } /*! @@ -3963,6 +3972,7 @@ void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) t->d_func()->setItem(q); transformData->onlyTransform = false; dirtySceneTransform = 1; + transformChanged(); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index f922842..8c7fbb4 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -284,6 +284,7 @@ public: void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); bool discardUpdateRequest(bool ignoreVisibleBit = false, bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; + virtual void transformChanged() {} int depth() const; #ifndef QT_NO_GRAPHICSEFFECT enum InvalidateReason { -- cgit v0.12 From 9c3acf1d307257df02a9ba0b6de6077881bb687b Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 16 Apr 2010 13:41:35 +1000 Subject: Do not set a font pixel size of 0. --- src/declarative/qml/qdeclarativevaluetype.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 352a6c0..c5f6d6a 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -55,13 +55,13 @@ int qmlRegisterValueTypeEnums(const char *qmlName) QByteArray pointerName(name + '*'); QDeclarativePrivate::RegisterType type = { - 0, + 0, qRegisterMetaType(pointerName.constData()), 0, 0, 0, "Qt", 4, 6, qmlName, &T::staticMetaObject, - 0, 0, + 0, 0, 0, 0, 0, @@ -712,7 +712,7 @@ int QDeclarativeFontValueType::pixelSize() const void QDeclarativeFontValueType::setPixelSize(int size) { - if (size >=0) { + if (size >0) { if (pointSizeSet) qWarning() << "Both point size and pixel size set. Using pixel size."; font.setPixelSize(size); -- cgit v0.12 From 5595ad768309b27c2c20376105f8715082b616bf Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 13:48:58 +1000 Subject: Add parent property to Timer Task-number: QTBUG-9949 --- src/declarative/util/qdeclarativetimer_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/util/qdeclarativetimer_p.h b/src/declarative/util/qdeclarativetimer_p.h index d1e6630..08c3d4e 100644 --- a/src/declarative/util/qdeclarativetimer_p.h +++ b/src/declarative/util/qdeclarativetimer_p.h @@ -63,6 +63,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarati Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) + Q_PROPERTY(QObject *parent READ parent CONSTANT) public: QDeclarativeTimer(QObject *parent=0); -- cgit v0.12 From 8ff39e55286e4ce3f01472fafa06941c9e9537fd Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 14:17:23 +1000 Subject: Add test for QTBUG-9949 Task-number: QTBUG-9949 --- .../qdeclarativetimer/tst_qdeclarativetimer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp index a08a91c..da2d173 100644 --- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include class tst_qdeclarativetimer : public QObject @@ -60,6 +61,7 @@ private slots: void triggeredOnStartRepeat(); void changeDuration(); void restart(); + void parentProperty(); }; class TimerHelper : public QObject @@ -317,6 +319,21 @@ void tst_qdeclarativetimer::restart() delete timer; } +void tst_qdeclarativetimer::parentProperty() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import Qt 4.7\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QDeclarativeTimer *timer = item->findChild("timer"); + QVERIFY(timer != 0); + + QVERIFY(timer->isRunning()); + + delete timer; +} + QTEST_MAIN(tst_qdeclarativetimer) #include "tst_qdeclarativetimer.moc" -- cgit v0.12 From d6ba9ff7e3d7e67d3718ffa7317bfc2d3941a2bb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 14:34:19 +1000 Subject: Doc: make note about using clip: true in views slightly more prominent. --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativepathview.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 562ba2a..a3d585a 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -885,7 +885,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m In this case ListModel is a handy way for us to test our UI. In practice the model would be implemented in C++, or perhaps via a SQL data source. - Note that views do not enable \e clip automatically. If the view + \bold Note that views do not enable \e clip automatically. If the view is not clipped by another item or the screen, it will be necessary to set \e {clip: true} in order to have the out of view items clipped nicely. diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 307c0a7..80db730 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1286,7 +1286,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m In this case ListModel is a handy way for us to test our UI. In practice the model would be implemented in C++, or perhaps via a SQL data source. - Note that views do not enable \e clip automatically. If the view + \bold Note that views do not enable \e clip automatically. If the view is not clipped by another item or the screen, it will be necessary to set \e {clip: true} in order to have the out of view items clipped nicely. diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 4aaa28d..d0a3cd1 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -314,7 +314,7 @@ void QDeclarativePathViewPrivate::regenerate() \image pathview.gif - Note that views do not enable \e clip automatically. If the view + \bold Note that views do not enable \e clip automatically. If the view is not clipped by another item or the screen, it will be necessary to set \e {clip: true} in order to have the out of view items clipped nicely. -- cgit v0.12 From 348d1f6d421a6e23b769af99608fa6d81631a6c3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Apr 2010 14:41:00 +1000 Subject: Throw exceptions on programming errors for global functions. Task-number: QTBUG-7897 --- src/declarative/qml/qdeclarativeengine.cpp | 77 ++++++++++-------- src/testlib/qtestlightxmlstreamer.cpp | 3 +- src/testlib/qtestlogger.cpp | 3 + src/testlib/qtestxmlstreamer.cpp | 3 +- .../qdeclarativeqt/data/createComponent.qml | 9 +- .../qdeclarativeqt/data/createQmlObject.qml | 25 +++--- .../auto/declarative/qdeclarativeqt/data/hsla.qml | 4 +- .../auto/declarative/qdeclarativeqt/data/rgba.qml | 4 +- .../qdeclarativeqt/tst_qdeclarativeqt.cpp | 95 ++++++++++++++-------- 9 files changed, 129 insertions(+), 94 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 96145fb..8e19240 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -957,7 +957,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS Q_ASSERT(context); if(ctxt->argumentCount() != 1) { - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); }else{ QString arg = ctxt->argument(0).toString(); if (arg.isEmpty()) @@ -977,7 +977,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QDeclarativeEngine* activeEngine = activeEnginePriv->q_func(); if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 or 3 parameters")); QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt); Q_ASSERT(context); @@ -997,35 +997,30 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); if(!parentArg) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("parent object not found")); QDeclarativeComponent component(activeEngine); component.setData(qml.toUtf8(), url); if(component.isError()) { QList errors = component.errors(); - qWarning().nospace() << "QDeclarativeEngine::createQmlObject():"; + QString errstr = QLatin1String("Qt.createQmlObject(): "); foreach (const QDeclarativeError &error, errors) - qWarning().nospace() << " " << error; - - return engine->nullValue(); + errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); + return ctxt->throwError(errstr); } - if (!component.isReady()) { - qWarning().nospace() << "QDeclarativeEngine::createQmlObject(): Component is not ready"; - - return engine->nullValue(); - } + if (!component.isReady()) + return ctxt->throwError(QDeclarativeEngine::tr("Qt.createQmlObject(): component is not ready")); QObject *obj = component.create(context->asQDeclarativeContext()); if(component.isError()) { QList errors = component.errors(); - qWarning().nospace() << "QDeclarativeEngine::createQmlObject():"; + QString errstr = QLatin1String("Qt.createQmlObject(): "); foreach (const QDeclarativeError &error, errors) - qWarning().nospace() << " " << error; - - return engine->nullValue(); + errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); + return ctxt->throwError(errstr); } Q_ASSERT(obj); @@ -1051,7 +1046,7 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 3) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); qsreal z = ctxt->argument(2).toNumber(); @@ -1062,7 +1057,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QDate date = ctxt->argument(0).toDateTime().date(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1073,7 +1068,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid date format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1082,7 +1077,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QTime date = ctxt->argument(0).toDateTime().time(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1093,7 +1088,7 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid time format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1102,7 +1097,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr { int argCount = ctxt->argumentCount(); if(argCount == 0 || argCount > 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 or 2 parameters")); QDateTime date = ctxt->argument(0).toDateTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; @@ -1113,7 +1108,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } else if (ctxt->argument(1).isNumber()) { enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); } else - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("invalid datetiem format")); } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } @@ -1122,14 +1117,20 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters")); qsreal r = ctxt->argument(0).toNumber(); qsreal g = ctxt->argument(1).toNumber(); qsreal b = ctxt->argument(2).toNumber(); qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1; - if (r < 0 || r > 1 || g < 0 || g > 1 || b < 0 || b > 1 || a < 0 || a > 1) - return engine->nullValue(); + if (r < 0.0) r=0.0; + if (r > 1.0) r=1.0; + if (g < 0.0) g=0.0; + if (g > 1.0) g=1.0; + if (b < 0.0) b=0.0; + if (b > 1.0) b=1.0; + if (a < 0.0) a=0.0; + if (a > 1.0) a=1.0; return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a))); } @@ -1138,14 +1139,20 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine { int argCount = ctxt->argumentCount(); if(argCount < 3 || argCount > 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 3 or 4 parameters")); qsreal h = ctxt->argument(0).toNumber(); qsreal s = ctxt->argument(1).toNumber(); qsreal l = ctxt->argument(2).toNumber(); qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1; - if (h < 0 || h > 1 || s < 0 || s > 1 || l < 0 || l > 1 || a < 0 || a > 1) - return engine->nullValue(); + if (h < 0.0) h=0.0; + if (h > 1.0) h=1.0; + if (s < 0.0) s=0.0; + if (s > 1.0) s=1.0; + if (l < 0.0) l=0.0; + if (l > 1.0) l=1.0; + if (a < 0.0) a=0.0; + if (a > 1.0) a=1.0; return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a))); } @@ -1153,7 +1160,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 4) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 4 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); @@ -1169,7 +1176,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y))); @@ -1178,7 +1185,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); qsreal w = ctxt->argument(0).toNumber(); qsreal h = ctxt->argument(1).toNumber(); return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h))); @@ -1187,7 +1194,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1206,7 +1213,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 1) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 1 parameter")); QVariant v = ctxt->argument(0).toVariant(); QColor color; if (v.userType() == QVariant::Color) @@ -1300,7 +1307,7 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) - return engine->nullValue(); + return ctxt->throwError(QDeclarativeEngine::tr("expected 2 parameters")); //get color QVariant v = ctxt->argument(0).toVariant(); QColor color; diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 0ac9ea8..8c22a4f 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -87,12 +87,13 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBu QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "\n \n\n", + QTest::qt_asprintf(formatted, "\n %s\n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 6c76388..79bb84c 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -318,6 +318,9 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char break; } + const char *tag = QTestResult::currentDataTag(); + if (tag) + errorElement->addAttribute(QTest::AI_Tag, tag); errorElement->addAttribute(QTest::AI_Type, typeBuf); errorElement->addAttribute(QTest::AI_Description, message); diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index b9946e5..9addb31 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -111,12 +111,13 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "\n \n\n", + QTest::qt_asprintf(formatted, "\n %s\n \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + element->attributeValue(QTest::AI_Tag) ? element->attributeValue(QTest::AI_Tag) : "", cdataDesc.constData()); break; } diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml index d9b70ec..412c467 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml @@ -1,19 +1,16 @@ import Qt 4.6 QtObject { - property bool incorrectArgCount1: false - property bool incorrectArgCount2: false property bool emptyArg: false property string relativeUrl property string absoluteUrl + property QtObject incorectArgCount1: createComponent() + property QtObject incorectArgCount2: createComponent("main.qml", 10) + Component.onCompleted: { - // Test that using incorrect argument count returns a null object - incorrectArgCount1 = (createComponent() == null); - incorrectArgCount2 = (createComponent("main.qml", 10) == null); emptyArg = (createComponent("") == null); - var r = createComponent("createComponentData.qml"); relativeUrl = r.url; diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml index 54a3e7d..a7edb2b 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml @@ -3,25 +3,26 @@ import Qt 4.6 Item { id: root - property bool incorrectArgCount1: false - property bool incorrectArgCount2: false + // errors resulting in exceptions + property QtObject incorrectArgCount1: createQmlObject() + property QtObject incorrectArgCount2: createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10) + property QtObject noParent: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0) + property QtObject notAvailable: createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root) + property QtObject errors: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") + property bool emptyArg: false - property bool noParent: false - property bool notAvailable: false property bool runtimeError: false - property bool errors: false property bool success: false Component.onCompleted: { - // errors - incorrectArgCount1 = (createQmlObject() == null); - incorrectArgCount2 = (createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10) == null); + // errors resulting in nulls emptyArg = (createQmlObject("", root) == null); - errors = (createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") == null); - noParent = (createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0) == null); - notAvailable = (createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root) == null); - runtimeError = (createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) == null); + try { + createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) + } catch (error) { + console.log("RunTimeError: ",error.message); + } var o = createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\n}", root); success = (o.test == 13); diff --git a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml index df51ccd..142410b 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml @@ -5,7 +5,7 @@ QtObject { property color test2: Qt.hsla(1, 0.5, 0.3); property color test3: Qt.hsla(1, 1); property color test4: Qt.hsla(1, 1, 1, 1, 1); - property color test5: Qt.hsla(1.2, 1, 1); - property color test6: Qt.hsla(-0.1, 1, 1); + property color test5: Qt.hsla(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.hsla(-0.1, -0.2, -0.3, -0.4); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml index 6dd6565..66305a4 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml @@ -5,6 +5,6 @@ QtObject { property color test2: Qt.rgba(1, 0.5, 0.3); property color test3: Qt.rgba(1, 1); property color test4: Qt.rgba(1, 1, 1, 1, 1); - property color test5: Qt.rgba(1.2, 1, 1); - property color test6: Qt.rgba(-0.1, 1, 1); + property color test5: Qt.rgba(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.rgba(-0.1, -0.2, -0.3, -0.4); } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 98f1200..4d22b0a 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -102,14 +102,10 @@ void tst_qdeclarativeqt::rgba() { QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml")); - QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; - QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QObject *object = component.create(); QVERIFY(object != 0); @@ -119,8 +115,8 @@ void tst_qdeclarativeqt::rgba() QCOMPARE(qvariant_cast(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1)); QCOMPARE(qvariant_cast(object->property("test3")), QColor()); QCOMPARE(qvariant_cast(object->property("test4")), QColor()); - QCOMPARE(qvariant_cast(object->property("test5")), QColor()); - QCOMPARE(qvariant_cast(object->property("test6")), QColor()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0)); delete object; } @@ -129,14 +125,10 @@ void tst_qdeclarativeqt::hsla() { QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml")); - QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; - QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QObject *object = component.create(); QVERIFY(object != 0); @@ -145,8 +137,8 @@ void tst_qdeclarativeqt::hsla() QCOMPARE(qvariant_cast(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1)); QCOMPARE(qvariant_cast(object->property("test3")), QColor()); QCOMPARE(qvariant_cast(object->property("test4")), QColor()); - QCOMPARE(qvariant_cast(object->property("test5")), QColor()); - QCOMPARE(qvariant_cast(object->property("test6")), QColor()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor::fromHslF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast(object->property("test6")), QColor::fromHslF(0, 0, 0, 0)); delete object; } @@ -154,6 +146,12 @@ void tst_qdeclarativeqt::hsla() void tst_qdeclarativeqt::rect() { QDeclarativeComponent component(&engine, TEST_FILE("rect.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 4 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 4 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -169,6 +167,12 @@ void tst_qdeclarativeqt::rect() void tst_qdeclarativeqt::point() { QDeclarativeComponent component(&engine, TEST_FILE("point.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -183,6 +187,12 @@ void tst_qdeclarativeqt::point() void tst_qdeclarativeqt::size() { QDeclarativeComponent component(&engine, TEST_FILE("size.qml")); + + QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -198,6 +208,12 @@ void tst_qdeclarativeqt::size() void tst_qdeclarativeqt::vector() { QDeclarativeComponent component(&engine, TEST_FILE("vector.qml")); + + QString warning1 = component.url().toString() + ":6: Error: expected 3 parameters"; + QString warning2 = component.url().toString() + ":7: Error: expected 3 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -212,6 +228,12 @@ void tst_qdeclarativeqt::vector() void tst_qdeclarativeqt::lighter() { QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); + + QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -228,6 +250,12 @@ void tst_qdeclarativeqt::lighter() void tst_qdeclarativeqt::darker() { QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); + + QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); @@ -245,8 +273,9 @@ void tst_qdeclarativeqt::tint() { QDeclarativeComponent component(&engine, TEST_FILE("tint.qml")); - QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor"; - QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor"; + QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; + QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -305,13 +334,15 @@ void tst_qdeclarativeqt::md5() void tst_qdeclarativeqt::createComponent() { QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml")); + + QString warning1 = component.url().toString() + ":9: Error: expected 1 parameter"; + QString warning2 = component.url().toString() + ":10: Error: expected 1 parameter"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(object->property("incorrectArgCount1").toBool(), true); - QCOMPARE(object->property("incorrectArgCount2").toBool(), true); - QCOMPARE(object->property("emptyArg").toBool(), true); - QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString()); @@ -322,30 +353,24 @@ void tst_qdeclarativeqt::createQmlObject() { QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); - QString warning1 = "QDeclarativeEngine::createQmlObject():"; - QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name"; - QString warning3 = "QDeclarativeEngine::createQmlObject():"; - QString warning4 = " " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type"; - QString warning5 = "QDeclarativeEngine::createQmlObject():"; - QString warning6 = " " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method"; + QString warning1 = component.url().toString() + ":7: Error: expected 2 or 3 parameters"; + QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n"; + QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n"; + QString warning4 = component.url().toString()+ ":9: Error: parent object not found"; + QString warning5 = component.url().toString()+ ":8: Error: expected 2 or 3 parameters"; + QString warning6 = "RunTimeError: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6)); + QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6)); QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(object->property("incorrectArgCount1").toBool(), true); - QCOMPARE(object->property("incorrectArgCount2").toBool(), true); QCOMPARE(object->property("emptyArg").toBool(), true); - QCOMPARE(object->property("errors").toBool(), true); - QCOMPARE(object->property("noParent").toBool(), true); - QCOMPARE(object->property("notAvailable").toBool(), true); - QCOMPARE(object->property("runtimeError").toBool(), true); QCOMPARE(object->property("success").toBool(), true); QDeclarativeItem *item = qobject_cast(object); -- cgit v0.12 From 25419577354f0a6af77e49acd860a84fc4aa26ae Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Apr 2010 14:44:50 +1000 Subject: clean up --- tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml index a7edb2b..8e6c58e 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml @@ -11,7 +11,6 @@ Item { property QtObject errors: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") property bool emptyArg: false - property bool runtimeError: false property bool success: false -- cgit v0.12 From 91838257f36ef3431143d59871ecb62def735fe4 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 16 Apr 2010 14:56:36 +1000 Subject: Cleanup photoviewer demo. --- demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml | 6 ++++-- demos/declarative/photoviewer/PhotoViewerCore/Button.qml | 2 +- demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml index cd9ecbc..d39b7bc 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -77,10 +77,12 @@ Component { } ] - GridView.onAdd: NumberAnimation { target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0 } + GridView.onAdd: NumberAnimation { + target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: "OutQuad" + } GridView.onRemove: SequentialAnimation { PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } - NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0 } + NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: "OutQuad" } PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } } diff --git a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml index fd1fae9..c681064 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml @@ -4,7 +4,7 @@ Item { id: container property alias label: labelText.text - property string tint: "" + property color tint: "#FFFFFFFF" signal clicked width: labelText.width + 70 ; height: labelText.height + 18 diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml index e435425..ccfda02 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml @@ -4,7 +4,7 @@ Item { id: container property string label - property string tint: "" + property color tint: "#FFFFFFFF" signal clicked signal labelChanged(string label) -- cgit v0.12 From e1b1b11afbddbe260d4de61f20181ffd3b941996 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 16 Apr 2010 14:32:02 +1000 Subject: Add QML imports to s60installs.pro Task-number: QTBUG-9784 Reviewed-by: Martin Jones --- src/s60installs/s60installs.pro | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index dfce7d2..c3809b2 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -143,6 +143,25 @@ symbian: { contains(QT_CONFIG, declarative): { qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtDeclarative$${QT_LIBINFIX}.dll + + widgetImport.sources = widgets.dll $$QT_BUILD_TREE/src/imports/widgets/qmldir + widgetImport.path = $$QT_IMPORTS_BASE_DIR/Qt/widgets + DEPLOYMENT += widgetImport + + particlesImport.sources = particles.dll $$QT_BUILD_TREE/src/imports/particles/qmldir + particlesImport.path = $$QT_IMPORTS_BASE_DIR/Qt/labs/particles + DEPLOYMENT += particlesImport + + contains(QT_CONFIG, webkit): { + webkitImport.sources = webkitqmlplugin.dll $$QT_BUILD_TREE/src/imports/webkit/qmldir + webkitImport.path = $$QT_IMPORTS_BASE_DIR/org/webkit + DEPLOYMENT += webkitImport + } + contains(QT_CONFIG, multimedia): { + multimediaImport.sources = multimedia.dll $$QT_BUILD_TREE/src/imports/multimedia/qmldir + multimediaImport.path = $$QT_IMPORTS_BASE_DIR/Qt/multimedia + DEPLOYMENT += multimediaImport + } } graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems -- cgit v0.12 From 8693ed5a3fd0814802613c5a8a78b6802751bd0f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 16 Apr 2010 14:34:36 +1000 Subject: Simplify QML import plugin deployment lines Task-number: Reviewed-by: Martin Jones --- src/imports/gestures/gestures.pro | 3 +-- src/imports/multimedia/multimedia.pro | 3 +-- src/imports/particles/particles.pro | 3 +-- src/imports/webkit/webkit.pro | 3 +-- src/imports/widgets/widgets.pro | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro index b9c5b4e..f55c00e 100644 --- a/src/imports/gestures/gestures.pro +++ b/src/imports/gestures/gestures.pro @@ -17,8 +17,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = gesturesqmlplugin.dll \ - qmldir + importFiles.sources = gesturesqmlplugin.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index 92f7ec4..c366e54 100644 --- a/src/imports/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -27,8 +27,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/multimedia.dll \ - qmldir + importFiles.sources = multimedia.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index 58bfe05..79ac543 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -21,8 +21,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/particles.dll \ - qmldir + importFiles.sources = particles.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro index 62db9ac..77cbc4d 100644 --- a/src/imports/webkit/webkit.pro +++ b/src/imports/webkit/webkit.pro @@ -18,8 +18,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/webkitqmlplugin.dll \ - qmldir + importFiles.sources = webkitqmlplugin.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro index f26e4b9..234ff1e 100644 --- a/src/imports/widgets/widgets.pro +++ b/src/imports/widgets/widgets.pro @@ -21,8 +21,7 @@ symbian:{ load(data_caging_paths) include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - importFiles.sources = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/widgets.dll \ - qmldir + importFiles.sources = widgets.dll qmldir importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH DEPLOYMENT = importFiles -- cgit v0.12 From ba3f33401c97c5517abe19f4ea6f6307e4374c6c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 16 Apr 2010 14:54:19 +1000 Subject: More class documentation fixes for declarative. --- src/declarative/qml/qdeclarativecontext.cpp | 7 ++- src/declarative/qml/qdeclarativeerror.cpp | 51 +++++++++++++++------- .../qml/qdeclarativeextensionplugin.cpp | 11 ++++- src/declarative/qml/qdeclarativeimageprovider.cpp | 22 +++++++--- src/declarative/qml/qdeclarativeimageprovider.h | 2 +- src/declarative/qml/qdeclarativelist.cpp | 15 ++++--- src/declarative/qml/qdeclarativeproperty.cpp | 1 + 7 files changed, 77 insertions(+), 32 deletions(-) diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 6657fea..5288923 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -114,7 +114,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() \endcode All properties added explicitly by QDeclarativeContext::setContextProperty() take - precedence over context object's properties. + precedence over the context object's properties. Contexts form a hierarchy. The root of this heirarchy is the QDeclarativeEngine's \l {QDeclarativeEngine::rootContext()}{root context}. A component instance can @@ -140,6 +140,11 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() While QML objects instantiated in a context are not strictly owned by that context, their bindings are. If a context is destroyed, the property bindings of outstanding QML objects will stop evaluating. + + \note Setting the context object or adding new context properties after an object + has been created in that context is an expensive operation (essentially forcing all bindings + to reevaluate). Thus whenever possible you should complete "setup" of the context + before using it to create any objects. */ /*! \internal */ diff --git a/src/declarative/qml/qdeclarativeerror.cpp b/src/declarative/qml/qdeclarativeerror.cpp index 7e8aac0..17e91e3 100644 --- a/src/declarative/qml/qdeclarativeerror.cpp +++ b/src/declarative/qml/qdeclarativeerror.cpp @@ -49,8 +49,27 @@ QT_BEGIN_NAMESPACE /*! \class QDeclarativeError - \since 4.7 - \brief The QDeclarativeError class encapsulates a QML error + \since 4.7 + \brief The QDeclarativeError class encapsulates a QML error. + + QDeclarativeError includes a textual description of the error, as well + as location information (the file, line, and column). The toString() + method creates a single-line, human-readable string containing all of + this information, for example: + \code + file:///home/user/test.qml:7:8: Invalid property assignment: double expected + \endcode + + You can use qDebug() or qWarning() to output errors to the console. This method + will attempt to open the file indicated by the error + and include additional contextual information. + \code + file:///home/user/test.qml:7:8: Invalid property assignment: double expected + y: "hello" + ^ + \endcode + + \sa QDeclarativeView::errors(), QDeclarativeComponent::errors() */ class QDeclarativeErrorPrivate { @@ -69,7 +88,7 @@ QDeclarativeErrorPrivate::QDeclarativeErrorPrivate() } /*! - Create an empty error object. + Creates an empty error object. */ QDeclarativeError::QDeclarativeError() : d(0) @@ -77,7 +96,7 @@ QDeclarativeError::QDeclarativeError() } /*! - Create a copy of \a other. + Creates a copy of \a other. */ QDeclarativeError::QDeclarativeError(const QDeclarativeError &other) : d(0) @@ -86,7 +105,7 @@ QDeclarativeError::QDeclarativeError(const QDeclarativeError &other) } /*! - Assign \a other to this error object. + Assigns \a other to this error object. */ QDeclarativeError &QDeclarativeError::operator=(const QDeclarativeError &other) { @@ -112,7 +131,7 @@ QDeclarativeError::~QDeclarativeError() } /*! - Return true if this error is valid, otherwise false. + Returns true if this error is valid, otherwise false. */ bool QDeclarativeError::isValid() const { @@ -120,7 +139,7 @@ bool QDeclarativeError::isValid() const } /*! - Return the url for the file that caused this error. + Returns the url for the file that caused this error. */ QUrl QDeclarativeError::url() const { @@ -129,7 +148,7 @@ QUrl QDeclarativeError::url() const } /*! - Set the \a url for the file that caused this error. + Sets the \a url for the file that caused this error. */ void QDeclarativeError::setUrl(const QUrl &url) { @@ -138,7 +157,7 @@ void QDeclarativeError::setUrl(const QUrl &url) } /*! - Return the error description. + Returns the error description. */ QString QDeclarativeError::description() const { @@ -147,7 +166,7 @@ QString QDeclarativeError::description() const } /*! - Set the error \a description. + Sets the error \a description. */ void QDeclarativeError::setDescription(const QString &description) { @@ -156,7 +175,7 @@ void QDeclarativeError::setDescription(const QString &description) } /*! - Return the error line number. + Returns the error line number. */ int QDeclarativeError::line() const { @@ -165,7 +184,7 @@ int QDeclarativeError::line() const } /*! - Set the error \a line number. + Sets the error \a line number. */ void QDeclarativeError::setLine(int line) { @@ -174,7 +193,7 @@ void QDeclarativeError::setLine(int line) } /*! - Return the error column number. + Returns the error column number. */ int QDeclarativeError::column() const { @@ -183,7 +202,7 @@ int QDeclarativeError::column() const } /*! - Set the error \a column number. + Sets the error \a column number. */ void QDeclarativeError::setColumn(int column) { @@ -192,7 +211,7 @@ void QDeclarativeError::setColumn(int column) } /*! - Return the error as a human readable string. + Returns the error as a human readable string. */ QString QDeclarativeError::toString() const { @@ -210,7 +229,7 @@ QString QDeclarativeError::toString() const \relates QDeclarativeError \fn QDebug operator<<(QDebug debug, const QDeclarativeError &error) - Output a human readable version of \a error to \a debug. + Outputs a human readable version of \a error to \a debug. */ QDebug operator<<(QDebug debug, const QDeclarativeError &error) diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp index 762c642d..863bfc4 100644 --- a/src/declarative/qml/qdeclarativeextensionplugin.cpp +++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp @@ -59,6 +59,11 @@ QT_BEGIN_NAMESPACE function, and exporting the class using the Q_EXPORT_PLUGIN2() macro. + QML extension plugins can be used to provide either application-specific or + library-like plugins. Library plugins should limit themselves to registering types, + as any manipulation of the engine's root context may cause conflicts + or other issues in the library user's code. + See \l {Extending QML in C++} for details how to write a QML extension plugin. See \l {How to Create Qt Plugins} for general Qt plugin documentation. @@ -85,7 +90,7 @@ QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(QObject *parent) } /*! - Destructor. + Destroys the plugin. */ QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin() { @@ -94,7 +99,9 @@ QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin() /*! \fn void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) - Initializes the extension from the \a uri using the \a engine. + Initializes the extension from the \a uri using the \a engine. Here an application + plugin might, for example, expose some data or objects to QML, + as context properties on the engine's root context. */ void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index b992b9f..4be3472 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -45,31 +45,39 @@ QT_BEGIN_NAMESPACE /*! \class QDeclarativeImageProvider - \brief The QDeclarativeImageProvider class provides an interface for threaded image requests. + \since 4.7 + \brief The QDeclarativeImageProvider class provides an interface for threaded image requests in QML. - Note: the request() method may be called by multiple threads, so ensure the + QDeclarativeImageProvider can be used by a QDeclarativeEngine to provide images to QML asynchronously. + The image request will be run in a low priority thread, allowing potentially costly image + loading to be done in the background, without affecting the performance of the UI. + + See the QDeclarativeEngine::addImageProvider() documentation for an + example of how a custom QDeclarativeImageProvider can be constructed and used. + + \note the request() method may be called by multiple threads, so ensure the implementation of this method is reentrant. \sa QDeclarativeEngine::addImageProvider() */ /*! - The destructor is virtual. + Destroys the image provider. */ QDeclarativeImageProvider::~QDeclarativeImageProvider() { } /*! - \fn QImage QDeclarativeImageProvider::request(const QString &id, QSize *size, const QSize& requested_size) + \fn QImage QDeclarativeImageProvider::request(const QString &id, QSize *size, const QSize& requestedSize) Implement this method to return the image with \a id. - If \a requested_size is a valid size, resize the image to that size before returning. + If \a requestedSize is a valid size, the image returned should be of that size. - In any case, \a size must be set to the (original) size of the image. + In all cases, \a size must be set to the original size of the image. - Note: this method may be called by multiple threads, so ensure the + \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. */ diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h index 50b73fe..cc9c9af 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.h +++ b/src/declarative/qml/qdeclarativeimageprovider.h @@ -54,7 +54,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageProvider { public: virtual ~QDeclarativeImageProvider(); - virtual QImage request(const QString &id, QSize *size, const QSize& requested_size) = 0; + virtual QImage request(const QString &id, QSize *size, const QSize& requestedSize) = 0; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp index 45b8cd7..31ef4c2 100644 --- a/src/declarative/qml/qdeclarativelist.cpp +++ b/src/declarative/qml/qdeclarativelist.cpp @@ -87,9 +87,10 @@ void QDeclarativeListReferencePrivate::release() /*! \class QDeclarativeListReference +\since 4.7 \brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties. -QDeclarativeListReference allows programs to read from, and assign values to a QML list property in a +QDeclarativeListReference allows C++ programs to read from, and assign values to a QML list property in a simple and type safe way. A QDeclarativeListReference can be created by passing an object and property name or through a QDeclarativeProperty instance. These two are equivalant: @@ -304,6 +305,7 @@ int QDeclarativeListReference::count() const /*! \class QDeclarativeListProperty +\since 4.7 \brief The QDeclarativeListProperty class allows applications to explose list-like properties to QML. @@ -313,10 +315,10 @@ The use of a list property from QML looks like this: \code FruitBasket { fruit: [ - Apple {}, - Orange{}, - Banana {} - ] + Apple {}, + Orange{}, + Banana{} + ] } \endcode @@ -336,6 +338,9 @@ Q_PROPERTY(QDeclarativeListProperty fruit READ fruit); QML list properties are typesafe - in this case \c {Fruit} is a QObject type that \c {Apple}, \c {Orange} and \c {Banana} all derive from. + +\note QDeclarativeListProperty can only be used for lists of QObject-derived object pointers. + */ /*! diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index afd0d84..3881d0a 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE /*! \class QDeclarativeProperty +\since 4.7 \brief The QDeclarativeProperty class abstracts accessing properties on objects created from QML. As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect -- cgit v0.12 From 8620548e1024c44fbff1cb1becaab8d2d9e53cd5 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 29 Mar 2010 16:57:56 +1000 Subject: ResizeMode support for QGraphicsWidgets created with QDeclarativeView Task-number: QTBUG-8814 Reviewed-by: alexis --- src/declarative/util/qdeclarativeview.cpp | 266 +++++++++++++------- src/declarative/util/qdeclarativeview.h | 2 +- tests/auto/declarative/declarative.pro | 1 + .../data/resizemodedeclarativeitem.qml | 5 + .../data/resizemodegraphicswidget.qml | 5 + .../qdeclarativeview/qdeclarativeview.pro | 7 + .../qdeclarativeview/tst_qdeclarativeview.cpp | 272 +++++++++++++++++++++ tools/qml/main.cpp | 9 +- tools/qml/qmlruntime.cpp | 112 +++++---- tools/qml/qmlruntime.h | 4 +- 10 files changed, 551 insertions(+), 132 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml create mode 100644 tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml create mode 100644 tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro create mode 100644 tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index f786898..5cfa0e8 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -59,10 +59,14 @@ #include #include #include -#include +#include +#include +#include #include #include #include +#include +#include QT_BEGIN_NAMESPACE @@ -124,19 +128,23 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QDeclarativeViewPrivate +class QDeclarativeViewPrivate : public QDeclarativeItemChangeListener { public: QDeclarativeViewPrivate(QDeclarativeView *view) - : q(view), root(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} + : q(view), root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} ~QDeclarativeViewPrivate() { delete root; } - void execute(); + void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + void initResize(); + void updateSize(); + inline QSize rootObjectSize(); QDeclarativeView *q; QDeclarativeGuard root; - QDeclarativeGuard qmlRoot; + QDeclarativeGuard declarativeItemRoot; + QDeclarativeGuard graphicsWidgetRoot; QUrl source; @@ -144,7 +152,6 @@ public: QDeclarativeComponent *component; QBasicTimer resizetimer; - mutable QSize initialSize; QDeclarativeView::ResizeMode resizeMode; QTime frameTimer; @@ -155,18 +162,32 @@ public: void QDeclarativeViewPrivate::execute() { - delete root; - delete component; - initialSize = QSize(); - component = new QDeclarativeComponent(&engine, source, q); - - if (!component->isLoading()) { - q->continueExecute(); - } else { - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute())); + if (root) { + delete root; + root = 0; + } + if (component) { + delete component; + component = 0; + } + if (!source.isEmpty()) { + component = new QDeclarativeComponent(&engine, source, q); + if (!component->isLoading()) { + q->continueExecute(); + } else { + QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute())); + } } } +void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) +{ + if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) { + // wait for both width and height to be changed + resizetimer.start(0,q); + } + QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); +} /*! \class QDeclarativeView @@ -332,7 +353,6 @@ QDeclarativeContext* QDeclarativeView::rootContext() /*! \enum QDeclarativeView::Status - Specifies the loading status of the QDeclarativeView. \value Null This QDeclarativeView has no source set. @@ -373,7 +393,6 @@ QList QDeclarativeView::errors() const return QList(); } - /*! \property QDeclarativeView::resizeMode \brief whether the view should resize the canvas contents @@ -394,16 +413,92 @@ void QDeclarativeView::setResizeMode(ResizeMode mode) if (d->resizeMode == mode) return; + if (d->declarativeItemRoot) { + if (d->resizeMode == SizeViewToRootObject) { + QDeclarativeItemPrivate *p = + static_cast(QGraphicsItemPrivate::get(d->declarativeItemRoot)); + p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); + } + } else if (d->graphicsWidgetRoot) { + if (d->resizeMode == QDeclarativeView::SizeViewToRootObject) { + d->graphicsWidgetRoot->removeEventFilter(this); + } + } + d->resizeMode = mode; - if (d->qmlRoot) { - if (d->resizeMode == SizeRootObjectToView) { - d->qmlRoot->setWidth(width()); - d->qmlRoot->setHeight(height()); - } else { - d->qmlRoot->setWidth(d->initialSize.width()); - d->qmlRoot->setHeight(d->initialSize.height()); + if (d->root) { + d->initResize(); + } +} + +void QDeclarativeViewPrivate::initResize() +{ + if (declarativeItemRoot) { + if (resizeMode == QDeclarativeView::SizeViewToRootObject) { + QDeclarativeItemPrivate *p = + static_cast(QGraphicsItemPrivate::get(declarativeItemRoot)); + p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + } + } else if (graphicsWidgetRoot) { + if (resizeMode == QDeclarativeView::SizeViewToRootObject) { + graphicsWidgetRoot->installEventFilter(q); + } + } + updateSize(); +} + +void QDeclarativeViewPrivate::updateSize() +{ + if (!root) + return; + if (declarativeItemRoot) { + if (resizeMode == QDeclarativeView::SizeViewToRootObject) { + QSize newSize = QSize(declarativeItemRoot->width(), declarativeItemRoot->height()); + if (newSize.isValid() && newSize != q->size()) { + q->resize(newSize); + } + } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) { + if (!qFuzzyCompare(q->width(), declarativeItemRoot->width())) + declarativeItemRoot->setWidth(q->width()); + if (!qFuzzyCompare(q->height(), declarativeItemRoot->height())) + declarativeItemRoot->setHeight(q->height()); } + } else if (graphicsWidgetRoot) { + if (resizeMode == QDeclarativeView::SizeViewToRootObject) { + QSize newSize = QSize(graphicsWidgetRoot->size().width(), graphicsWidgetRoot->size().height()); + if (newSize.isValid() && newSize != q->size()) { + q->resize(newSize); + } + } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) { + QSizeF newSize = QSize(q->size().width(), q->size().height()); + if (newSize.isValid() && newSize != graphicsWidgetRoot->size()) { + graphicsWidgetRoot->resize(newSize); + } + } + } + q->updateGeometry(); +} + +QSize QDeclarativeViewPrivate::rootObjectSize() +{ + QSize rootObjectSize(0,0); + int widthCandidate = -1; + int heightCandidate = -1; + if (declarativeItemRoot) { + widthCandidate = declarativeItemRoot->width(); + heightCandidate = declarativeItemRoot->height(); + } else if (root) { + QSizeF size = root->boundingRect().size(); + widthCandidate = size.width(); + heightCandidate = size.height(); + } + if (widthCandidate > 0) { + rootObjectSize.setWidth(widthCandidate); } + if (heightCandidate > 0) { + rootObjectSize.setHeight(heightCandidate); + } + return rootObjectSize; } QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const @@ -449,55 +544,46 @@ void QDeclarativeView::continueExecute() */ void QDeclarativeView::setRootObject(QObject *obj) { - if (QDeclarativeItem *item = qobject_cast(obj)) { - d->scene.addItem(item); - - d->root = item; - d->qmlRoot = item; - connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); - connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); - if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0) - d->initialSize.setWidth(d->qmlRoot->width()); - if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0) - d->initialSize.setHeight(d->qmlRoot->height()); - resize(d->initialSize); - - if (d->resizeMode == SizeRootObjectToView) { - d->qmlRoot->setWidth(width()); - d->qmlRoot->setHeight(height()); + if (d->root == obj) + return; + if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { + d->scene.addItem(declarativeItem); + d->root = declarativeItem; + d->declarativeItemRoot = declarativeItem; + } else if (QGraphicsObject *graphicsObject = qobject_cast(obj)) { + d->scene.addItem(graphicsObject); + d->root = graphicsObject; + if (graphicsObject->isWidget()) { + d->graphicsWidgetRoot = static_cast(graphicsObject); } else { - QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); - emit sceneResized(sz); - resize(sz); + qWarning() << "QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject"; } - updateGeometry(); - } else if (QGraphicsObject *item = qobject_cast(obj)) { - d->scene.addItem(item); - qWarning() << "QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject"; - } else if (QWidget *wid = qobject_cast(obj)) { - window()->setAttribute(Qt::WA_OpaquePaintEvent, false); - window()->setAttribute(Qt::WA_NoSystemBackground, false); - if (!layout()) { - setLayout(new QVBoxLayout); - layout()->setContentsMargins(0, 0, 0, 0); - } else if (layout()->count()) { - // Hide the QGraphicsView in GV mode. - QLayoutItem *item = layout()->itemAt(0); - if (item->widget()) - item->widget()->hide(); + } else if (obj) { + qWarning() << "QDeclarativeView only supports loading of root objects that derive from QGraphicsObject"; + if (QWidget* widget = qobject_cast(obj)) { + window()->setAttribute(Qt::WA_OpaquePaintEvent, false); + window()->setAttribute(Qt::WA_NoSystemBackground, false); + if (layout() && layout()->count()) { + // Hide the QGraphicsView in GV mode. + QLayoutItem *item = layout()->itemAt(0); + if (item->widget()) + item->widget()->hide(); + } + widget->setParent(this); + if (isVisible()) { + widget->setVisible(true); + } + resize(widget->size()); } - layout()->addWidget(wid); - emit sceneResized(wid->size()); } -} -/*! - \internal - */ -void QDeclarativeView::sizeChanged() -{ - // delay, so we catch both width and height changing. - d->resizetimer.start(0,this); + if (d->root) { + QSize initialSize = d->rootObjectSize(); + if (initialSize != size()) { + resize(initialSize); + } + d->initResize(); + } } /*! @@ -508,30 +594,36 @@ void QDeclarativeView::sizeChanged() void QDeclarativeView::timerEvent(QTimerEvent* e) { if (!e || e->timerId() == d->resizetimer.timerId()) { - if (d->qmlRoot) { - QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); - emit sceneResized(sz); - //if (!d->resizable) - //resize(sz); - } + d->updateSize(); d->resizetimer.stop(); - updateGeometry(); } } +bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) +{ + if (watched == d->root && d->resizeMode == SizeViewToRootObject) { + if (d->graphicsWidgetRoot) { + if (e->type() == QEvent::GraphicsSceneResize) { + d->updateSize(); + } + } + } + return QGraphicsView::eventFilter(watched, e); +} + /*! \internal - The size hint is the size of the root item. + Preferred size follows the root object in + resize mode SizeViewToRootObject and + the view in resize mode SizeRootObjectToView. */ QSize QDeclarativeView::sizeHint() const { - if (d->qmlRoot) { - if (d->initialSize.width() <= 0) - d->initialSize.setWidth(d->qmlRoot->width()); - if (d->initialSize.height() <= 0) - d->initialSize.setHeight(d->qmlRoot->height()); + if (d->resizeMode == SizeRootObjectToView) { + return size(); + } else { // d->resizeMode == SizeViewToRootObject + return d->rootObjectSize(); } - return d->initialSize; } /*! @@ -549,17 +641,17 @@ QGraphicsObject *QDeclarativeView::rootObject() const */ void QDeclarativeView::resizeEvent(QResizeEvent *e) { - if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) { - d->qmlRoot->setWidth(width()); - d->qmlRoot->setHeight(height()); + if (d->resizeMode == SizeRootObjectToView) { + d->updateSize(); } - if (d->qmlRoot) { - setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height())); + if (d->declarativeItemRoot) { + setSceneRect(QRectF(0, 0, d->declarativeItemRoot->width(), d->declarativeItemRoot->height())); } else if (d->root) { setSceneRect(d->root->boundingRect()); } else { setSceneRect(rect()); } + emit sceneResized(e->size()); QGraphicsView::resizeEvent(e); } diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index 107f3f9..1807758 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -97,13 +97,13 @@ Q_SIGNALS: private Q_SLOTS: void continueExecute(); - void sizeChanged(); protected: virtual void resizeEvent(QResizeEvent *); virtual void paintEvent(QPaintEvent *event); virtual void timerEvent(QTimerEvent*); virtual void setRootObject(QObject *obj); + virtual bool eventFilter(QObject *watched, QEvent *e); friend class QDeclarativeViewPrivate; QDeclarativeViewPrivate *d; diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 7834650..58371c1 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -59,6 +59,7 @@ SUBDIRS += \ qdeclarativerepeater \ # Cover qdeclarativeworkerscript \ # Cover qdeclarativevaluetypes \ # Cover + qdeclarativeview \ # Cover qdeclarativexmlhttprequest \ # Cover qdeclarativeimageprovider \ # Cover qdeclarativestyledtext \ # Cover diff --git a/tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml b/tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml new file mode 100644 index 0000000..27c8454 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml @@ -0,0 +1,5 @@ +import Qt 4.7 +Item { + width: 200 + height: 200 +} diff --git a/tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml b/tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml new file mode 100644 index 0000000..964810c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml @@ -0,0 +1,5 @@ +import Qt 4.7 +QGraphicsWidget { + width: 200 + height: 200 +} diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro new file mode 100644 index 0000000..d6be728 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeview.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp new file mode 100644 index 0000000..1ed51c1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +class tst_QDeclarativeView : public QObject + +{ + Q_OBJECT +public: + tst_QDeclarativeView(); + +private slots: + void resizemodedeclarativeitem(); + void resizemodegraphicswidget(); + +private: + template + T *findItem(QGraphicsObject *parent, const QString &objectName); +}; + + +tst_QDeclarativeView::tst_QDeclarativeView() +{ +} + +void tst_QDeclarativeView::resizemodedeclarativeitem() +{ + QWidget window; + QDeclarativeView *canvas = new QDeclarativeView(&window); + QVERIFY(canvas); + QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize))); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); + QDeclarativeItem* declarativeItem = qobject_cast(canvas->rootObject()); + QVERIFY(declarativeItem); + window.show(); + + // initial size from root object + QCOMPARE(declarativeItem->width(), 200.0); + QCOMPARE(declarativeItem->height(), 200.0); + QCOMPARE(canvas->size(), QSize(200, 200)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 1); + + // size update from view + canvas->resize(QSize(80,100)); + QCOMPARE(declarativeItem->width(), 80.0); + QCOMPARE(declarativeItem->height(), 100.0); + QCOMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 2); + + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + + // size update from view disabled + canvas->resize(QSize(60,80)); + QCOMPARE(declarativeItem->width(), 80.0); + QCOMPARE(declarativeItem->height(), 100.0); + QCOMPARE(canvas->size(), QSize(60, 80)); + QCOMPARE(sceneResizedSpy.count(), 3); + + // size update from root object + declarativeItem->setWidth(250); + declarativeItem->setHeight(350); + qApp->processEvents(); + QCOMPARE(declarativeItem->width(), 250.0); + QCOMPARE(declarativeItem->height(), 350.0); + QCOMPARE(canvas->size(), QSize(250, 350)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 4); + + // reset canvas + window.hide(); + delete canvas; + canvas = new QDeclarativeView(&window); + QVERIFY(canvas); + QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize))); + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); + declarativeItem = qobject_cast(canvas->rootObject()); + QVERIFY(declarativeItem); + window.show(); + + // initial size for root object + QCOMPARE(declarativeItem->width(), 200.0); + QCOMPARE(declarativeItem->height(), 200.0); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 1); + + // size update from root object + declarativeItem->setWidth(80); + declarativeItem->setHeight(100); + qApp->processEvents(); + QCOMPARE(declarativeItem->width(), 80.0); + QCOMPARE(declarativeItem->height(), 100.0); + QCOMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 2); + + // size update from root object disabled + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + declarativeItem->setWidth(60); + declarativeItem->setHeight(80); + QCOMPARE(canvas->width(), 80); + QCOMPARE(canvas->height(), 100); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 2); + + // size update from view + canvas->resize(QSize(200,300)); + QCOMPARE(declarativeItem->width(), 200.0); + QCOMPARE(declarativeItem->height(), 300.0); + QCOMPARE(canvas->size(), QSize(200, 300)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 3); + + delete canvas; +} + +void tst_QDeclarativeView::resizemodegraphicswidget() +{ + QWidget window; + QDeclarativeView *canvas = new QDeclarativeView(&window); + QVERIFY(canvas); + QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize))); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml")); + QGraphicsWidget* graphicsWidget = qobject_cast(canvas->rootObject()); + QVERIFY(graphicsWidget); + window.show(); + + // initial size from root object + QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0)); + QCOMPARE(canvas->size(), QSize(200, 200)); + QCOMPARE(canvas->size(), QSize(200, 200)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 1); + + // size update from view + canvas->resize(QSize(80,100)); + QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0)); + QCOMPARE(canvas->size(), QSize(80,100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 2); + + // size update from view disabled + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + canvas->resize(QSize(60,80)); + QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0)); + QCOMPARE(canvas->size(), QSize(60, 80)); + QCOMPARE(sceneResizedSpy.count(), 3); + + // size update from root object + graphicsWidget->resize(QSizeF(250.0, 350.0)); + QCOMPARE(graphicsWidget->size(), QSizeF(250.0,350.0)); + QCOMPARE(canvas->size(), QSize(250, 350)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy.count(), 4); + + // reset canvas + window.hide(); + delete canvas; + canvas = new QDeclarativeView(&window); + QVERIFY(canvas); + QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize))); + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml")); + graphicsWidget = qobject_cast(canvas->rootObject()); + QVERIFY(graphicsWidget); + window.show(); + + // initial size from root object + QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0)); + QCOMPARE(canvas->size(), QSize(200, 200)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 1); + + // size update from root object + graphicsWidget->resize(QSizeF(80, 100)); + QCOMPARE(graphicsWidget->size(), QSizeF(80.0, 100.0)); + QCOMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 2); + + // size update from root object disabled + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + graphicsWidget->resize(QSizeF(60,80)); + QCOMPARE(canvas->size(), QSize(80,100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 2); + + // size update from view + canvas->resize(QSize(200,300)); + QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 300.0)); + QCOMPARE(canvas->size(), QSize(200, 300)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(sceneResizedSpy2.count(), 3); + + window.show(); + delete canvas; +} + +template +T *tst_QDeclarativeView::findItem(QGraphicsObject *parent, const QString &objectName) +{ + if (!parent) + return 0; + + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->QGraphicsObject::children().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) + return static_cast(item); + item = findItem(item, objectName); + if (item) + return static_cast(item); + } + + return 0; +} + +QTEST_MAIN(tst_QDeclarativeView) + +#include "tst_qdeclarativeview.moc" diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 341908e..5e829a4 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -88,6 +88,8 @@ void usage() qWarning(" -skin ...................... run with a skin window frame"); qWarning(" \"list\" for a list of built-ins"); qWarning(" -resizeview .............................. resize the view, not the skin"); + qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); + qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); qWarning(" -recordfile ..................... set video recording file"); qWarning(" - ImageMagick 'convert' for GIF)"); @@ -184,6 +186,7 @@ int main(int argc, char ** argv) bool stayOnTop = false; bool maximized = false; bool useNativeFileBrowser = true; + bool sizeToView = true; #if defined(Q_OS_SYMBIAN) maximized = true; @@ -270,6 +273,10 @@ int main(int argc, char ** argv) if (lastArg) usage(); script = QString(argv[++i]); runScript = true; + } else if (arg == "-sizeviewtorootobject") { + sizeToView = false; + } else if (arg == "-sizerootobjecttoview") { + sizeToView = true; } else if (arg[0] != '-') { fileName = arg; } else if (1 || arg == "-help") { @@ -339,6 +346,7 @@ int main(int argc, char ** argv) viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); + viewer.setSizeToView(sizeToView); if (resizeview) viewer.setScaleView(); if (fps>0) @@ -390,6 +398,5 @@ int main(int argc, char ** argv) } viewer.setUseGL(useGL); viewer.raise(); - return app.exec(); } diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 53409c1..7b4706b 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -496,7 +496,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) canvas = new QDeclarativeView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); + canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); @@ -519,7 +519,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) #else setCentralWidget(canvas); #endif - namFactory = new NetworkAccessManagerFactory; canvas->engine()->setNetworkAccessManagerFactory(namFactory); @@ -753,10 +752,11 @@ void QDeclarativeViewer::setScaleSkin() if (scaleSkin) return; scaleSkin = true; - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); if (skin) { - canvas->setFixedSize(canvas->sizeHint()); - skin->setScreenSize(canvas->sizeHint()); + canvas->resize(initialSize); + canvas->setFixedSize(initialSize); + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + updateSizeHints(); } } @@ -766,11 +766,8 @@ void QDeclarativeViewer::setScaleView() return; scaleSkin = false; if (skin) { - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(16777215,16777215)); - canvas->resize(skin->standardScreenSize()); - skin->setScreenSize(skin->standardScreenSize()); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + updateSizeHints(); } } @@ -916,19 +913,12 @@ void QDeclarativeViewer::statusChanged() tester->executefailure(); if (canvas->status() == QDeclarativeView::Ready) { - if (!skin) { - canvas->updateGeometry(); - if (mb) - mb->updateGeometry(); - if (!isFullScreen() && !isMaximized()) - resize(sizeHint()); - } else { - if (scaleSkin) - canvas->resize(canvas->sizeHint()); - else { - canvas->setFixedSize(skin->standardScreenSize()); - canvas->resize(skin->standardScreenSize()); - } + initialSize = canvas->sizeHint(); + if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { + QSize newWindowSize = initialSize; + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + updateSizeHints(); + resize(newWindowSize); } } } @@ -1010,7 +1000,6 @@ bool QDeclarativeViewer::open(const QString& file_or_url) t.start(); canvas->setSource(url); - qWarning() << "Wall startup time:" << t.elapsed(); return true; @@ -1056,41 +1045,43 @@ void QDeclarativeViewer::setSkin(const QString& skinDirOrName) skin->deleteLater(); } - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); - DeviceSkinParameters parameters; if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { layout()->setEnabled(false); - //setMenuBar(0); if (mb) mb->hide(); if (!err.isEmpty()) qWarning() << err; skin = new PreviewDeviceSkin(parameters,this); - canvas->resize(canvas->sizeHint()); if (scaleSkin) skin->setPreviewAndScale(canvas); else skin->setPreview(canvas); createMenu(0,skin->menu); + if (scaleSkin) { + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + } + updateSizeHints(); skin->show(); - } else { + } else if (skin) { skin = 0; clearMask(); menuBar()->clear(); - canvas->setParent(this, Qt::SubWindow); createMenu(menuBar(),0); - mb->show(); - setMinimumSize(QSize(0,0)); - setMaximumSize(QSize(16777215,16777215)); - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(16777215,16777215)); - QRect g = geometry(); - g.setSize(sizeHint()); + canvas->setParent(this, Qt::SubWindow); setParent(0,windowFlags()); // recreate - canvas->move(0,menuBar()->sizeHint().height()); - setGeometry(g); + mb->show(); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + updateSizeHints(); + layout()->setEnabled(true); + if (!scaleSkin) { + canvas->resize(initialSize); + canvas->setFixedSize(initialSize); + } + QSize newWindowSize = canvas->size(); + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + resize(newWindowSize); show(); } canvas->show(); @@ -1122,9 +1113,10 @@ void QDeclarativeViewer::setRecordRate(int fps) void QDeclarativeViewer::sceneResized(QSize size) { if (size.width() > 0 && size.height() > 0) { - if (skin && scaleSkin) - skin->setScreenSize(size); - } + if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { + updateSizeHints(); + } + } } void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) @@ -1397,6 +1389,42 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use) useQmlFileBrowser = !use; } +void QDeclarativeViewer::setSizeToView(bool sizeToView) +{ + QDeclarativeView::ResizeMode resizeMode = sizeToView ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject; + if (resizeMode != canvas->resizeMode()) { + canvas->setResizeMode(resizeMode); + updateSizeHints(); + } +} + +void QDeclarativeViewer::updateSizeHints() +{ + if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { + QSize newWindowSize = canvas->sizeHint(); + if (!skin) { + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + } + if (!isFullScreen() && !isMaximized()) { + resize(newWindowSize); + setFixedSize(newWindowSize); + if (skin && scaleSkin) { + skin->setScreenSize(newWindowSize); + } + } + } else { // QDeclarativeView::SizeRootObjectToView + canvas->setMinimumSize(QSize(0,0)); + canvas->setMaximumSize(QSize(16777215,16777215)); + setMinimumSize(QSize(0,0)); + setMaximumSize(QSize(16777215,16777215)); + if (skin && !scaleSkin) { + canvas->setFixedSize(skin->standardScreenSize()); + skin->setScreenSize(skin->standardScreenSize()); + } + } + updateGeometry(); +} + void QDeclarativeViewer::registerTypes() { static bool registered = false; diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 2089dda..a00a703 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -100,7 +100,8 @@ public: void addPluginPath(const QString& plugin); void setUseGL(bool use); void setUseNativeFileBrowser(bool); - + void updateSizeHints(); + void setSizeToView(bool sizeToView); QStringList builtinSkins() const; QMenuBar *menuBar() const; @@ -149,6 +150,7 @@ private: PreviewDeviceSkin *skin; QSize skinscreensize; QDeclarativeView *canvas; + QSize initialSize; QString currentFileOrUrl; QDeclarativeTimer recordTimer; QString frame_fmt; -- cgit v0.12 From b458d672dbec892f00019edc1fe06156190401c7 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 16 Apr 2010 15:25:23 +1000 Subject: Test not reliable --- tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp index 2621d65..b8e317e 100644 --- a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp @@ -111,14 +111,6 @@ void tst_QPacketProtocol::setMaximumPacketSize() QPacketProtocol out(m_serverConn); QCOMPARE(out.setMaximumPacketSize(size), expected); - - if (size == expected) { - QPacketProtocol in(m_client); - QByteArray b; - b.fill('a', size + 1); - out.send() << b.constData(); - QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(invalidPacket()))); - } } void tst_QPacketProtocol::setMaximumPacketSize_data() -- cgit v0.12 From 34a1a6b5d6399e7bcad136fdaa9a050a0f8bb2dc Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 16 Apr 2010 15:33:41 +1000 Subject: Wait for debug clients asynchronously instead of blocking creation of the engine until a debug client has connected. This makes for easier debugging from Qt Creator when debugging C++ and QML together and when debugging an application that has multiple engines. --- .../debugger/qdeclarativedebugservice.cpp | 133 +++++++++------------ .../debugger/qdeclarativedebugservice_p.h | 7 +- src/declarative/qml/qdeclarativeengine.cpp | 2 - .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 91 +++++++------- .../tst_qdeclarativedebugclient.cpp | 42 +++---- .../tst_qdeclarativedebugservice.cpp | 42 +++---- tests/auto/declarative/shared/debugutil.cpp | 81 +------------ tests/auto/declarative/shared/debugutil_p.h | 56 --------- 8 files changed, 143 insertions(+), 311 deletions(-) diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp index 9d9d1d0..34e73fd 100644 --- a/src/declarative/debugger/qdeclarativedebugservice.cpp +++ b/src/declarative/debugger/qdeclarativedebugservice.cpp @@ -60,12 +60,12 @@ class QDeclarativeDebugServer : public QObject Q_DISABLE_COPY(QDeclarativeDebugServer) public: static QDeclarativeDebugServer *instance(); - void wait(); - void registerForStartNotification(QObject *object, const char *receiver); + void listen(); + bool hasDebuggingClient() const; private Q_SLOTS: void readyRead(); - void registeredObjectDestroyed(QObject *object); + void newConnection(); private: friend class QDeclarativeDebugService; @@ -78,14 +78,14 @@ class QDeclarativeDebugServerPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QDeclarativeDebugServer) public: QDeclarativeDebugServerPrivate(); - void wait(); int port; QTcpSocket *connection; QPacketProtocol *protocol; QHash plugins; QStringList enabledPlugins; - QList > notifyClients; + QTcpServer *tcpServer; + bool gotHello; }; class QDeclarativeDebugServicePrivate : public QObjectPrivate @@ -99,56 +99,41 @@ public: }; QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() -: connection(0), protocol(0) +: connection(0), protocol(0), gotHello(false) { } -void QDeclarativeDebugServerPrivate::wait() +void QDeclarativeDebugServer::listen() { - Q_Q(QDeclarativeDebugServer); - QTcpServer server; - - if (!server.listen(QHostAddress::Any, port)) { - qWarning("QDeclarativeDebugServer: Unable to listen on port %d", port); - return; - } - - qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", port); - - for (int i=0; itcpServer = new QTcpServer(this); + QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); + if (d->tcpServer->listen(QHostAddress::Any, d->port)) + qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port); + else + qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port); +} - connection = server.nextPendingConnection(); - connection->setParent(q); - protocol = new QPacketProtocol(connection, q); +void QDeclarativeDebugServer::newConnection() +{ + Q_D(QDeclarativeDebugServer); - // ### Wait for hello - while (!protocol->packetsAvailable()) { - connection->waitForReadyRead(); - } - QPacket hello = protocol->read(); - QString name; - hello >> name >> enabledPlugins; - if (name != QLatin1String("QDeclarativeDebugServer")) { - qWarning("QDeclarativeDebugServer: Invalid hello message"); - delete protocol; delete connection; connection = 0; protocol = 0; + if (d->connection) { + qWarning("QDeclarativeDebugServer error: another client is already connected"); return; } - QObject::connect(protocol, SIGNAL(readyRead()), q, SLOT(readyRead())); - q->readyRead(); + d->connection = d->tcpServer->nextPendingConnection(); + d->connection->setParent(this); + d->protocol = new QPacketProtocol(d->connection, this); + QObject::connect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); +} - qWarning("QDeclarativeDebugServer: Connection established"); +bool QDeclarativeDebugServer::hasDebuggingClient() const +{ + Q_D(const QDeclarativeDebugServer); + return d->gotHello; } QDeclarativeDebugServer *QDeclarativeDebugServer::instance() @@ -163,36 +148,15 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance() bool ok = false; int port = env.toInt(&ok); - if (ok && port > 1024) + if (ok && port > 1024) { server = new QDeclarativeDebugServer(port); + server->listen(); + } } return server; } -void QDeclarativeDebugServer::wait() -{ - Q_D(QDeclarativeDebugServer); - d->wait(); -} - -void QDeclarativeDebugServer::registerForStartNotification(QObject *object, const char *methodName) -{ - Q_D(QDeclarativeDebugServer); - connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*))); - d->notifyClients.append(qMakePair(object, QByteArray(methodName))); -} - -void QDeclarativeDebugServer::registeredObjectDestroyed(QObject *object) -{ - Q_D(QDeclarativeDebugServer); - QMutableListIterator > i(d->notifyClients); - while (i.hasNext()) { - if (i.next().first == object) - i.remove(); - } -} - QDeclarativeDebugServer::QDeclarativeDebugServer(int port) : QObject(*(new QDeclarativeDebugServerPrivate)) { @@ -204,6 +168,23 @@ void QDeclarativeDebugServer::readyRead() { Q_D(QDeclarativeDebugServer); + if (!d->gotHello) { + QPacket hello = d->protocol->read(); + QString name; + hello >> name >> d->enabledPlugins; + if (name != QLatin1String("QDeclarativeDebugServer")) { + qWarning("QDeclarativeDebugServer: Invalid hello message"); + QObject::disconnect(d->protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); + d->protocol->deleteLater(); + d->protocol = 0; + d->connection->deleteLater(); + d->connection = 0; + return; + } + d->gotHello = true; + qWarning("QDeclarativeDebugServer: Connection established"); + } + QString debugServer(QLatin1String("QDeclarativeDebugServer")); while (d->protocol->packetsAvailable()) { @@ -375,6 +356,12 @@ bool QDeclarativeDebugService::isDebuggingEnabled() return QDeclarativeDebugServer::instance() != 0; } +bool QDeclarativeDebugService::hasDebuggingClient() +{ + return QDeclarativeDebugServer::instance() != 0 + && QDeclarativeDebugServer::instance()->hasDebuggingClient(); +} + QString QDeclarativeDebugService::objectToString(QObject *obj) { if(!obj) @@ -390,16 +377,6 @@ QString QDeclarativeDebugService::objectToString(QObject *obj) return rv; } -void QDeclarativeDebugService::waitForClients() -{ - QDeclarativeDebugServer::instance()->wait(); -} - -void QDeclarativeDebugService::notifyOnServerStart(QObject *object, const char *receiver) -{ - QDeclarativeDebugServer::instance()->registerForStartNotification(object, receiver); -} - void QDeclarativeDebugService::sendMessage(const QByteArray &message) { Q_D(QDeclarativeDebugService); diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h index 498edf3..c461ddf 100644 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ b/src/declarative/debugger/qdeclarativedebugservice_p.h @@ -68,19 +68,16 @@ public: static int idForObject(QObject *); static QObject *objectForId(int); - static bool isDebuggingEnabled(); static QString objectToString(QObject *obj); - static void waitForClients(); - - static void notifyOnServerStart(QObject *object, const char *receiver); + static bool isDebuggingEnabled(); + static bool hasDebuggingClient(); protected: virtual void enabledChanged(bool); virtual void messageReceived(const QByteArray &); private: - void registerForStartNotification(QObject *object, const char *methodName); friend class QDeclarativeDebugServer; }; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index cfdc79e..4dbd199 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -390,8 +390,6 @@ void QDeclarativeEnginePrivate::init() qmlEngineDebugServer(); isDebugging = true; QDeclarativeEngineDebugServer::addEngine(q); - - qmlEngineDebugServer()->waitForClients(); } } diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 133dcb8..49d430e 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -60,6 +60,7 @@ #include #include +#include "../../../shared/util.h" #include "../shared/debugutil_p.h" Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State) @@ -69,14 +70,6 @@ class tst_QDeclarativeDebug : public QObject { Q_OBJECT -public: - tst_QDeclarativeDebug(QDeclarativeDebugTestData *data) - { - m_conn = data->conn; - m_engine = data->engine; - m_rootItem = data->items[0]; - } - private: QDeclarativeDebugObjectReference findRootObject(); QDeclarativeDebugPropertyReference findProperty(const QList &props, const QString &name) const; @@ -93,8 +86,11 @@ private: QDeclarativeEngine *m_engine; QDeclarativeItem *m_rootItem; + QObjectList m_components; + private slots: void initTestCase(); + void cleanupTestCase(); void watch_property(); void watch_object(); @@ -278,9 +274,50 @@ void tst_QDeclarativeDebug::compareProperties(const QDeclarativeDebugPropertyRef void tst_QDeclarativeDebug::initTestCase() { + qRegisterMetaType(); + + qputenv("QML_DEBUG_SERVER_PORT", "3768"); + m_engine = new QDeclarativeEngine(this); + + QList qml; + qml << "import Qt 4.7\n" + "Item {" + "width: 10; height: 20; scale: blueRect.scale;" + "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" + "Text { color: blueRect.color; }" + "MouseArea {" + "onEntered: { console.log('hello') }" + "}" + "}"; + // add second component to test multiple root contexts + qml << "import Qt 4.7\n" + "Item {}"; + + for (int i=0; i(component.create()); + } + m_rootItem = qobject_cast(m_components.first()); + + + // add an extra context to test for multiple contexts + QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this); + context->setObjectName("tst_QDeclarativeDebug_childContext"); + + m_conn = new QDeclarativeDebugConnection(this); + m_conn->connectToHost("127.0.0.1", 3768); + bool ok = m_conn->waitForConnected(); + Q_ASSERT(ok); + QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); + m_dbg = new QDeclarativeEngineDebug(m_conn, this); +} - qRegisterMetaType(); +void tst_QDeclarativeDebug::cleanupTestCase() +{ + qDeleteAll(m_components); } void tst_QDeclarativeDebug::watch_property() @@ -804,40 +841,6 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference() compareProperties(r, ref); } - -class tst_QDeclarativeDebug_Factory : public QDeclarativeTestFactory -{ -public: - QObject *createTest(QDeclarativeDebugTestData *data) - { - tst_QDeclarativeDebug *test = new tst_QDeclarativeDebug(data); - QDeclarativeContext *c = new QDeclarativeContext(data->engine->rootContext(), test); - c->setObjectName("tst_QDeclarativeDebug_childContext"); - return test; - } -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QList qml; - qml << "import Qt 4.7\n" - "Item {" - "width: 10; height: 20; scale: blueRect.scale;" - "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" - "Text { color: blueRect.color; }" - "MouseArea {" - "onEntered: { console.log('hello') }" - "}" - "}"; - // add second component to test multiple root contexts - qml << "import Qt 4.7\n" - "Item {}"; - tst_QDeclarativeDebug_Factory factory; - return QDeclarativeDebugTest::runTests(&factory, qml); -} - -//QTEST_MAIN(tst_QDeclarativeDebug) +QTEST_MAIN(tst_QDeclarativeDebug) #include "tst_qdeclarativedebug.moc" diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index d3679a7..fb17f90 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -52,21 +52,19 @@ #include #include +#include "../../../shared/util.h" #include "../shared/debugutil_p.h" class tst_QDeclarativeDebugClient : public QObject { Q_OBJECT -public: - tst_QDeclarativeDebugClient(QDeclarativeDebugTestData *data) - { - m_conn = data->conn; - } - +private: QDeclarativeDebugConnection *m_conn; private slots: + void initTestCase(); + void name(); void isEnabled(); void setEnabled(); @@ -74,6 +72,19 @@ private slots: void sendMessage(); }; +void tst_QDeclarativeDebugClient::initTestCase() +{ + qputenv("QML_DEBUG_SERVER_PORT", "3768"); + new QDeclarativeEngine(this); + + m_conn = new QDeclarativeDebugConnection(this); + m_conn->connectToHost("127.0.0.1", 3768); + bool ok = m_conn->waitForConnected(); + Q_ASSERT(ok); + + QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); +} + void tst_QDeclarativeDebugClient::name() { QString name = "tst_QDeclarativeDebugClient::name()"; @@ -136,22 +147,7 @@ void tst_QDeclarativeDebugClient::sendMessage() QCOMPARE(resp, msg); } - -class tst_QDeclarativeDebugClient_Factory : public QDeclarativeTestFactory -{ -public: - QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugClient(data); } -}; - - -// This does not use QTEST_MAIN because the test has to be created and run -// in a separate thread. -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - tst_QDeclarativeDebugClient_Factory factory; - return QDeclarativeDebugTest::runTests(&factory); -} +QTEST_MAIN(tst_QDeclarativeDebugClient) #include "tst_qdeclarativedebugclient.moc" + diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index c8fc001..80d7f76 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -52,21 +52,19 @@ #include #include +#include "../../../shared/util.h" #include "../shared/debugutil_p.h" + class tst_QDeclarativeDebugService : public QObject { Q_OBJECT - -public: - tst_QDeclarativeDebugService(QDeclarativeDebugTestData *data) - { - m_conn = data->conn; - } - +private: QDeclarativeDebugConnection *m_conn; private slots: + void initTestCase(); + void name(); void isEnabled(); void enabledChanged(); @@ -76,6 +74,19 @@ private slots: void objectToString(); }; +void tst_QDeclarativeDebugService::initTestCase() +{ + qputenv("QML_DEBUG_SERVER_PORT", "3768"); + new QDeclarativeEngine(this); + + m_conn = new QDeclarativeDebugConnection(this); + m_conn->connectToHost("127.0.0.1", 3768); + bool ok = m_conn->waitForConnected(); + Q_ASSERT(ok); + + QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); +} + void tst_QDeclarativeDebugService::name() { QString name = "tst_QDeclarativeDebugService::name()"; @@ -170,21 +181,6 @@ void tst_QDeclarativeDebugService::objectToString() delete obj; } - -class tst_QDeclarativeDebugService_Factory : public QDeclarativeTestFactory -{ -public: - QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugService(data); } -}; - -// This does not use QTEST_MAIN because the test has to be created and run -// in a separate thread. -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - tst_QDeclarativeDebugService_Factory factory; - return QDeclarativeDebugTest::runTests(&factory); -} +QTEST_MAIN(tst_QDeclarativeDebugService) #include "tst_qdeclarativedebugservice.moc" diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index 66f04e5..c0c3eca 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -47,11 +47,11 @@ #include "debugutil_p.h" -#include bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) { QEventLoop loop; QTimer timer; + timer.setSingleShot(true); QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); QObject::connect(receiver, member, &loop, SLOT(quit())); timer.start(timeout); @@ -59,25 +59,6 @@ bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, return timer.isActive(); } - -QDeclarativeDebugTestData::QDeclarativeDebugTestData(QEventLoop *el) - : exitCode(-1), loop(el) -{ -} - -QDeclarativeDebugTestData::~QDeclarativeDebugTestData() -{ - qDeleteAll(items); -} - -void QDeclarativeDebugTestData::testsFinished(int code) -{ - exitCode = code; - loop->quit(); -} - - - QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent) : QDeclarativeDebugService(s, parent), enabled(false) { @@ -117,63 +98,3 @@ void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba) emit serverMessage(ba); } - -tst_QDeclarativeDebug_Thread::tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory) - : m_data(data), m_factory(factory) -{ -} - -void tst_QDeclarativeDebug_Thread::run() -{ - bool ok = false; - - QDeclarativeDebugConnection conn; - conn.connectToHost("127.0.0.1", 3768); - ok = conn.waitForConnected(); - Q_ASSERT(ok); - - QEventLoop loop; - connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit())); - loop.exec(); - - m_data->conn = &conn; - - Q_ASSERT(m_factory); - QObject *test = m_factory->createTest(m_data); - Q_ASSERT(test); - int code = QTest::qExec(test, QCoreApplication::arguments()); - delete test; - emit testsFinished(code); -} - -int QDeclarativeDebugTest::runTests(QDeclarativeTestFactory *factory, const QList &qml) -{ - qputenv("QML_DEBUG_SERVER_PORT", "3768"); - - QEventLoop loop; - QDeclarativeDebugTestData data(&loop); - - tst_QDeclarativeDebug_Thread thread(&data, factory); - QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int))); - - QDeclarativeDebugService::notifyOnServerStart(&thread, "start"); - - QDeclarativeEngine engine; // blocks until client connects - - foreach (const QByteArray &code, qml) { - QDeclarativeComponent c(&engine); - c.setData(code, QUrl::fromLocalFile("")); - Q_ASSERT(c.isReady()); // fails if bad syntax - data.items << qobject_cast(c.create()); - } - - // start the test - data.engine = &engine; - emit data.engineCreated(); - - loop.exec(); - thread.wait(); - - return data.exitCode; -} - diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index c152b5a..e6bb7ad 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -51,50 +51,10 @@ #include #include -class QDeclarativeTestFactory; - class QDeclarativeDebugTest { public: static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); - - static int runTests(QDeclarativeTestFactory *factory, const QList &qml = QList()); -}; - -class QDeclarativeDebugTestData : public QObject -{ - Q_OBJECT -public: - QDeclarativeDebugTestData(QEventLoop *el); - - ~QDeclarativeDebugTestData(); - - QDeclarativeDebugConnection *conn; - QDeclarativeEngine *engine; - - int exitCode; - QEventLoop *loop; - - QList items; - -signals: - void engineCreated(); - -public slots: - void testsFinished(int code); - -private: - friend class QDeclarativeDebugTest; -}; - - -class QDeclarativeTestFactory -{ -public: - QDeclarativeTestFactory() {} - virtual ~QDeclarativeTestFactory() {} - - virtual QObject *createTest(QDeclarativeDebugTestData *data) = 0; }; class QDeclarativeDebugTestService : public QDeclarativeDebugService @@ -131,20 +91,4 @@ private: QByteArray lastMsg; }; -class tst_QDeclarativeDebug_Thread : public QThread -{ - Q_OBJECT -public: - tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory); - - void run(); - -signals: - void testsFinished(int); - -private: - QDeclarativeDebugTestData *m_data; - QDeclarativeTestFactory *m_factory; -}; - -- cgit v0.12 From daa12d2d6658924aae22cfbb93cfbc77240f26ba Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 15:39:42 +1000 Subject: Doc: Put "default" property label on same line as property name Task-number: QTBUG-6336 --- doc/src/template/style/style.css | 6 ++++++ tools/qdoc3/htmlgenerator.cpp | 13 +++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index 4668c23..94a95a5 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -904,6 +904,12 @@ color: red; } + .qmldefault + { + float: right; + color: red; + } + .qmldoc { } diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 4985f64..a13fc7a 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4412,18 +4412,11 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << ""; out() << ""; if (!qpn->isWritable()) - out() << "read-only"; + out() << "read-only "; + if (qpgn->isDefault()) + out() << "default "; generateQmlItem(qpn, relative, marker, false); out() << ""; - if (qpgn->isDefault()) { - out() << "" - << "" - << "
" - << "
" - << "" - << ""; - } } ++p; } -- cgit v0.12 From ecdc0ebacd97f0d607dcbe884751c203a296a88c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 15:41:26 +1000 Subject: Doc: in QML use "real" and "enumeration", not "qreal" and "enum" --- doc/src/declarative/elements.qdoc | 7 +------ .../graphicsitems/qdeclarativeborderimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeevents.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeloader.cpp | 4 ++-- src/declarative/util/qdeclarativeanimation.cpp | 4 ++-- src/declarative/util/qdeclarativefontloader.cpp | 2 +- src/declarative/util/qdeclarativesmoothedanimation.cpp | 4 ++-- src/declarative/util/qdeclarativesmoothedfollow.cpp | 4 ++-- src/declarative/util/qdeclarativespringfollow.cpp | 16 ++++++++-------- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 +- 12 files changed, 23 insertions(+), 28 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index ce3a6e3..355c0f4 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -46,8 +46,6 @@ The following table lists the QML elements provided by the Qt Declarative module. -\bold {Standard Qt Declarative Elements} - \table 80% \header \o \bold {States} @@ -81,6 +79,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l PropertyAction \o \l ScriptAction \o \l Transition +\o \l SmoothedFollow \o \l SpringFollow \o \l Behavior \endlist @@ -109,11 +108,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l QtObject \o \l WorkerScript \endlist -\endtable -\bold {QML Items} - -\table 80% \header \o \bold {Basic Visual Items} \o \bold {Basic Interaction Items} diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index be9d8bd..7858a7a 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -82,7 +82,7 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() QDeclarativePixmapCache::cancel(d->sciurl, this); } /*! - \qmlproperty enum BorderImage::status + \qmlproperty enumeration BorderImage::status This property holds the status of image loading. It can be one of: \list diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp index a181071..4425c97 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents.cpp +++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp @@ -145,7 +145,7 @@ Item { */ /*! - \qmlproperty enum MouseEvent::button + \qmlproperty enumeration MouseEvent::button This property holds the button that caused the event. It can be one of: \list diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index ca86637..37b07bf 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -221,7 +221,7 @@ qreal QDeclarativeImage::paintedHeight() const } /*! - \qmlproperty enum Image::status + \qmlproperty enumeration Image::status This property holds the status of image loading. It can be one of: \list diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 0e4e327..843dfdc 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1415,7 +1415,7 @@ QDeclarativeItem::~QDeclarativeItem() } /*! - \qmlproperty enum Item::transformOrigin + \qmlproperty enumeration Item::transformOrigin This property holds the origin point around which scale and rotation transform. Nine transform origins are available, as shown in the image below. diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 409c228..8cf8235 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -325,7 +325,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() } /*! - \qmlproperty enum Loader::status + \qmlproperty enumeration Loader::status This property holds the status of QML loading. It can be one of: \list @@ -383,7 +383,7 @@ qreal QDeclarativeLoader::progress() const } /*! - \qmlproperty enum Loader::resizeMode + \qmlproperty enumeration Loader::resizeMode This property determines how the Loader or item are resized: \list diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 7e20428..fd85d91 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1316,7 +1316,7 @@ void QDeclarativeRotationAnimation::setTo(qreal t) } /*! - \qmlproperty enum RotationAnimation::direction + \qmlproperty enumeration RotationAnimation::direction The direction in which to rotate. Possible values are Numerical, Clockwise, Counterclockwise, or Shortest. @@ -1741,7 +1741,7 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) } /*! - \qmlproperty enum PropertyAnimation::easing.type + \qmlproperty enumeration PropertyAnimation::easing.type \qmlproperty real PropertyAnimation::easing.amplitude \qmlproperty real PropertyAnimation::easing.overshoot \qmlproperty real PropertyAnimation::easing.period diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index b577b81..41740a8 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -181,7 +181,7 @@ void QDeclarativeFontLoader::setName(const QString &name) } /*! - \qmlproperty enum FontLoader::status + \qmlproperty enumeration FontLoader::status This property holds the status of font loading. It can be one of: \list diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 48a7583..19a00ee 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -438,7 +438,7 @@ qreal QDeclarativeSmoothedAnimation::velocity() const } /*! - \qmlproperty qreal SmoothedAnimation::velocity + \qmlproperty real SmoothedAnimation::velocity This property holds the average velocity allowed when tracking the 'to' value. @@ -457,7 +457,7 @@ void QDeclarativeSmoothedAnimation::setVelocity(qreal v) } /*! - \qmlproperty qreal SmoothedAnimation::maximumEasingTime + \qmlproperty int SmoothedAnimation::maximumEasingTime This property specifies the maximum time, in msecs, an "eases" during the follow should take. Setting this property causes the velocity to "level out" after at a time. Setting diff --git a/src/declarative/util/qdeclarativesmoothedfollow.cpp b/src/declarative/util/qdeclarativesmoothedfollow.cpp index 9f155fc..3ed9257 100644 --- a/src/declarative/util/qdeclarativesmoothedfollow.cpp +++ b/src/declarative/util/qdeclarativesmoothedfollow.cpp @@ -195,7 +195,7 @@ qreal QDeclarativeSmoothedFollow::velocity() const } /*! - \qmlproperty qreal SmoothedFollow::velocity + \qmlproperty real SmoothedFollow::velocity This property holds the average velocity allowed when tracking the 'to' value. @@ -214,7 +214,7 @@ void QDeclarativeSmoothedFollow::setVelocity(qreal v) } /*! - \qmlproperty qreal SmoothedFollow::maximumEasingTime + \qmlproperty int SmoothedFollow::maximumEasingTime This property specifies the maximum time, in msecs, an "eases" during the follow should take. Setting this property causes the velocity to "level out" after at a time. Setting diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp index 7921735..70077f3 100644 --- a/src/declarative/util/qdeclarativespringfollow.cpp +++ b/src/declarative/util/qdeclarativespringfollow.cpp @@ -267,7 +267,7 @@ qreal QDeclarativeSpringFollow::to() const } /*! - \qmlproperty qreal SpringFollow::to + \qmlproperty real SpringFollow::to This property holds the target value which will be tracked. Bind to a property in order to track its changes. @@ -284,7 +284,7 @@ void QDeclarativeSpringFollow::setTo(qreal value) } /*! - \qmlproperty qreal SpringFollow::velocity + \qmlproperty real SpringFollow::velocity This property holds the maximum velocity allowed when tracking the source. */ @@ -303,7 +303,7 @@ void QDeclarativeSpringFollow::setVelocity(qreal velocity) } /*! - \qmlproperty qreal SpringFollow::spring + \qmlproperty real SpringFollow::spring This property holds the spring constant The spring constant describes how strongly the target is pulled towards the @@ -326,7 +326,7 @@ void QDeclarativeSpringFollow::setSpring(qreal spring) } /*! - \qmlproperty qreal SpringFollow::damping + \qmlproperty real SpringFollow::damping This property holds the spring damping constant The damping constant describes how quickly a sprung follower comes to rest. @@ -349,7 +349,7 @@ void QDeclarativeSpringFollow::setDamping(qreal damping) /*! - \qmlproperty qreal SpringFollow::epsilon + \qmlproperty real SpringFollow::epsilon This property holds the spring epsilon The epsilon is the rate and amount of change in the value which is close enough @@ -371,7 +371,7 @@ void QDeclarativeSpringFollow::setEpsilon(qreal epsilon) } /*! - \qmlproperty qreal SpringFollow::modulus + \qmlproperty real SpringFollow::modulus This property holds the modulus value. Setting a \a modulus forces the target value to "wrap around" at the modulus. @@ -394,7 +394,7 @@ void QDeclarativeSpringFollow::setModulus(qreal modulus) } /*! - \qmlproperty qreal SpringFollow::mass + \qmlproperty real SpringFollow::mass This property holds the "mass" of the property being moved. mass is 1.0 by default. Setting a different mass changes the dynamics of @@ -452,7 +452,7 @@ bool QDeclarativeSpringFollow::inSync() const } /*! - \qmlproperty qreal SpringFollow::value + \qmlproperty real SpringFollow::value The current value. */ qreal QDeclarativeSpringFollow::value() const diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 7f8b962..55e768e 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -667,7 +667,7 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati } /*! - \qmlproperty enum XmlListModel::status + \qmlproperty enumeration XmlListModel::status Specifies the model loading status, which can be one of the following: \list -- cgit v0.12 From 39653e0ff461875b5bbe31c955a7c217abc2931f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Apr 2010 15:42:55 +1000 Subject: Don't use zoomfactor. It gives better resolution for text positioning, btu many web sites don't work well with it and WebKit. --- demos/declarative/webbrowser/content/FlickableWebView.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 81904c6..46f45e0 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -45,7 +45,7 @@ Flickable { smoothCache: true // We do want smooth rendering fillColor: "white" focus: true - zoomFactor: 4 + zoomFactor: 1 onAlert: console.log(message) @@ -73,7 +73,7 @@ Flickable { contentsScale: 1/zoomFactor onContentsSizeChanged: { // zoom out - contentsScale = Math.min(0.25,flickable.width / contentsSize.width) + contentsScale = Math.min(1,flickable.width / contentsSize.width) } onUrlChanged: { // got to topleft -- cgit v0.12 From a8003df9c7d17a7cdb94161a0aa1b553a30a68e4 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Apr 2010 16:16:52 +1000 Subject: Ensure existing image is gone before next photo selection. Task-number: QTBUG-8084 --- demos/declarative/flickr/mobile/TitleBar.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index 72b779f..71d9385 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -12,6 +12,7 @@ Item { width: (parent.width * 2) - 55 ; height: parent.height function accept() { + imageDetails.closed() titleBar.state = "" background.state = "" rssModel.tags = editor.text -- cgit v0.12 From c01c0c9746fbd54d29683b79de2bf973e5c40cec Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 16:19:35 +1000 Subject: More QML doc consistency. --- src/imports/multimedia/qdeclarativeaudio.cpp | 10 +++++----- src/imports/multimedia/qdeclarativevideo.cpp | 16 ++++++++-------- src/imports/particles/qdeclarativeparticles.cpp | 14 +++++++------- src/multimedia/effects/qsoundeffect.cpp | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 82d5d89..849c51d 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -195,7 +195,7 @@ void QDeclarativeAudio::stop() */ /*! - \qmlproperty enum Audio::status + \qmlproperty enumeration Audio::status This property holds the status of media loading. It can be one of: @@ -263,7 +263,7 @@ QDeclarativeAudio::Status QDeclarativeAudio::status() const */ /*! - \qmlproperty qreal Audio::volume + \qmlproperty real Audio::volume This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). */ @@ -275,7 +275,7 @@ QDeclarativeAudio::Status QDeclarativeAudio::status() const */ /*! - \qmlproperty qreal Audio::bufferProgress + \qmlproperty real Audio::bufferProgress This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 (full). @@ -290,13 +290,13 @@ QDeclarativeAudio::Status QDeclarativeAudio::status() const */ /*! - \qmlproperty qreal Audio::playbackRate + \qmlproperty real Audio::playbackRate This property holds the rate at which audio is played at as a multiple of the normal rate. */ /*! - \qmlproperty enum Audio::error + \qmlproperty enumeration Audio::error This property holds the error state of the audio. It can be one of: diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp index c6ae272..d84d304 100644 --- a/src/imports/multimedia/qdeclarativevideo.cpp +++ b/src/imports/multimedia/qdeclarativevideo.cpp @@ -82,11 +82,11 @@ void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) Video { source: "video/movie.mpg" } \endqml - The video item supports untransformed, stretched, and uniformly scaled video presentation. + The Video item supports untransformed, stretched, and uniformly scaled video presentation. For a description of stretched uniformly scaled presentation, see the \l fillMode property description. - The video item is only visible when the \l hasVideo property is true and the video is playing. + The Video item is only visible when the \l hasVideo property is true and the video is playing. \sa Audio */ @@ -169,7 +169,7 @@ QDeclarativeVideo::~QDeclarativeVideo() */ /*! - \qmlproperty enum Video::status + \qmlproperty enumeration Video::status This property holds the status of media loading. It can be one of: @@ -236,7 +236,7 @@ QDeclarativeVideo::Status QDeclarativeVideo::status() const */ /*! - \qmlproperty qreal Video::volume + \qmlproperty real Video::volume This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume). */ @@ -270,7 +270,7 @@ bool QDeclarativeVideo::hasVideo() const } /*! - \qmlproperty qreal Video::bufferProgress + \qmlproperty real Video::bufferProgress This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0 (full). @@ -283,13 +283,13 @@ bool QDeclarativeVideo::hasVideo() const */ /*! - \qmlproperty qreal Video::playbackRate + \qmlproperty real Video::playbackRate This property holds the rate at which video is played at as a multiple of the normal rate. */ /*! - \qmlproperty enum Video::error + \qmlproperty enumeration Video::error This property holds the error state of the video. It can be one of: @@ -325,7 +325,7 @@ QDeclarativeVideo::Error QDeclarativeVideo::error() const */ /*! - \qmlproperty enum Video::fillMode + \qmlproperty enumeration Video::fillMode Set this property to define how the video is scaled to fit the target area. diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index 264cba2..ecc6604 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -189,13 +189,13 @@ void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int inte */ /*! - \qmlproperty qreal ParticleMotionGravity::xattractor - \qmlproperty qreal ParticleMotionGravity::yattractor + \qmlproperty real ParticleMotionGravity::xattractor + \qmlproperty real ParticleMotionGravity::yattractor These properties hold the x and y coordinates of the point attracting the particles. */ /*! - \qmlproperty qreal ParticleMotionGravity::acceleration + \qmlproperty real ParticleMotionGravity::acceleration This property holds the acceleration to apply to the particles. */ @@ -303,14 +303,14 @@ Rectangle { */ /*! - \qmlproperty qreal QDeclarativeParticleMotionWander::xvariance - \qmlproperty qreal QDeclarativeParticleMotionWander::yvariance + \qmlproperty real QDeclarativeParticleMotionWander::xvariance + \qmlproperty real QDeclarativeParticleMotionWander::yvariance These properties set the amount to wander in the x and y directions. */ /*! - \qmlproperty qreal QDeclarativeParticleMotionWander::pace + \qmlproperty real QDeclarativeParticleMotionWander::pace This property holds how quickly the paricles will move from side to side. */ @@ -859,7 +859,7 @@ void QDeclarativeParticles::setEmissionRate(int er) } /*! - \qmlproperty qreal Particles::emissionVariance + \qmlproperty real Particles::emissionVariance This property holds how inconsistent the rate of particle emissions are. It is a number between 0 (no variance) and 1 (some variance). diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp index d34e532..1992ee5 100644 --- a/src/multimedia/effects/qsoundeffect.cpp +++ b/src/multimedia/effects/qsoundeffect.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass SoundEffect QSoundEffect \since 4.7 - \brief The SoundEffect element provides a way to play sound effects in qml. + \brief The SoundEffect element provides a way to play sound effects in QML. This element is part of the \bold{Qt.multimedia 4.7} module. @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty QUrl SoundEffect::source + \qmlproperty url SoundEffect::source This property provides a way to control the sound to play. */ -- cgit v0.12 From f38c026421febb58686b25d4fb1ca94787f7c4ee Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 16 Apr 2010 16:29:39 +1000 Subject: Documentation typo. --- doc/src/declarative/javascriptblocks.qdoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index 8ffe58c..e5e61f2 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -47,7 +47,7 @@ QML encourages building UIs declaratively, using \l {Property Binding} and the composition of existing \l {QML Elements}. To allow the implementation of more advanced behavior, QML integrates tightly with imperative JavaScript code. -The JavaScript environment provided by QML is stricter than that in a webbrowser. +The JavaScript environment provided by QML is stricter than that in a web browser. In QML you cannot add, or modify, members of the JavaScript global object. It is possible to do this accidentally by using a variable without declaring it. In QML this will throw an exception, so all local variables should be explicitly @@ -104,12 +104,12 @@ Item { } \endcode -Both relative and absolute JavaScript URLs can be imported. In the case of a -relative URL, the location is resolved relative to the location of the -\l {QML Document} that contains the import. If the script file is not accessible, -an error will occur. If the JavaScript needs to be fetched from a network +Both relative and absolute JavaScript URLs can be imported. In the case of a +relative URL, the location is resolved relative to the location of the +\l {QML Document} that contains the import. If the script file is not accessible, +an error will occur. If the JavaScript needs to be fetched from a network resource, the QML document has a "Loading" -\l {QDeclarativeComponent::status()}{status} until the script has been +\l {QDeclarativeComponent::status()}{status} until the script has been downloaded. Imported JavaScript files are always qualified using the "as" keyword. The @@ -160,7 +160,7 @@ parameters. \section1 Running JavaScript at Startup It is occasionally necessary to run some imperative code at application (or -component instance) "startup". While it is tempting to just include the startup +component instance) startup. While it is tempting to just include the startup script as \e {global code} in an external script file, this can have severe limitations as the QML environment may not have been fully established. For example, some objects might not have been created or some \l {Property Binding}s may not have been run. @@ -180,7 +180,7 @@ Rectangle { } \endcode -Any element in a QML file - including nested elements and nested QML component +Any element in a QML file - including nested elements and nested QML component instances - can use this attached property. If there is more than one \c onCompleted() handler to execute at startup, they are run sequentially in an undefined order. -- cgit v0.12 From 731071ed146febd8d93e1897e7f1aba135ac23c4 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 16 Apr 2010 16:27:39 +1000 Subject: Remove unsupported plugin version flags in .pro files of declarative examples Task-number: QTBUG-9191 Reviewed-by: Martin Jones --- examples/declarative/plugins/plugins.pro | 1 - examples/declarative/proxywidgets/proxywidgets.pro | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro index c409d39..b501ae3 100644 --- a/examples/declarative/plugins/plugins.pro +++ b/examples/declarative/plugins/plugins.pro @@ -3,7 +3,6 @@ DESTDIR = com/nokia/TimeExample TARGET = qtimeexampleqmlplugin CONFIG += qt plugin QT += declarative -VERSION = 1.0.0 SOURCES += plugin.cpp diff --git a/examples/declarative/proxywidgets/proxywidgets.pro b/examples/declarative/proxywidgets/proxywidgets.pro index eb85191..cb07d80 100644 --- a/examples/declarative/proxywidgets/proxywidgets.pro +++ b/examples/declarative/proxywidgets/proxywidgets.pro @@ -3,7 +3,6 @@ DESTDIR = ProxyWidgets TARGET = proxywidgetsplugin CONFIG += qt plugin QT += declarative -VERSION = 1.0.0 SOURCES += proxywidgets.cpp -- cgit v0.12 From 269623184ee55bd8126cf3ae5cfb619d3bdda91b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 16 Apr 2010 18:34:10 +1000 Subject: Doc --- doc/src/declarative/javascriptblocks.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index e5e61f2..7c0570e 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -66,7 +66,7 @@ them. \code Item { function factorial(a) { - a = Integer(a); + a = parseInt(a); if (a <= 0) return 1; else @@ -143,7 +143,7 @@ stateless library through the use of a pragma, as shown in the following example .pragma library function factorial(a) { - a = Integer(a); + a = parseInt(a); if (a <= 0) return 1; else -- cgit v0.12 From 561a7bf35b96ffe70ebafc3876e965ef41b4441d Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 16 Apr 2010 11:15:55 +0200 Subject: Fixed parsing of inner labelled statements. The JS grammar is ambigious and the following statement can be parsed as an object-literal followed by an inserted semicolon or as two labelled statements. outer: { inner: {} } In the old days we used to resolve the conflict by reducing the statement to an expression statement but this was wrong so now we prefer the labelled statement. As nice side effect, we pass two more tests in tests/auto/declarative/parserstress. Task-number: QTBUG-8108 --- src/declarative/qml/parser/qdeclarativejs.g | 2 +- src/declarative/qml/parser/qdeclarativejsgrammar.cpp | 6 +++--- tests/auto/declarative/parserstress/tst_parserstress.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g index ba9338e..1b66ba0 100644 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ b/src/declarative/qml/parser/qdeclarativejs.g @@ -1376,7 +1376,7 @@ case $rule_number: { } break; ./ -PropertyName: T_IDENTIFIER %prec REDUCE_HERE ; +PropertyName: T_IDENTIFIER %prec SHIFT_THERE ; /. case $rule_number: { AST::IdentifierPropertyName *node = makeAstNode (driver->nodePool(), sym(1).sval); diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp index 52e979a..b87d8f4 100644 --- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp +++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ // This file was generated by qlalr - DO NOT EDIT! -#include "private/qdeclarativejsgrammar_p.h" +#include "qdeclarativejsgrammar_p.h" QT_BEGIN_NAMESPACE @@ -346,9 +346,9 @@ const short QDeclarativeJSGrammar::action_index [] = { const short QDeclarativeJSGrammar::action_info [] = { 399, 352, 345, -101, 343, 457, 440, 403, 257, -112, - -125, -131, -123, -98, -120, 348, -128, 389, 453, 391, + -125, -131, -123, 346, -120, 348, -128, 389, 453, 391, 416, 401, 408, 563, -101, -123, 416, -120, 539, -131, - -98, -112, -125, 348, 257, 99, 71, 645, 621, 101, + 346, -112, -125, 348, 257, 99, 71, 645, 621, 101, -128, 440, 141, 621, 164, 431, 539, 430, 453, 573, 457, 444, 440, 424, 71, 424, 101, 446, 559, 420, 424, 448, 539, 440, 570, 539, 466, 527, 312, 346, diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 41c0a1b..971496d 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -65,7 +65,7 @@ QStringList tst_parserstress::findJSFiles(const QDir &d) { QStringList rv; - QStringList files = d.entryList(QStringList() << QLatin1String("*.js"), + QStringList files = d.entryList(QStringList() << QLatin1String("*.js"), QDir::Files); foreach (const QString &file, files) { if (file == "browser.js") @@ -73,7 +73,7 @@ QStringList tst_parserstress::findJSFiles(const QDir &d) rv << d.absoluteFilePath(file); } - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); foreach (const QString &dir, dirs) { QDir sub = d; @@ -132,7 +132,7 @@ void tst_parserstress::ecmascript() component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); QSet failingTests; failingTests << "uc-003.js" << "uc-005.js" << "regress-352044-02-n.js" - << "regress-334158.js" << "regress-58274.js" << "dowhile-006.js" << "dowhile-005.js"; + << "regress-334158.js" << "regress-58274.js"; QFileInfo info(file); foreach (const QString &failing, failingTests) { if (info.fileName().endsWith(failing)) { -- cgit v0.12 From 00d9ffa077d48e1d1c5ee40594e609522d055cdf Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 15 Apr 2010 12:00:03 +0200 Subject: Fix doc: remote contents requires qmldir --- doc/src/declarative/network.qdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc index 0a26c68..d268a13 100644 --- a/doc/src/declarative/network.qdoc +++ b/doc/src/declarative/network.qdoc @@ -69,8 +69,10 @@ Network transparency is supported throughout QML, for example: \endlist Even QML types themselves can be on the network - if the \l {Qt Declarative UI Runtime}{qml} tool is used to load -\tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", this -will load from \tt http://example.com/mystuff/World.qml just as it would for a local file. +\tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", the engine +will load \tt http://example.com/mystuff/qmldir and resolve the type just as it would for a local file. +For example if the qmldir file contains the line "World World.qml", it will load +\tt http://example.com/mystuff/World.qml Any other resources that \tt Hello.qml referred to, usually by a relative URL, would similarly be loaded from the network. -- cgit v0.12 From c8a26b05c342d05e718c118fe6279021c4cadf14 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 16 Apr 2010 13:58:54 +0200 Subject: Fix doc: QML_DECLARE_TYPE is no longer necessary It's sufficient to register a type with qmlRegisterType() --- doc/src/declarative/extending.qdoc | 21 +++------------------ doc/src/declarative/qtdeclarative.qdoc | 6 +----- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index e1c6469..4d477c6 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -67,12 +67,11 @@ that derive from QObject. The QML engine has no intrinsic knowledge of any class types. Instead the programmer must define the C++ types, and their corresponding QML name. -Custom C++ types are declared QML types using a macro and a template function: +Custom C++ types are registered using a template function: \quotation \code -#define QML_DECLARE_TYPE(T) template int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) \endcode @@ -81,10 +80,6 @@ Calling qmlRegisterType() registers the C++ type \a T with the QML system, and m under the name \a qmlName in library \a uri version \a versionMajor.versionMinor. The \a qmlName can be the same as the C++ type name. -Generally the QML_DECLARE_TYPE() macro should be included immediately following -the type declaration (usually in its header file), and the template function qmlRegisterType() -called by the implementation. - Type \a T must be a concrete type that inherits QObject and has a default constructor. \endquotation @@ -149,21 +144,16 @@ property can be assigned. QML also supports assigning Qt interfaces. To assign to a property whose type is a Qt interface pointer, the interface must also be registered with QML. As they cannot be instantiated directly, registering a Qt interface is different -from registering a new QML type. The following macro and function are used instead: +from registering a new QML type. The following function is used instead: \quotation \code -#define QML_DECLARE_INTERFACE(T) template int qmlRegisterInterface(const char *typeName) \endcode Registers the C++ interface \a T with the QML system as \a typeName. -Generally the QML_DECLARE_INTERFACE() macro should be included immediately -following the interface declaration (usually in its header file), and the -qmlRegisterInterface() template function called by the implementation. - Following registration, QML can coerce objects that implement this interface for assignment to appropriately typed properties. \endquotation @@ -198,11 +188,10 @@ To assign to a property, the property's type must have been registered with QML. Both the qmlRegisterType() and qmlRegisterInterface() template functions already shown can be used to register a type with QML. Additionally, if a type that acts purely as a base class that cannot be instantiated from QML needs to be -registered these macro and function can be used: +registered, the following function can be used: \quotation \code - #define QML_DECLARE_TYPE(T) template int qmlRegisterType() \endcode @@ -212,10 +201,6 @@ function qmlRegisterType() does not define a mapping between the C++ class and a QML element name, so the type is not instantiable from QML, but it is available for type coercion. -Generally the QML_DECLARE_TYPE() macro should be included immediately following -the type declaration (usually in its header file), and the -qmlRegisterType() template function called from the implementation. - Type \a T must inherit QObject, but there are no restrictions on whether it is concrete or the signature of its constructor. \endquotation diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index cbb2146..b4d8a2e 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -70,9 +70,7 @@ \macro QML_DECLARE_TYPE() \relates QDeclarativeEngine - Declares a C++ type to be usable in the QML system. In addition - to this, a type must also be registered with the QML system using - qmlRegisterType(). + Equivalent to Q_DECLARE_METATYPE(TYPE) and Q_DECLARE_METATYPE(QDeclarativeListProperty) */ @@ -83,7 +81,6 @@ This template function registers the C++ type in the QML system with the name \a qmlName. in the library imported from \a uri having the version number composed from \a versionMajor and \a versionMinor. - The type should also haved been declared with the QML_DECLARE_TYPE() macro. Returns the QML type id. @@ -114,7 +111,6 @@ This template function registers the C++ type in the QML system under the name \a typeName. - The type should also haved been declared with the QML_DECLARE_TYPE() macro. Returns the QML type id. -- cgit v0.12 From 86efad03a977763c900aaa0b634f64c109a27e4f Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 16 Apr 2010 14:01:29 +0200 Subject: Fix README The base directory is no longer automatically used as import path. --- examples/declarative/plugins/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README index 3ae256d..fe519f8 100644 --- a/examples/declarative/plugins/README +++ b/examples/declarative/plugins/README @@ -5,5 +5,5 @@ by a C++ plugin (providing the "Time" type), and by QML files (providing the To run: make install - qml plugins.qml + qml -I . plugins.qml -- cgit v0.12 From e23a519366587cfc27ad3be88180692cb49e206f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 16 Apr 2010 15:01:39 +0200 Subject: Recognize identifiers containing unicode escape sequences. Task-number: QTBUG-8108 Reviewed-by: Olivier Goffart --- src/declarative/qml/parser/qdeclarativejslexer.cpp | 42 +++++++++++++++++++++- .../declarative/parserstress/tst_parserstress.cpp | 4 +-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp index a616146..7c1c30c 100644 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp @@ -484,6 +484,8 @@ int Lexer::lex() stackToken = -1; } + bool identifierWithEscapedUnicode = false; + while (!done) { switch (state) { case Start: @@ -523,7 +525,26 @@ int Lexer::lex() state = InString; multiLineString = false; stringType = current; + } else if (current == '\\' && next1 == 'u') { + identifierWithEscapedUnicode = true; + recordStartPos(); + + shift(2); // skip the unicode escape prefix `\u' + + if (isHexDigit(current) && isHexDigit(next1) && + isHexDigit(next2) && isHexDigit(next3)) { + record16(convertUnicode(current, next1, next2, next3)); + shift(3); + state = InIdentifier; + } else { + setDone(Bad); + err = IllegalUnicodeEscapeSequence; + errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); + break; + } + } else if (isIdentLetter(current)) { + identifierWithEscapedUnicode = false; recordStartPos(); record16(current); state = InIdentifier; @@ -683,6 +704,21 @@ int Lexer::lex() if (isIdentLetter(current) || isDecimalDigit(current)) { record16(current); break; + } else if (current == '\\' && next1 == 'u') { + identifierWithEscapedUnicode = true; + shift(2); // skip the unicode escape prefix `\u' + + if (isHexDigit(current) && isHexDigit(next1) && + isHexDigit(next2) && isHexDigit(next3)) { + record16(convertUnicode(current, next1, next2, next3)); + shift(3); + break; + } else { + setDone(Bad); + err = IllegalUnicodeEscapeSequence; + errmsg = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); + break; + } } setDone(Identifier); break; @@ -825,7 +861,11 @@ int Lexer::lex() delimited = true; return token; case Identifier: - if ((token = findReservedWord(buffer16, pos16)) < 0) { + token = -1; + if (! identifierWithEscapedUnicode) + token = findReservedWord(buffer16, pos16); + + if (token < 0) { /* TODO: close leak on parse error. same holds true for String */ if (driver) qsyylval.ustr = driver->intern(buffer16, pos16); diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 971496d..f61ca9f 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -131,8 +131,8 @@ void tst_parserstress::ecmascript() QDeclarativeComponent component(&engine); component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); QSet failingTests; - failingTests << "uc-003.js" << "uc-005.js" << "regress-352044-02-n.js" - << "regress-334158.js" << "regress-58274.js"; + failingTests << "regress-352044-02-n.js" + << "regress-334158.js"; QFileInfo info(file); foreach (const QString &failing, failingTests) { if (info.fileName().endsWith(failing)) { -- cgit v0.12
" - << "default