summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-06-10 04:57:51 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-06-10 04:57:51 (GMT)
commit4dc4cfac667389efda4a43df5ff8cfa4ba305a2f (patch)
tree5c937ab2e510edb7a359b225132544d938a884a9 /src/declarative
parent29496148abe8506fbf50c99e9a210095c5115a14 (diff)
downloadQt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.zip
Qt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.tar.gz
Qt-4dc4cfac667389efda4a43df5ff8cfa4ba305a2f.tar.bz2
Support URLs directly (not just as strings), so they are correctly resolved.
URLs expressed as strings (possible relative) are resolved relative to the component in which the string expression is converted to a url value. All items are converted to use QUrl properties, except SqlConnection, where the databasename is only a special-case URL (this may need further consideration).
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp8
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h6
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp5
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp34
-rw-r--r--src/declarative/fx/qfxblendedimage.h14
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp12
-rw-r--r--src/declarative/fx/qfxhighlightfilter.h8
-rw-r--r--src/declarative/fx/qfximage.cpp15
-rw-r--r--src/declarative/fx/qfximage.h8
-rw-r--r--src/declarative/fx/qfximage_p.h1
-rw-r--r--src/declarative/fx/qfxitem.cpp21
-rw-r--r--src/declarative/fx/qfxitem.h6
-rw-r--r--src/declarative/fx/qfxitem_p.h3
-rw-r--r--src/declarative/fx/qfxparticles.cpp18
-rw-r--r--src/declarative/fx/qfxparticles.h6
-rw-r--r--src/declarative/fx/qfxwebview.cpp18
-rw-r--r--src/declarative/fx/qfxwebview.h6
-rw-r--r--src/declarative/qml/qmlbindablevalue.cpp4
-rw-r--r--src/declarative/qml/qmlcompiler.cpp11
-rw-r--r--src/declarative/qml/qmlinstruction.cpp3
-rw-r--r--src/declarative/qml/qmlinstruction_p.h6
-rw-r--r--src/declarative/qml/qmlparser_p.h2
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp1
-rw-r--r--src/declarative/qml/qmlvme.cpp16
-rw-r--r--src/declarative/qml/qmlvmemetaobject.cpp3
-rw-r--r--src/declarative/util/qfxview.cpp6
-rw-r--r--src/declarative/util/qmlscript.cpp17
-rw-r--r--src/declarative/util/qmlscript.h6
28 files changed, 145 insertions, 119 deletions
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index a7f5d72..62ede80 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -270,7 +270,7 @@ public:
, queryId(-1), roleObjects(this) {}
bool isClassComplete;
- QString src;
+ QUrl src;
QString query;
QString namespaces;
int size;
@@ -388,13 +388,13 @@ QString QmlXmlListModel::toString(int role) const
return d->roleNames.at(index);
}
-QString QmlXmlListModel::source() const
+QUrl QmlXmlListModel::source() const
{
Q_D(const QmlXmlListModel);
return d->src;
}
-void QmlXmlListModel::setSource(const QString &src)
+void QmlXmlListModel::setSource(const QUrl &src)
{
Q_D(QmlXmlListModel);
if (d->src != src) {
@@ -483,7 +483,7 @@ void QmlXmlListModel::reload()
emit progressChanged(d->progress);
emit statusChanged(d->status);
- QNetworkRequest req((QUrl(d->src)));
+ QNetworkRequest req(d->src);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index 052a0c2..bdbba47 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -93,7 +93,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QString source READ source WRITE setSource)
+ Q_PROPERTY(QUrl source READ source WRITE setSource)
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects)
@@ -109,8 +109,8 @@ public:
QmlList<XmlListModelRole *> *roleObjects();
- QString source() const;
- void setSource(const QString&);
+ QUrl source() const;
+ void setSource(const QUrl&);
QString query() const;
void setQuery(const QString&);
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
index 029206b..604481c 100644
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ b/src/declarative/fx/qfxanimatedimageitem.cpp
@@ -155,7 +155,7 @@ int QFxAnimatedImageItem::frameCount() const
void QFxAnimatedImageItem::setSource(const QString &url)
{
Q_D(QFxAnimatedImageItem);
- if (url == d->source)
+ if (url == d->url)
return;
delete d->_movie;
@@ -166,8 +166,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
d->reply = 0;
}
- d->source = url;
- d->url = qmlContext(this)->resolvedUrl(url);
+ d->url = url;
if (url.isEmpty()) {
delete d->_movie;
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index 4c6eb58..1f805df 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -84,9 +84,9 @@ QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
\qmlproperty string BlendedImage::primaryUrl
The URL of the first image to be displayed in this item.
*/
-QString QFxBlendedImage::primaryUrl() const
+QUrl QFxBlendedImage::primaryUrl() const
{
- return primSrc;
+ return primUrl;
}
void QFxBlendedImage::primaryLoaded()
@@ -96,15 +96,15 @@ void QFxBlendedImage::primaryLoaded()
update();
}
-void QFxBlendedImage::setPrimaryUrl(const QString &url)
+void QFxBlendedImage::setPrimaryUrl(const QUrl &url)
{
- if (primSrc == url)
+ if (primUrl == url)
return;
- if (!primSrc.isEmpty())
+ if (!primUrl.isEmpty())
QFxPixmap::cancelGet(primUrl,this);
- primSrc = url;
- primUrl = qmlContext(this)->resolvedUrl(url);
- if (!primSrc.isEmpty())
+ Q_ASSERT(!primUrl.isRelative());
+ primUrl = url;
+ if (!primUrl.isEmpty())
QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded()));
}
@@ -112,9 +112,9 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url)
\qmlproperty string BlendedImage::secondaryUrl
The URL of the second image to be displayed in this item.
*/
-QString QFxBlendedImage::secondaryUrl() const
+QUrl QFxBlendedImage::secondaryUrl() const
{
- return secSrc;
+ return secUrl;
}
void QFxBlendedImage::secondaryLoaded()
@@ -124,15 +124,15 @@ void QFxBlendedImage::secondaryLoaded()
update();
}
-void QFxBlendedImage::setSecondaryUrl(const QString &url)
+void QFxBlendedImage::setSecondaryUrl(const QUrl &url)
{
- if (secSrc == url)
+ if (secUrl == url)
return;
- if (!secSrc.isEmpty())
+ if (!secUrl.isEmpty())
QFxPixmap::cancelGet(secUrl,this);
- secSrc = url;
- secUrl = qmlContext(this)->resolvedUrl(url);
- if (!secSrc.isEmpty())
+ Q_ASSERT(!url.isRelative());
+ secUrl = url;
+ if (!secUrl.isEmpty())
QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded()));
}
@@ -183,7 +183,7 @@ void QFxBlendedImage::setSmoothTransform(bool s)
void QFxBlendedImage::paintContents(QPainter &p)
{
- if (primSrc.isNull() && secSrc.isNull())
+ if (primUrl.isEmpty() && secUrl.isEmpty())
return;
if (_smooth) {
diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h
index baf4b64..7169b92 100644
--- a/src/declarative/fx/qfxblendedimage.h
+++ b/src/declarative/fx/qfxblendedimage.h
@@ -57,18 +57,18 @@ class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem
{
Q_OBJECT
- Q_PROPERTY(QString primaryUrl READ primaryUrl WRITE setPrimaryUrl)
- Q_PROPERTY(QString secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
+ Q_PROPERTY(QUrl primaryUrl READ primaryUrl WRITE setPrimaryUrl)
+ Q_PROPERTY(QUrl secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
Q_PROPERTY(qreal blend READ blend WRITE setBlend)
Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxBlendedImage(QFxItem *parent=0);
- QString primaryUrl() const;
- void setPrimaryUrl(const QString &);
+ QUrl primaryUrl() const;
+ void setPrimaryUrl(const QUrl &);
- QString secondaryUrl() const;
- void setSecondaryUrl(const QString &);
+ QUrl secondaryUrl() const;
+ void setSecondaryUrl(const QUrl &);
qreal blend() const;
void setBlend(qreal);
@@ -87,8 +87,6 @@ private Q_SLOTS:
void secondaryLoaded();
private:
- QString primSrc;
- QString secSrc;
QUrl primUrl;
QUrl secUrl;
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
index 6bf3148..3d5f413 100644
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ b/src/declarative/fx/qfxhighlightfilter.cpp
@@ -128,7 +128,7 @@ QFxHighlightFilter::~QFxHighlightFilter()
\property QFxHighlightFilter::source
\brief the URL of the image to be used as the highlight.
*/
-QString QFxHighlightFilter::source() const
+QUrl QFxHighlightFilter::source() const
{
return d->source;
}
@@ -144,14 +144,14 @@ void QFxHighlightFilter::imageLoaded()
update();
}
-void QFxHighlightFilter::setSource(const QString &f)
+void QFxHighlightFilter::setSource(const QUrl &f)
{
- if (d->source == f)
+ if (d->url == f)
return;
- if (!d->source.isEmpty())
+ if (!d->url.isEmpty())
QFxPixmap::cancelGet(d->url, this);
- d->source = f;
- d->url = qmlContext(this)->resolvedUrl(f);
+ Q_ASSERT(!f.isRelative());
+ d->url = f;
#if defined(QFX_RENDER_OPENGL2)
d->tex.clear();
#endif
diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h
index 19e95ac..33f0963 100644
--- a/src/declarative/fx/qfxhighlightfilter.h
+++ b/src/declarative/fx/qfxhighlightfilter.h
@@ -56,7 +56,7 @@ class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter
{
Q_OBJECT
- Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(bool tiled READ tiled WRITE setTiled NOTIFY tiledChanged)
Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
@@ -64,8 +64,8 @@ public:
QFxHighlightFilter(QObject *parent=0);
virtual ~QFxHighlightFilter();
- QString source() const;
- void setSource(const QString &);
+ QUrl source() const;
+ void setSource(const QUrl &);
bool tiled() const;
void setTiled(bool);
@@ -76,7 +76,7 @@ public:
void setYOffset(int);
Q_SIGNALS:
- void sourceChanged(const QString &);
+ void sourceChanged(const QUrl &);
void offsetChanged(int x, int y);
void tiledChanged(bool);
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 224c25e..05738e3 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -825,19 +825,19 @@ qreal QFxImage::progress() const
The content specified can be of any image type loadable by QImage. Alternatively,
you can specify an sci format file, which specifies both an image and it's scale grid.
*/
-QString QFxImage::source() const
+QUrl QFxImage::source() const
{
Q_D(const QFxImage);
- return d->source;
+ return d->url;
}
-void QFxImage::setSource(const QString &url)
+void QFxImage::setSource(const QUrl &url)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::PixmapLoad> perf;
#endif
Q_D(QFxImage);
- if (url == d->source)
+ if (url == d->url)
return;
if (d->sciReply) {
@@ -850,8 +850,7 @@ void QFxImage::setSource(const QString &url)
if (!d->sciurl.isEmpty())
QFxPixmap::cancelGet(d->sciurl, this);
- d->source = url;
- d->url = qmlContext(this)->resolvedUrl(url);
+ d->url = url;
d->sciurl = QUrl();
if (d->progress != 0.0) {
d->progress = 0.0;
@@ -872,7 +871,7 @@ void QFxImage::setSource(const QString &url)
}
#endif
emit statusChanged(d->status);
- emit sourceChanged(d->source);
+ emit sourceChanged(d->url);
emit progressChanged(1.0);
update();
} else {
@@ -936,7 +935,7 @@ void QFxImage::requestFinished()
}
#endif
emit statusChanged(d->status);
- emit sourceChanged(d->source);
+ emit sourceChanged(d->url);
emit progressChanged(1.0);
update();
}
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 4d5f134..35b921a 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
Q_ENUMS(Status)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid)
@@ -88,8 +88,8 @@ public:
Status status() const;
qreal progress() const;
- QString source() const;
- virtual void setSource(const QString &url);
+ QUrl source() const;
+ virtual void setSource(const QUrl &url);
virtual void dump(int depth);
virtual QString propertyInfo() const;
@@ -102,7 +102,7 @@ public:
#endif
Q_SIGNALS:
- void sourceChanged(const QString &);
+ void sourceChanged(const QUrl &);
void statusChanged(Status);
void progressChanged(qreal progress);
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index cd07a37..1785abb 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -106,7 +106,6 @@ public:
#endif
QFxImage::Status status;
- QString source;
QUrl url;
QUrl sciurl;
QNetworkReply *sciReply;
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 7129757..09ec748 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -792,12 +792,12 @@ QFxItem *QFxItem::qmlItem() const
}
/*!
- \qmlproperty string Item::qml
- This property holds the dynamic QML for the item.
+ \qmlproperty url Item::qml
+ This property holds the dynamic URL of the QML for the item.
This property is used for dynamically loading QML into the
item. Querying for the QML only has meaning if the QML has been
- dynamically set; otherwise an empty string is returned.
+ dynamically set; otherwise an empty URL is returned.
*/
/*! \fn void QFxItem::qmlChanged()
@@ -809,32 +809,31 @@ QFxItem *QFxItem::qmlItem() const
/*!
\property QFxItem::qml
- This property holds the dynamic QML for the item.
+ This property holds the dynamic URL of the QML for the item.
This property is used for dynamically loading QML into the
item. Querying for the QML only has meaning if the QML has been
- dynamically set; otherwise an empty string is returned.
+ dynamically set; otherwise an empty URL is returned.
*/
-QString QFxItem::qml() const
+QUrl QFxItem::qml() const
{
Q_D(const QFxItem);
return d->_qml;
}
-void QFxItem::setQml(const QString &qml)
+void QFxItem::setQml(const QUrl &qml)
{
Q_D(QFxItem);
if (d->_qml == qml)
return;
if (!d->_qml.isEmpty()) {
- QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml);
+ QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml.toString());
if (iter != d->_qmlChildren.end())
(*iter)->setOpacity(0.);
}
d->_qml = qml;
- d->_qmlurl = qmlContext(this)->resolvedUri(qml);
d->qmlItem = 0;
if (d->_qml.isEmpty()) {
@@ -842,14 +841,14 @@ void QFxItem::setQml(const QString &qml)
return;
}
- QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml);
+ QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml.toString());
if (iter != d->_qmlChildren.end()) {
(*iter)->setOpacity(1.);
d->qmlItem = (*iter);
emit qmlChanged();
} else {
d->_qmlcomp =
- new QmlComponent(qmlEngine(this), d->_qmlurl, this);
+ new QmlComponent(qmlEngine(this), d->_qml, this);
if (!d->_qmlcomp->isLoading())
qmlLoaded();
else
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 8ca1f9e..3c872e1 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -111,7 +111,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS
Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QString qml READ qml WRITE setQml NOTIFY qmlChanged)
+ Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged)
Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged)
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged)
@@ -171,8 +171,8 @@ public:
void setState(const QString &);
QFxItem *qmlItem() const;
- QString qml() const;
- void setQml(const QString &);
+ QUrl qml() const;
+ void setQml(const QUrl &);
bool flipVertically() const;
void setFlipVertically(bool);
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index a54f523..b38d877 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -133,9 +133,8 @@ public:
QFxAnchors *_anchors;
QFxContents *_contents;
QFxItem *qmlItem;
- QUrl _qmlurl;
QmlComponent *_qmlcomp;
- QString _qml;
+ QUrl _qml;
QList<QUrl> _qmlnewloading;
QList<QmlComponent*> _qmlnewcomp;
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 41fb5bc..25e359d 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -395,7 +395,6 @@ public:
void createParticle(int time);
void updateOpacity(QFxParticle &p, int age);
- QString source;
QUrl url;
QPixmap image;
int count;
@@ -642,10 +641,10 @@ QFxParticles::~QFxParticles()
\property QFxParticles::source
\brief the URL of the particle image.
*/
-QString QFxParticles::source() const
+QUrl QFxParticles::source() const
{
Q_D(const QFxParticles);
- return d->source;
+ return d->url;
}
void QFxParticles::imageLoaded()
@@ -659,18 +658,17 @@ void QFxParticles::imageLoaded()
update();
}
-void QFxParticles::setSource(const QString &name)
+void QFxParticles::setSource(const QUrl &name)
{
Q_D(QFxParticles);
- if (name == d->source)
+ if (name == d->url)
return;
- if (!d->source.isEmpty())
+ if (!d->url.isEmpty())
QFxPixmap::cancelGet(d->url, this);
if (name.isEmpty()) {
- d->source = name;
- d->url = QUrl();
+ d->url = name;
d->image = QPixmap();
#if defined(QFX_RENDER_OPENGL)
d->texDirty = true;
@@ -678,8 +676,8 @@ void QFxParticles::setSource(const QString &name)
#endif
update();
} else {
- d->source = name;
- d->url = qmlContext(this)->resolvedUrl(name);
+ d->url = name;
+ Q_ASSERT(!name.isRelative());
QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
}
}
diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h
index 6ef2582..b3a569b 100644
--- a/src/declarative/fx/qfxparticles.h
+++ b/src/declarative/fx/qfxparticles.h
@@ -153,7 +153,7 @@ class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem
{
Q_OBJECT
- Q_PROPERTY(QString source READ source WRITE setSource)
+ Q_PROPERTY(QUrl source READ source WRITE setSource)
Q_PROPERTY(int count READ count WRITE setCount)
Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan)
Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation)
@@ -172,8 +172,8 @@ public:
QFxParticles(QFxItem *parent=0);
~QFxParticles();
- QString source() const;
- void setSource(const QString &);
+ QUrl source() const;
+ void setSource(const QUrl &);
int count() const;
void setCount(int cnt);
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index bfccd34..d15502b 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -287,7 +287,7 @@ void QFxWebView::componentComplete()
Q_D(QFxWebView);
switch (d->pending) {
case QFxWebViewPrivate::PendingUrl:
- setUrl(d->pending_url.toString());
+ setUrl(d->pending_url);
break;
case QFxWebViewPrivate::PendingHtml:
setHtml(d->pending_string, d->pending_url);
@@ -339,7 +339,7 @@ void QFxWebView::doLoadFinished(bool ok)
}
/*!
- \qmlproperty string WebView::url
+ \qmlproperty url WebView::url
This property holds the URL to the page displayed in this item.
Note that after this property is set, it may take some time
@@ -358,24 +358,22 @@ void QFxWebView::doLoadFinished(bool ok)
Emitted when loading of the URL successfully starts after
setUrl() is called.
*/
-QString QFxWebView::url() const
+QUrl QFxWebView::url() const
{
- return page()->mainFrame()->url().toString();
+ return page()->mainFrame()->url();
}
-void QFxWebView::setUrl(const QString &n)
+void QFxWebView::setUrl(const QUrl &url)
{
Q_D(QFxWebView);
- if (n == page()->mainFrame()->url().toString())
+ if (url == page()->mainFrame()->url())
return;
page()->setViewportSize(QSize(
d->idealwidth>0 ? d->idealwidth : width(),
d->idealheight>0 ? d->idealheight : height()));
- QUrl url(n);
- if (url.isRelative())
- url = qmlContext(this)->resolvedUrl(n);
+ Q_ASSERT(!url.isRelative());
if (isComponentComplete())
page()->mainFrame()->load(url);
@@ -942,7 +940,7 @@ void QFxWebView::setHtml(const QString &html, const QUrl &baseUrl)
d->idealwidth>0 ? d->idealwidth : width(),
d->idealheight>0 ? d->idealheight : height()));
if (isComponentComplete())
- page()->mainFrame()->setHtml(html, qmlContext(this)->resolvedUrl(baseUrl));
+ page()->mainFrame()->setHtml(html, baseUrl);
else {
d->pending = d->PendingHtml;
d->pending_url = baseUrl;
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 28ef6c3..f30fd0d 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -90,7 +90,7 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem
Q_PROPERTY(int idealWidth READ idealWidth WRITE setIdealWidth NOTIFY idealWidthChanged)
Q_PROPERTY(int idealHeight READ idealHeight WRITE setIdealHeight NOTIFY idealHeightChanged)
- Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
@@ -108,8 +108,8 @@ public:
QFxWebView(QFxItem *parent=0);
~QFxWebView();
- QString url() const;
- void setUrl(const QString &);
+ QUrl url() const;
+ void setUrl(const QUrl &);
QString title() const;
diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp
index 351e0bd..de01387 100644
--- a/src/declarative/qml/qmlbindablevalue.cpp
+++ b/src/declarative/qml/qmlbindablevalue.cpp
@@ -220,6 +220,10 @@ void QmlBindableValue::update()
} else if (d->property.propertyCategory() == QmlMetaProperty::Normal) {
QVariant value = this->value();
+ if (d->property.propertyType() == QVariant::Url && value.canConvert(QVariant::String) && !value.isNull()) {
+ // Must resolve first
+ value.setValue(context()->resolvedUrl(value.toString()));
+ }
d->property.write(value);
}
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index b28d7dd..8b4be2b 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -278,6 +278,14 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
instr.storeString.value = output->indexForString(string);
}
break;
+ case QVariant::Url:
+ {
+ instr.type = QmlInstruction::StoreUrl;
+ QUrl u = output->url.resolved(string);
+ instr.storeUrl.propertyIndex = prop.propertyIndex();
+ instr.storeUrl.value = output->indexForString(u.toString());
+ }
+ break;
case QVariant::UInt:
{
instr.type = QmlInstruction::StoreInteger;
@@ -1355,6 +1363,9 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj)
case Object::DynamicProperty::String:
type = "QString";
break;
+ case Object::DynamicProperty::Url:
+ type = "QUrl";
+ break;
case Object::DynamicProperty::Color:
type = "QColor";
break;
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index af1489a..3fe3a8e 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -85,6 +85,9 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::StoreString:
qWarning() << idx << "\t" << line << "\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
break;
+ case QmlInstruction::StoreUrl:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << primitives.at(instr->storeUrl.value);
+ break;
case QmlInstruction::StoreColor:
qWarning() << idx << "\t" << line << "\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t" << QString::number(instr->storeColor.value, 16);
break;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 5a1729f..7cdc1ed 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -76,6 +76,7 @@ public:
// StoreInteger - Store a int or uint in a core property
// StoreBool - Store a bool in a core property
// StoreString - Store a QString in a core property
+ // StoreUrl - Store a QUrl in a core property
// StoreColor - Store a QColor in a core property
// StoreDate - Store a QDate in a core property
// StoreTime - Store a QTime in a core property
@@ -88,6 +89,7 @@ public:
StoreInteger, /* storeInteger */
StoreBool, /* storeBool */
StoreString, /* storeString */
+ StoreUrl, /* storeUrl */
StoreColor, /* storeColor */
StoreDate, /* storeDate */
StoreTime, /* storeTime */
@@ -217,6 +219,10 @@ public:
} storeString;
struct {
int propertyIndex;
+ int value;
+ } storeUrl;
+ struct {
+ int propertyIndex;
unsigned int value;
} storeColor;
struct {
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index 0fdd26b..7989933 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -131,7 +131,7 @@ namespace QmlParser
DynamicProperty();
DynamicProperty(const DynamicProperty &);
- enum Type { Variant, Int, Bool, Real, String, Color, Date };
+ enum Type { Variant, Int, Bool, Real, String, Url, Color, Date };
bool isDefaultProperty;
Type type;
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 5207292..cab7915 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -501,6 +501,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
{ "double", Object::DynamicProperty::Real },
{ "real", Object::DynamicProperty::Real },
{ "string", Object::DynamicProperty::String },
+ { "url", Object::DynamicProperty::Url },
{ "color", Object::DynamicProperty::Color },
{ "date", Object::DynamicProperty::Date },
{ "var", Object::DynamicProperty::Variant },
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index f00d282..af0b3e0 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -77,6 +77,7 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) {
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreInteger);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreBool);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreString);
+ Q_DECLARE_PERFORMANCE_METRIC(InstrStoreUrl);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreColor);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreDate);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreDateTime);
@@ -116,6 +117,7 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") {
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreInteger, "StoreInteger");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreBool, "StoreBool");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreString, "StoreString");
+ Q_DEFINE_PERFORMANCE_METRIC(InstrStoreUrl, "StoreUrl");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreColor, "StoreColor");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreDate, "StoreDate");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreDateTime, "StoreDateTime");
@@ -337,6 +339,20 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
+ case QmlInstruction::StoreUrl:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreUrl> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QUrl u(primitives.at(instr.storeUrl.value));
+ a[0] = (void *)&u;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeUrl.propertyIndex, a);
+ }
+ break;
+
case QmlInstruction::StoreFloat:
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp
index 58708cf..0117448 100644
--- a/src/declarative/qml/qmlvmemetaobject.cpp
+++ b/src/declarative/qml/qmlvmemetaobject.cpp
@@ -134,6 +134,9 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
case QVariant::String:
*reinterpret_cast<QString *>(a[0]) = data[propId].toString();
break;
+ case QVariant::Url:
+ *reinterpret_cast<QUrl *>(a[0]) = data[propId].toUrl();
+ break;
case QVariant::Color:
*reinterpret_cast<QColor *>(a[0]) = data[propId].value<QColor>();
break;
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 0d5b796..d8d9ba1 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -84,11 +84,6 @@ static QVariant stringToKeySequence(const QString &str)
return QVariant::fromValue(QKeySequence(str));
}
-static QVariant stringToUrl(const QString &str)
-{
- return QVariant(QUrl(str));
-}
-
class QFxViewPrivate
{
public:
@@ -166,7 +161,6 @@ void QFxViewPrivate::init()
QmlMetaType::registerCustomStringConverter(QVariant::Pixmap, &stringToPixmap);
QmlMetaType::registerCustomStringConverter(QVariant::Icon, &stringToIcon);
QmlMetaType::registerCustomStringConverter(QVariant::KeySequence, &stringToKeySequence);
- QmlMetaType::registerCustomStringConverter(QVariant::Url, &stringToUrl);
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::FontDatabase> perf;
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp
index 45370e2..e422f37 100644
--- a/src/declarative/util/qmlscript.cpp
+++ b/src/declarative/util/qmlscript.cpp
@@ -69,7 +69,6 @@ public:
void addScriptToEngine(const QString &, const QString &fileName=QString());
QString script;
- QString source;
QNetworkReply *reply;
QUrl url;
};
@@ -138,26 +137,26 @@ void QmlScript::setScript(const QString &script)
\property QmlScript::source
\brief the path to a script file.
*/
-QString QmlScript::source() const
+QUrl QmlScript::source() const
{
Q_D(const QmlScript);
- return d->source;
+ return d->url;
}
-void QmlScript::setSource(const QString &source)
+void QmlScript::setSource(const QUrl &source)
{
Q_D(QmlScript);
- if (d->source == source)
+ if (d->url == source)
return;
- d->source = source;
- d->url = qmlContext(this)->resolvedUrl(source);
+ d->url = source;
+ Q_ASSERT(!source.isRelative());
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
if (d->url.scheme() == QLatin1String("file")) {
QFile file(d->url.toLocalFile());
file.open(QIODevice::ReadOnly);
QByteArray ba = file.readAll();
- d->addScriptToEngine(QString::fromUtf8(ba), d->source);
+ d->addScriptToEngine(QString::fromUtf8(ba), d->url);
} else
#endif
{
@@ -174,7 +173,7 @@ void QmlScript::replyFinished()
Q_D(QmlScript);
if (!d->reply->error()) {
QByteArray ba = d->reply->readAll();
- d->addScriptToEngine(QString::fromUtf8(ba), d->source);
+ d->addScriptToEngine(QString::fromUtf8(ba), d->url);
}
d->reply->deleteLater();
d->reply = 0;
diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h
index dc090bc..09ebc2c 100644
--- a/src/declarative/util/qmlscript.h
+++ b/src/declarative/util/qmlscript.h
@@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlScript : public QObject
Q_DECLARE_PRIVATE(QmlScript)
Q_PROPERTY(QString script READ script WRITE setScript)
- Q_PROPERTY(QString source READ source WRITE setSource)
+ Q_PROPERTY(QUrl source READ source WRITE setSource)
Q_CLASSINFO("DefaultProperty", "script")
public:
@@ -67,8 +67,8 @@ public:
QString script() const;
void setScript(const QString &);
- QString source() const;
- void setSource(const QString &);
+ QUrl source() const;
+ void setSource(const QUrl &);
private Q_SLOTS:
void replyFinished();