From 953d3fbe53e77261c57612aad35ffb34cde95ecb Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 09:03:59 +1000 Subject: namespaces doc --- doc/src/declarative/components.qdoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/src/declarative/components.qdoc b/doc/src/declarative/components.qdoc index 6564375..3b37c45 100644 --- a/doc/src/declarative/components.qdoc +++ b/doc/src/declarative/components.qdoc @@ -78,15 +78,15 @@ MyButton { label: "Reset"; onClicked: resetData() } \section1 Placing .qml Files -Component files should be placed in specific locations in order to be found by the Qml engine: +When one component refers to a another, the second must be found either in the same directory +as the first, or in a directory imported using the \c import statement: -\list -\o the run directory -\o the run directory + "/qml" -\o the directory of the Qml you are running -\o the directory of the Qml you are running + "/qml" -\endlist +\code +import "library" +\endcode + +\section1 Namespaces -In the future library-like directories will be defined (in the meantime the first two options above effectively serve this purpose). +Namespaces for QML will be supported in Qt 4.6. */ -- cgit v0.12 From 3df1b31051a908d165d9ea18d0d18c36a4748408 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 09:05:37 +1000 Subject: default QGV --- src/declarative/canvas/qsimplecanvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp index 1911b35..ce02a4c 100644 --- a/src/declarative/canvas/qsimplecanvas.cpp +++ b/src/declarative/canvas/qsimplecanvas.cpp @@ -556,7 +556,7 @@ QSimpleCanvas::QSimpleCanvas(CanvasMode mode, QWidget *parent) QSimpleCanvas::QSimpleCanvas(QWidget *parent) : QWidget(parent), d(new QSimpleCanvasPrivate(this)) { - d->init(useGraphicsView()?GraphicsView:SimpleCanvas); + d->init(useGraphicsView()?SimpleCanvas:GraphicsView); } void QSimpleCanvasPrivate::init(QSimpleCanvas::CanvasMode mode) -- cgit v0.12 From 76408fe44b1b28fbe20c1ada0f1a7f728c1483d1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 09:55:24 +1000 Subject: default to QGV --- doc/src/declarative/examples.qdoc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index fa9f05b..5ffcbf6 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -27,9 +27,4 @@ to be instructive on specific elements. Finally, check out the \l {tutorial} to learn a little more about writing your own QML-based applications. - -\note When running applications that only use the Fluid UI atoms under the -software rasterizer, a simple canvas backend is used by default. To use -Graphics View instead, set \c QML_USE_GRAPHICSVIEW=1. - */ -- cgit v0.12 From 627f9b09896a1933dd55e1157a06bdec84c7d70c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 09:55:41 +1000 Subject: white background no good in web page, go gray --- doc/src/declarative/tutorial1.qdoc | 4 ++-- doc/src/declarative/tutorial2.qdoc | 2 +- doc/src/declarative/tutorial3.qdoc | 2 +- doc/src/images/declarative-tutorial1.png | Bin 3416 -> 3025 bytes doc/src/images/declarative-tutorial2.png | Bin 3145 -> 3050 bytes doc/src/images/declarative-tutorial3_animation.gif | Bin 42486 -> 38111 bytes .../tutorials/helloworld/t1/tutorial1.qml | 2 +- .../tutorials/helloworld/t2/tutorial2.qml | 2 +- .../tutorials/helloworld/t3/tutorial3.qml | 2 +- 9 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index c2e3e22..6bb5012 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -14,7 +14,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" @@ -35,7 +35,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" } \endcode diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index 54f1828..1535c42 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -37,7 +37,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 3ac22a1..0b97e63 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -16,7 +16,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" diff --git a/doc/src/images/declarative-tutorial1.png b/doc/src/images/declarative-tutorial1.png index a936054..ea0000f 100644 Binary files a/doc/src/images/declarative-tutorial1.png and b/doc/src/images/declarative-tutorial1.png differ diff --git a/doc/src/images/declarative-tutorial2.png b/doc/src/images/declarative-tutorial2.png index 7871589..0538451 100644 Binary files a/doc/src/images/declarative-tutorial2.png and b/doc/src/images/declarative-tutorial2.png differ diff --git a/doc/src/images/declarative-tutorial3_animation.gif b/doc/src/images/declarative-tutorial3_animation.gif index 0465e61..d2d4c63 100644 Binary files a/doc/src/images/declarative-tutorial3_animation.gif and b/doc/src/images/declarative-tutorial3_animation.gif differ diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml index ec29f4f..4e53b8e 100644 --- a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +++ b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml @@ -2,7 +2,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml index 4630435..6c7e68e 100644 --- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml @@ -2,7 +2,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index 3ca7a2f..bd89ecf 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -2,7 +2,7 @@ Rect { id: Page width: 480 height: 200 - color: "white" + color: "LightGrey" Text { id: HelloText text: "Hello world!" -- cgit v0.12 From 2dd06e645cb6e1ffca1274864a62418a2ebe6504 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 11:32:07 +1000 Subject: doc --- doc/src/declarative/components.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/components.qdoc b/doc/src/declarative/components.qdoc index 3b37c45..d7a4ba6 100644 --- a/doc/src/declarative/components.qdoc +++ b/doc/src/declarative/components.qdoc @@ -13,8 +13,8 @@ Writing and using components allows you to: \endlist Components are placed in \e .qml files, allowing \e to then be used as a tag -elsewhere. For example, if you have a Slider.qml file, you can then use \c {Slider \{\}} to -place a slider. +elsewhere. For example, if you have a Slider.qml file, you can then use \c {Slider { ... }} to +make a slider, just as if it was a built-in type. Components may be collected into \l {qmlmodules}{modules}. -- cgit v0.12 From 990e4215926c5fd2327e379f6ef872b8274a7f67 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 7 May 2009 11:32:17 +1000 Subject: Fix QmlXmlListModel on property changes, on empty results. Tags in flickr demo. --- demos/declarative/flickr/content/ImageDetails.qml | 5 +++ demos/declarative/flickr/flickr.qml | 13 ++++--- src/declarative/extra/qmlxmllistmodel.cpp | 42 ++++++++++++++++++----- src/declarative/extra/qmlxmllistmodel.h | 2 +- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 7b16831..d721983 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -6,6 +6,7 @@ Flipable { property var fullScreenArea: BigImage property string photoTitle: "" property string photoDescription: "" + property string photoTags: "" property int photoWidth property int photoHeight property string photoType @@ -58,6 +59,10 @@ Flipable { text: "Author: " + Container.photoAuthor } Text { id: Date; color: "white"; width: 300; x: 220; anchors.top: Author.bottom text: "Published: " + Container.photoDate } + Text { id: TagsLabel; color: "white"; x: 220; anchors.top: Date.bottom; + text: Container.photoTags == "" ? "" : "Tags: " } + Text { id: Tags; color: "white"; width: parent.width-x-20; anchors.left: TagsLabel.right; anchors.top: Date.bottom; elide: "ElideRight" + text: Container.photoTags == "" ? "" : Container.photoTags } ScrollBar { id: ScrollBar; x: 720; y: Flickable.y; width: 7; height: Flickable.height; opacity: 0; flickableArea: Flickable; clip: true } diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 0ff539d..676e51b 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -8,7 +8,8 @@ Item { resources: [ XmlListModel { id: FeedModel - source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" + property string tags : "" + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" query: "doc($src)/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" @@ -16,6 +17,7 @@ Item { Role { name: "imagePath"; query: "media:thumbnail/@url/string()" } Role { name: "url"; query: "media:content/@url/string()" } Role { name: "description"; query: "description/string()"; isCData: true } + Role { name: "tags"; query: "media:category/string()" } Role { name: "photoWidth"; query: "media:content/@width/string()" } Role { name: "photoHeight"; query: "media:content/@height/string()" } Role { name: "photoType"; query: "media:content/@type/string()" } @@ -44,6 +46,7 @@ Item { ImageDetails.flickableArea.yPosition = 0; ImageDetails.fullScreenArea.source = ""; ImageDetails.photoDescription = description; + ImageDetails.photoTags = tags; ImageDetails.photoWidth = photoWidth; ImageDetails.photoHeight = photoHeight; ImageDetails.photoType = photoType; @@ -134,7 +137,7 @@ Item { } PathAttribute { name: "scale"; value: 1 } - PathAttribute { name: "angle"; value: 45 } + PathAttribute { name: "angle"; value: -45 } } } @@ -151,7 +154,7 @@ Item { text: "Update" anchors.right: CloseButton.left; anchors.rightMargin: 5 anchors.top: CloseButton.top - onClicked: { FeedModel.fetch(); } + onClicked: { FeedModel.reload(); } } states: [ @@ -172,7 +175,9 @@ Item { } Text { - id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15; text: "Flickr - Uploads from everyone" + id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15; + text: "Flickr - " + + (FeedModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + FeedModel.tags) font.size: 16; font.bold: true; color: "white"; style: "Raised"; styleColor: "black" } } diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index af72ecc..bba817d 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -90,8 +90,9 @@ class QmlXmlListModelPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlXmlListModel) public: - QmlXmlListModelPrivate() : size(-1), highestRole(Qt::UserRole), reply(0), roleObjects(this) {} + QmlXmlListModelPrivate() : isClassComplete(false), size(-1), highestRole(Qt::UserRole), reply(0), roleObjects(this) {} + bool isClassComplete; QString src; QString query; QString namespaces; @@ -204,7 +205,10 @@ QString QmlXmlListModel::source() const void QmlXmlListModel::setSource(const QString &src) { Q_D(QmlXmlListModel); - d->src = src; + if (d->src != src) { + d->src = src; + reload(); + } } QString QmlXmlListModel::query() const @@ -216,7 +220,10 @@ QString QmlXmlListModel::query() const void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); - d->query = query; + if (d->query != query) { + d->query = query; + reload(); + } } QString QmlXmlListModel::namespaceDeclarations() const @@ -228,29 +235,44 @@ QString QmlXmlListModel::namespaceDeclarations() const void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations) { Q_D(QmlXmlListModel); - d->namespaces = declarations; + if (d->namespaces != declarations) { + d->namespaces = declarations; + reload(); + } } void QmlXmlListModel::classComplete() { - fetch(); + Q_D(QmlXmlListModel); + d->isClassComplete = true; + reload(); } -void QmlXmlListModel::fetch() +void QmlXmlListModel::reload() { Q_D(QmlXmlListModel); + if (!d->isClassComplete) + return; + //clear existing data d->size = 0; int count = d->data.count(); d->data.clear(); - emit itemsRemoved(0, count); + if (count > 0) + emit itemsRemoved(0, count); if (d->src.isEmpty()) { - qWarning() << "Can't fetch empty src string"; + qWarning() << "Can't load empty src string"; return; } + if (d->reply) { + d->reply->abort(); + d->reply->deleteLater(); + d->reply = 0; + } + QNetworkRequest req((QUrl(d->src))); req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req); @@ -316,7 +338,9 @@ void QmlXmlListModel::doQuery(QByteArray &rawData) d->xml = xml; d->size = count; - emit itemsInserted(0, count); + + if (count > 0) + emit itemsInserted(0, count); } void QmlXmlListModel::doSubquery(int index) const diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index acc54a9..2e932cb 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -118,7 +118,7 @@ public: virtual void classComplete(); public Q_SLOTS: - void fetch(); + void reload(); protected: void doQuery(QByteArray &rawData); -- cgit v0.12