From d535797f7fd5eebbc5d0128a477c57f71632a377 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 2 Oct 2009 12:21:12 +1000 Subject: Make compile since QmlValuePropertySource is no longer a Qobject. --- .../extending/binding/happybirthday.cpp | 2 +- .../declarative/extending/binding/happybirthday.h | 6 ++- .../extending/valuesource/happybirthday.cpp | 2 +- .../extending/valuesource/happybirthday.h | 5 ++- examples/declarative/flowview/FlickrView.qml | 46 ++++++++++++++++++++++ examples/declarative/flowview/RoundedRect.qml | 4 ++ examples/declarative/flowview/flickr.qml | 46 ---------------------- examples/declarative/flowview/rect.qml | 4 -- src/declarative/util/qmlview.cpp | 6 ++- 9 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 examples/declarative/flowview/FlickrView.qml create mode 100644 examples/declarative/flowview/RoundedRect.qml delete mode 100644 examples/declarative/flowview/flickr.qml delete mode 100644 examples/declarative/flowview/rect.qml diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp index d1f485e..dd1247f 100644 --- a/examples/declarative/extending/binding/happybirthday.cpp +++ b/examples/declarative/extending/binding/happybirthday.cpp @@ -2,7 +2,7 @@ #include HappyBirthday::HappyBirthday(QObject *parent) -: QmlPropertyValueSource(parent), m_line(-1) +: QObject(parent), m_line(-1) { setName(QString()); QTimer *timer = new QTimer(this); diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h index 3039db2..fff2df0 100644 --- a/examples/declarative/extending/binding/happybirthday.h +++ b/examples/declarative/extending/binding/happybirthday.h @@ -2,8 +2,12 @@ #define HAPPYBIRTHDAY_H #include +#include +#include -class HappyBirthday : public QmlPropertyValueSource +#include + +class HappyBirthday : public QObject, public QmlPropertyValueSource { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp index 905dc51..4862aa9 100644 --- a/examples/declarative/extending/valuesource/happybirthday.cpp +++ b/examples/declarative/extending/valuesource/happybirthday.cpp @@ -2,7 +2,7 @@ #include HappyBirthday::HappyBirthday(QObject *parent) -: QmlPropertyValueSource(parent), m_line(-1) +: QObject(parent), m_line(-1) { setName(QString()); QTimer *timer = new QTimer(this); diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h index e0d4912..18ac1f4 100644 --- a/examples/declarative/extending/valuesource/happybirthday.h +++ b/examples/declarative/extending/valuesource/happybirthday.h @@ -2,9 +2,12 @@ #define HAPPYBIRTHDAY_H #include +#include + +#include // ![0] -class HappyBirthday : public QmlPropertyValueSource +class HappyBirthday : public QObject, public QmlPropertyValueSource { Q_OBJECT // ![0] diff --git a/examples/declarative/flowview/FlickrView.qml b/examples/declarative/flowview/FlickrView.qml new file mode 100644 index 0000000..1cdb132 --- /dev/null +++ b/examples/declarative/flowview/FlickrView.qml @@ -0,0 +1,46 @@ +import Qt 4.6 + +Rectangle { + radius: 5; + border.width: 1; + width:400; + height: 120; + color: background; + + XmlListModel { + id: FeedModel + source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } + } + + ListView { + clip: true + orientation: "Horizontal" + width: parent.width + height: 86 + y: 17 + model: FeedModel + delegate: + Item { width: 90; height: 86 + Rectangle { + anchors.centerIn: parent + width: 86; height: 86; + color: "white"; radius: 5 + Image { source: imagePath; x: 5; y: 5 } + } + } + } +} + diff --git a/examples/declarative/flowview/RoundedRect.qml b/examples/declarative/flowview/RoundedRect.qml new file mode 100644 index 0000000..7d2b58b --- /dev/null +++ b/examples/declarative/flowview/RoundedRect.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +Rectangle { radius: 5; border.width: 1; width:400; height: 120; color: background; } + diff --git a/examples/declarative/flowview/flickr.qml b/examples/declarative/flowview/flickr.qml deleted file mode 100644 index 1cdb132..0000000 --- a/examples/declarative/flowview/flickr.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.6 - -Rectangle { - radius: 5; - border.width: 1; - width:400; - height: 120; - color: background; - - XmlListModel { - id: FeedModel - source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "url"; query: "media:content/@url/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "tags"; query: "media:category/string()" } - XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } - XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } - XmlRole { name: "photoType"; query: "media:content/@type/string()" } - XmlRole { name: "photoAuthor"; query: "author/string()" } - XmlRole { name: "photoDate"; query: "pubDate/string()" } - } - - ListView { - clip: true - orientation: "Horizontal" - width: parent.width - height: 86 - y: 17 - model: FeedModel - delegate: - Item { width: 90; height: 86 - Rectangle { - anchors.centerIn: parent - width: 86; height: 86; - color: "white"; radius: 5 - Image { source: imagePath; x: 5; y: 5 } - } - } - } -} - diff --git a/examples/declarative/flowview/rect.qml b/examples/declarative/flowview/rect.qml deleted file mode 100644 index 7d2b58b..0000000 --- a/examples/declarative/flowview/rect.qml +++ /dev/null @@ -1,4 +0,0 @@ -import Qt 4.6 - -Rectangle { radius: 5; border.width: 1; width:400; height: 120; color: background; } - diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 98642e9..f932e4a 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -538,7 +538,11 @@ void QmlView::resizeEvent(QResizeEvent *e) d->root->setWidth(width()); d->root->setHeight(height()); } - setSceneRect(QRectF(0, 0, d->root->width(), d->root->height())); + if (d->root) { + setSceneRect(QRectF(0, 0, d->root->width(), d->root->height())); + } else { + setSceneRect(rect()); + } QGraphicsView::resizeEvent(e); } -- cgit v0.12