diff options
13 files changed, 64 insertions, 13 deletions
diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml index 52c7c1e..2aa15e5 100644 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml @@ -8,7 +8,8 @@ Item { property int activeSuns: 0 //This is a desktop-sized example - width: 1024; height: 512 + width: 800; height: 480 + //This is the message box that pops up when there's an error Rectangle { @@ -79,7 +80,7 @@ Item { Rectangle { id: toolbox - width: 480 + width: 380 color: activePalette.window anchors { right: parent.right; top: parent.top; bottom: parent.bottom } @@ -132,7 +133,7 @@ Item { Text { text: "Arbitrary QML:" } Rectangle { - width: 460; height: 240 + width: 360; height: 240 TextEdit { id: qmlText @@ -140,8 +141,9 @@ Item { readOnly: false focusOnPress: true font.pixelSize: 14 + wrapMode: TextEdit.WordWrap - text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" + text: "import Qt 4.7\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" } } diff --git a/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml b/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml new file mode 100644 index 0000000..de096ad --- /dev/null +++ b/examples/declarative/toys/dynamicscene/qml/GenericSceneItem.qml @@ -0,0 +1,9 @@ +import Qt 4.7 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/declarative/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js index f92dd15..305cf7a 100644 --- a/examples/declarative/toys/dynamicscene/qml/itemCreation.js +++ b/examples/declarative/toys/dynamicscene/qml/itemCreation.js @@ -36,7 +36,7 @@ function createItem() { } else if (itemComponent.status == Component.Error) { draggedItem = null; console.log("error creating component"); - console.log(component.errorString()); + console.log(itemComponent.errorString()); } } diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp index 1bbdd97..c8ecbb6 100644 --- a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass LayoutItem QDeclarativeLayoutItem \since 4.7 - \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. + \brief The LayoutItem element allows you to place your declarative UI elements inside a classical Qt layout. LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate, diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index ccabbde..d098aa0 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -380,7 +380,9 @@ void QDeclarativeRectangle::generateBorderedRect() key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16); if (!QPixmapCache::find(key, &d->rectImage)) { - d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3); + // Adding 5 here makes qDrawBorderPixmap() paint correctly with smooth: true + // See QTBUG-7999 and QTBUG-10765 for more details. + d->rectImage = QPixmap(pw*2 + 5, pw*2 + 5); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index e37b68b..4cde54b 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -259,8 +259,6 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn if (ctxt->argumentCount() == 0) return engine->undefinedValue(); - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QString urlString = ctxt->argument(0).toString(); QUrl url(ctxt->argument(0).toString()); if (url.isRelative()) { diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1365cd7..de1c0cb 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2543,7 +2543,6 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 9a5c9de..7518eb7 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -162,7 +162,7 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM spacing: 5 Text { text: "Attributes:" } Repeater { - dataSource: attributes + model: attributes Component { Text { text: description } } } } diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4a374a5..cae1d3a 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -423,6 +423,7 @@ public: int highestRole; QNetworkReply *reply; QDeclarativeXmlListModel::Status status; + QString errorString; qreal progress; int queryId; QStringList keyRoleResultsCache; @@ -495,10 +496,11 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla </rss> \endcode - Then it could be used to create the following model: + A XmlListModel could create a model from this data, like this: \qml XmlListModel { + id: xmlModel source: "http://www.mysite.com/feed.xml" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } @@ -511,6 +513,16 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla model item attributes; here, each model item will have \c title and \c pubDate attributes that match the \c title and \c pubDate values of its corresponding \c <item>. + The model could be used in a ListView, like this: + + \qml + ListView { + width: 180; height: 300 + model: xmlModel + delegate: Text { title + " (" + pubDate + ")" } + } + \endqml + \section2 Using key XML roles @@ -722,7 +734,8 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati \o XmlListModel.Null - No XML data has been set for this model. \o XmlListModel.Ready - The XML data has been loaded into the model. \o XmlListModel.Loading - The model is in the process of reading and loading XML data. - \o XmlListModel.Error - An error occurred while the model was loading. + \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details + about the error. \endlist \sa progress @@ -755,6 +768,12 @@ qreal QDeclarativeXmlListModel::progress() const return d->progress; } +QString QDeclarativeXmlListModel::errorString() const +{ + Q_D(const QDeclarativeXmlListModel); + return d->errorString; +} + void QDeclarativeXmlListModel::classBegin() { Q_D(QDeclarativeXmlListModel); @@ -807,6 +826,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); return; @@ -816,6 +836,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = XMLLISTMODEL_CLEAR_ID; d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); QTimer::singleShot(0, this, SLOT(dataCleared())); @@ -824,6 +845,7 @@ void QDeclarativeXmlListModel::reload() d->progress = 0.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); @@ -854,6 +876,7 @@ void QDeclarativeXmlListModel::requestFinished() d->redirectCount = 0; if (d->reply->error() != QNetworkReply::NoError) { + d->errorString = d->reply->errorString(); disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; @@ -919,6 +942,7 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & d->data = result.data; d->keyRoleResultsCache = result.keyRoleResultsCache; d->status = Ready; + d->errorString.clear(); d->queryId = -1; bool hasKeys = false; diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index 7b85476..7101c57 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -113,6 +113,8 @@ public: Status status() const; qreal progress() const; + Q_INVOKABLE QString errorString() const; + virtual void classBegin(); virtual void componentComplete(); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml index a883e85..1655905 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml @@ -31,6 +31,8 @@ QtObject { property string test21: g property string test22: h property bool test23: i + property color test24: j + property color test25: k property real a: 4.5 property real b: 11.2 @@ -41,4 +43,6 @@ QtObject { property variant g: 6.7 property variant h: "!" property variant i: true + property string j: "#112233" + property string k: "#aa112233" } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 4900fa2..9a8ad64 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2090,6 +2090,8 @@ void tst_qdeclarativeecmascript::compiled() QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); QCOMPARE(object->property("test23").toBool(), true); + QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33)); + QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA)); delete object; } diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 4173a44..7769979 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -268,10 +268,12 @@ void tst_qdeclarativexmllistmodel::xml() QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -284,6 +286,7 @@ void tst_qdeclarativexmllistmodel::xml() QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->count(), count); delete model; @@ -309,10 +312,12 @@ void tst_qdeclarativexmllistmodel::source() QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(0.0)); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); QCOMPARE(model->progress(), qreal(1.0)); QCOMPARE(model->count(), 9); @@ -320,6 +325,7 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->progress(), qreal(0.0)); QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QVERIFY(model->errorString().isEmpty()); QEventLoop loop; QTimer timer; @@ -337,9 +343,12 @@ void tst_qdeclarativexmllistmodel::source() QCOMPARE(model->status(), status); QCOMPARE(model->count(), count); + if (status == QDeclarativeXmlListModel::Ready) QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->errorString().isEmpty(), status == QDeclarativeXmlListModel::Ready); + delete model; } |