summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/network.qdoc3
-rw-r--r--doc/src/declarative/propertybinding.qdoc18
-rw-r--r--src/declarative/declarative.pro6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp2
-rw-r--r--src/declarative/qml/qmlcomponent.cpp9
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro5
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp124
9 files changed, 142 insertions, 31 deletions
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 6d9d1f2..e983ad0 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -131,7 +131,7 @@ The following functions on the global object allow you to dynamically create QML
items from files or strings.
You can also dynamically create objects in a declarative manner, using items
-such as ListView, Repeater and Loader.
+such as ListView, \l Repeater and \l Loader.
\section2 createComponent(url file)
This function takes the URL of a QML file as its only argument. It returns
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index 4ed5ca2..ed20e66e 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -153,8 +153,9 @@ compiled into the executable.
\section1 Limitations
-The \c import statement only works network transparently if it has an "as" clause.
+The \c import statement is only network transparent if it has an "as" clause.
+More specifically:
\list
\o \c{import "dir"} only works on local file systems
\o \c{import libraryUri} only works on local file systems
diff --git a/doc/src/declarative/propertybinding.qdoc b/doc/src/declarative/propertybinding.qdoc
index 2b8a58c..8d0ffa9 100644
--- a/doc/src/declarative/propertybinding.qdoc
+++ b/doc/src/declarative/propertybinding.qdoc
@@ -48,7 +48,7 @@ a property's value to be expressed as an ECMAScript expression that defines the
to other property values or data accessible in the application. The property value is
automatically kept up to date if the other properties or data values change.
-Property bindings are created implicitly in QML whenever an property is assigned an ECMAScript
+Property bindings are created implicitly in QML whenever a property is assigned an ECMAScript
expression. The following QML uses two property bindings to connect the size of the rectangle
to that of \c otherItem.
@@ -68,14 +68,14 @@ expression! Here are some examples of more complex bindings:
\code
Rectangle {
Script {
- function calculateMyWidth() {
- return Math.max(otherItem.width, thirdItem.width);
+ function calculateMyHeight() {
+ return Math.max(otherItem.height, thirdItem.height);
}
}
anchors.centerIn: parent
width: Math.min(otherItem.width, 10)
- height: calculateMyWidth()
+ height: calculateMyHeight()
color: { if (width > 10) "blue"; else "red" }
}
\endcode
@@ -97,6 +97,14 @@ The implicit binding syntax shown previously is easy to use and works perfectly
of bindings. In some advanced cases, it is necessary to create bindings explicitly using the
\l Binding element.
-XXX - need an example
+For example, to bind a property exposed from C++ (\c system.brightness) to a value
+coming from QML (\c slider.value), you could use the Binding element as follows:
+\qml
+Binding {
+ target: system
+ property: "brightness"
+ value: slider.value
+}
+\endqml
*/
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index da8434f..d1e2ee8 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -9,8 +9,10 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtXml
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
-# LIBS += -lgcov
+exists("qml_enable_gcov") {
+ QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
+ LIBS += -lgcov
+}
INCLUDEPATH += ../../include/QtDeclarative
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index e1039f4..d7627ac 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -212,6 +212,8 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url)
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
+ if (d->pix.isNull())
+ d->status = Error;
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
@@ -329,6 +331,8 @@ void QmlGraphicsBorderImage::setGridScaledImage(const QmlGraphicsGridScaledImage
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
+ if (d->pix.isNull())
+ d->status = Error;
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
index c466c44..c841efe 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
@@ -116,6 +116,8 @@ QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
\endcode
unloads "Page1.qml" and frees resources consumed by it.
+
+ \sa {dynamic-object-creation}{Dynamic Object Creation}
*/
/*!
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index e31a1b5..7f8836a 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -219,7 +219,8 @@ QmlComponent::~QmlComponent()
}
/*!
- Returns the component's current \l{QmlComponent::Status} {status}.
+ \property QmlComponent::status
+ The component's current \l{QmlComponent::Status} {status}.
*/
QmlComponent::Status QmlComponent::status() const
{
@@ -284,7 +285,8 @@ bool QmlComponent::isLoading() const
}
/*!
- Returns he progress of loading the component, from 0.0 (nothing loaded)
+ \property QmlComponent::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
to 1.0 (finished).
*/
qreal QmlComponent::progress() const
@@ -503,7 +505,8 @@ QString QmlComponent::errorsString() const
}
/*!
- Return the component URL. This is the URL passed to either the constructor,
+ \property QmlComponent::url
+ The component URL. This is the URL passed to either the constructor,
or the loadUrl() or setData() methods.
*/
QUrl QmlComponent::url() const
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
index 82da769..1f606e5 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
+++ b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
@@ -1,8 +1,9 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,declarative): QT += declarative gui network
macx:CONFIG -= app_bundle
-SOURCES += tst_qmlgraphicsborderimage.cpp
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qmlgraphicsborderimage.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
index aa732c5..06a05dd 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
@@ -40,11 +40,32 @@
****************************************************************************/
#include <qtest.h>
#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlgraphicsborderimage_p.h>
#include <private/qmlgraphicsimagebase_p.h>
#include <private/qmlgraphicsscalegrid_p_p.h>
+#include <private/qmlgraphicsloader_p.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
class tst_qmlgraphicsborderimage : public QObject
@@ -55,11 +76,13 @@ public:
private slots:
void noSource();
- void simple();
+ void imageSource();
+ void imageSource_data();
void resized();
void smooth();
void tileModes();
- void sciFile();
+ void sciSource();
+ void sciSource_data();
void invalidSciFile();
private:
@@ -85,21 +108,53 @@ void tst_qmlgraphicsborderimage::noSource()
delete obj;
}
-void tst_qmlgraphicsborderimage::simple()
+void tst_qmlgraphicsborderimage::imageSource()
{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\" }";
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, valid);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl("file://" SRCDIR "/data/colors.png"));
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source));
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
+ } else {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
+ }
delete obj;
}
+void tst_qmlgraphicsborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false;
+}
+
void tst_qmlgraphicsborderimage::resized()
{
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
@@ -157,24 +212,57 @@ void tst_qmlgraphicsborderimage::tileModes()
}
}
-void tst_qmlgraphicsborderimage::sciFile()
+void tst_qmlgraphicsborderimage::sciSource()
{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors-round.sci\"; width: 300; height: 300 }";
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, valid);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
+ } else {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
+ }
delete obj;
}
+void tst_qmlgraphicsborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << false << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << true << false;
+}
+
void tst_qmlgraphicsborderimage::invalidSciFile()
{
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/invalid.sci\"; width: 300; height: 300 }";
@@ -190,6 +278,8 @@ void tst_qmlgraphicsborderimage::invalidSciFile()
delete obj;
}
+
+
QTEST_MAIN(tst_qmlgraphicsborderimage)
#include "tst_qmlgraphicsborderimage.moc"