From 1042834e11befa48e615775e853ac0f4d4bef5af Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 08:32:42 +1000 Subject: ignore chart exe --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d0e9c5f..1b29fca 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ tests/auto/qprocess/fileWriterProcess.txt tests/auto/qlibrary/libmylib.so* tests/auto/qresourceengine/runtime_resource.rcc tools/qdoc3/qdoc3* +tools/qtestlib/chart/chart* tools/qtestlib/updater/updater* tools/activeqt/testcon/testcon.tlb translations/*.qm -- cgit v0.12 From c3008c1df3017d0b9a4280def69c99be181a3689 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 09:59:10 +1000 Subject: Check initial preferredHeight. --- tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 6bd28fb..543ba3f 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -143,6 +143,7 @@ void tst_qmlgraphicswebview::basicProperties() QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); QCOMPARE(wv->width(), 123.0); QCOMPARE(wv->preferredWidth(), 0); + QCOMPARE(wv->preferredHeight(), 0); QCOMPARE(wv->zoomFactor(), 1.0); QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); QCOMPARE(wv->status(), QmlGraphicsWebView::Ready); -- cgit v0.12 From 99ff19eab317990ae927e42aa5084110ebc1e03a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 10:08:47 +1000 Subject: Test setting property when not set before. --- tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 80efd94..61d0863 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -111,6 +111,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).bar}" << 456 << ""; QTest::newRow("setprop4a") << "{set(0,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range"; QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});set(1,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});set(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << ""; -- cgit v0.12 From 9e5cb8c9e6a8526a26cd6ada9ccec1aba002cf68 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 10:10:46 +1000 Subject: Test one-past-end setting (not error; same as append). --- tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 61d0863..95cf68e 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -104,6 +104,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range"; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML QmlListModel (unknown location) set: value is not an object"; QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML QmlListModel (unknown location) set: value is not an object"; + QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; QTest::newRow("setprop1") << "{append({'foo':123});set(0,'foo',456);count}" << 1 << ""; QTest::newRow("setprop2") << "{append({'foo':123});set(0,'foo',456);get(0).foo}" << 456 << ""; -- cgit v0.12 From 831d30af205d5125f762696bb6f9a5f9d1e3c5f5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 23 Nov 2009 10:53:06 +1000 Subject: Doc. --- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index fb6afb1..263aea5 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -2307,7 +2307,7 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset) Opacity is an \e inherited attribute. That is, the opacity is also applied individually to child items. In almost all cases this is what you want. If you can spot the issue in the following - example, you might need to use an opacity filter (not yet available) instead. + example, you might need to use an \l Opacity effect instead. \table \row -- cgit v0.12 From 7de5a4981144648a158d893542bfe5ad82d6830d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 11:10:26 +1000 Subject: Tidy (and fix) error messages. --- src/declarative/util/qmllistmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index a3c5c59..5491fd7 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -732,11 +732,11 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL for(int jj = 0; jj < props.count(); ++jj) { const QmlCustomParserProperty &nodeProp = props.at(jj); if (nodeProp.name() == "") { - error(nodeProp, QLatin1String("Cannot use default property in ListModel")); + error(nodeProp, QmlListModel::tr("ListElement: cannot use default property")); return false; } if (nodeProp.name() == "id") { - error(nodeProp, QLatin1String("Cannot use reserved \"id\" property in ListModel")); + error(nodeProp, QmlListModel::tr("ListElement: cannot use reserved \"id\" property")); return false; } @@ -792,7 +792,7 @@ QByteArray QmlListModelParser::compile(const QList &cus for(int ii = 0; ii < customProps.count(); ++ii) { const QmlCustomParserProperty &prop = customProps.at(ii); if(prop.name() != "") { // isn't default property - error(prop, QLatin1String("Cannot use default property")); + error(prop, QmlListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); return QByteArray(); } -- cgit v0.12 From b316de95032216a90a8262cce3708f781f8ccbd9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 11:11:53 +1000 Subject: Test error messages. --- .../declarative/qmllistmodel/tst_qmllistmodel.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 95cf68e..f2ffb7b 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include class tst_QmlListModel : public QObject @@ -52,6 +53,8 @@ public: private slots: void dynamic_data(); void dynamic(); + void error_data(); + void error(); }; void tst_QmlListModel::dynamic_data() @@ -155,6 +158,56 @@ void tst_QmlListModel::dynamic() QCOMPARE(actual,result); } +void tst_QmlListModel::error_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("error"); + + QTest::newRow("id not allowed in ListElement") + << "import Qt 4.6\nListModel { ListElement { id: fred } }" + << "ListElement: cannot use reserved \"id\" property"; + + QTest::newRow("id allowed in ListModel") + << "import Qt 4.6\nListModel { id:model }" + << ""; + + QTest::newRow("random properties not allowed in ListModel") + << "import Qt 4.6\nListModel { foo:123 }" + << "ListModel: undefined property 'foo'"; + + QTest::newRow("random properties allowed in ListElement") + << "import Qt 4.6\nListModel { ListElement { foo:123 } }" + << ""; + + QTest::newRow("random object list properties allowed in ListElement") + << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" + << ""; + + QTest::newRow("default properties not allowed in ListElement") + << "import Qt 4.6\nListModel { ListElement { Item { } } }" + << "QTBUG-6082 ListElement should not allow child objects"; +} + +void tst_QmlListModel::error() +{ + QFETCH(QString, qml); + QFETCH(QString, error); + + QmlEngine engine; + QmlComponent component(&engine, qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + if (error.isEmpty()) { + QVERIFY(!component.isError()); + } else { + if (error.startsWith(QLatin1String("QTBUG-"))) + QEXPECT_FAIL("",error.toLatin1(),Abort); + QVERIFY(component.isError()); + QList errors = component.errors(); + QCOMPARE(errors.count(),1); + QCOMPARE(errors.at(0).description(),error); + } +} + QTEST_MAIN(tst_QmlListModel) #include "tst_qmllistmodel.moc" -- cgit v0.12 From 13815e441c6e0bb02daced5546965fde65a0cbb7 Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 23 Nov 2009 11:29:05 +1000 Subject: Documentation fixes Changed html tags over to qdoc tags. --- src/declarative/util/qmlnumberformatter.cpp | 92 +++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp index b09be5b..fce35d9 100644 --- a/src/declarative/util/qmlnumberformatter.cpp +++ b/src/declarative/util/qmlnumberformatter.cpp @@ -97,7 +97,7 @@ QmlNumberFormatter::~QmlNumberFormatter() \qmlproperty string NumberFormatter::text The number in the specified format. -
+ If no format is specified the text will be empty. */ @@ -123,38 +123,82 @@ qreal QmlNumberFormatter::number() const \qmlproperty string NumberFormatter::format The particular format the number will adhere to during the conversion to text. -
+ The format syntax follows a style similar to the Unicode Standard (UTS35). The table below shows the characters, patterns that can be used in the format. - - - - - - - -
Character Meaning
# Any digit(s), zero shows as absent (for leading/trailing zeroes)
0 Implicit digit. Zero will show in the case that the input number is too small.
. Decimal separator. Output decimal seperator will be dependant on system locale.
, Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize)
other Any other character will be taken as a string literal and placed directly into the output string
+ \table + \header + \o Character + \o Meaning + \row + \o # + \o Any digit(s), zero shows as absent (for leading/trailing zeroes). + \row + \o 0 + \o Implicit digit. Zero will show in the case that the input number is too small. + \row + \o . + \o Decimal separator. Output decimal seperator will be dependant on system locale. + \row + \o , + \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize). + \row + \o other + \o Any other character will be taken as a string literal and placed directly into the output string. + \endtable - Invalid formats will not guarantee a meaningful text output.
+ Invalid formats will not guarantee a meaningful text output. - \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point + \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point. The following table illustrates the output text created by applying some examples of numeric formats to the formatter. - - - - - - - - - - - -
Format Number Output
### 123456 123456
000 123456 123456
###### 1234 1234
000000 1234 001234
##,##0.## 1234.456 1,234.46 (for US locale)
1 234,46 (for FR locale)
000000,000.# 123456 000,123,456 (for US locale)
000 123 456 (for FR locale)
0.0### 0.999997 1.0
(000) 000 - 000 12345678 (012) 345 - 678
#A1212A
+ \table + \header + \o Format + \o Number + \o Output + \row + \o ### + \o 123456 + \o 123456 + \row + \o 000 + \o 123456 + \o 123456 + \row + \o ###### + \o 1234 + \o 1234 + \row + \o 000000 + \o 1234 + \o 001234 + \row + \o ##,##0.## + \o 1234.456 + \o 1,234.46 (for US locale) + \codeline 1 234,46 (for FR locale) + \row + \o 000000,000.# + \o 123456 + \o 000,123,456 (for US locale) + \codeline 000 123 456 (for FR locale) + \row + \o 0.0### + \o 0.999997 + \o 1.0 + \row + \o (000) 000 - 000 + \o 12345678 + \o (012) 345 - 678 + \row + \o #A + \o 12 + \o 12A + \endtable */ QString QmlNumberFormatter::format() const -- cgit v0.12 From 4621721a9c3705dc9fbc3b6f15e6122f913e5c72 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 11:38:16 +1000 Subject: Demonstrate "container" type objects. --- examples/declarative/tabwidget/TabWidget.qml | 42 ++++++++++++++++++++++++++++ examples/declarative/tabwidget/tabs.qml | 29 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 examples/declarative/tabwidget/TabWidget.qml create mode 100644 examples/declarative/tabwidget/tabs.qml diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml new file mode 100644 index 0000000..c56f41e --- /dev/null +++ b/examples/declarative/tabwidget/TabWidget.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Item { + id: page + property int current: 0 + default property alias content: stack.children + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + function setOpacities() + { + for (var i=0; iRoses are red"; font.pixelSize: 24 + wrap: true; width: parent.width-20 } + } + Rectangle { + property string title: "Green" + color: "green" + anchors.fill: parent + Text { anchors.centerIn: parent; text: "
Flower stems are green"; font.pixelSize: 24; + wrap: true; width: parent.width-20 } + } + Rectangle { + property string title: "Blue" + color: "blue" + anchors.fill: parent + Text { anchors.centerIn: parent; text: "
Violets are blue"; color: "white"; font.pixelSize: 24 + wrap: true; width: parent.width-20 } + } +} -- cgit v0.12 From 51c4944a90cca18679cfdb22f9bb5ef47664e465 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 Nov 2009 12:15:01 +1000 Subject: Crash --- tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 92b2c1a..1481dae 100644 --- a/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/declarative/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -993,7 +993,6 @@ void tst_QMetaObjectBuilder::serialize() QMetaObjectBuilder builder; builder.setClassName("Test"); builder.addProperty("foo", "int"); - builder.setSuperClass(0); QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly | QIODevice::Append); -- cgit v0.12 From c785d00ad7b5c5be66e2e9d94cc71854918c2a4b Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 23 Nov 2009 13:12:00 +1000 Subject: small doc fixes --- doc/src/declarative/qtdeclarative.qdoc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index ea8e198..e46cbab 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -45,29 +45,29 @@ \ingroup modules \brief The Qt Declarative module provides a declarative framework for building -highly dynamic, custom UIs +highly dynamic, custom user interfaces. -Qt Declarative aids programmers and designers in building the animation rich, -highly fluid user interfaces that are becoming common in portable consumer -electronics devices, such as mobile phones, media players, set-top boxes and -netbooks. The Qt Declarative module provides an engine for interpreting the -declarative QML language, and a rich set of \l {QML Elements} that can be used +Qt Declarative aids programmers and designers in building the animation rich, +highly fluid user interfaces that are becoming common in portable consumer +electronics devices, such as mobile phones, media players, set-top boxes and +netbooks. The Qt Declarative module provides an engine for interpreting the +declarative QML language, and a rich set of \l {QML Elements}{QML elements} that can be used from QML. QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{ECMAScript}, that provides a mechanism to declaratively build an object tree -of \l {QML Elements}. QML improves the integration between ECMAScript and Qt's -existing QObject based type system, adds support for automatic -\l {Property Binding}s and provides \l {Network Transparency} at the language +{ECMAScript}, that provides a mechanism to declaratively build an object tree +of QML elements. QML improves the integration between ECMAScript and Qt's +existing QObject based type system, adds support for automatic +\l {Property Binding}{property bindings} and provides \l {Network Transparency}{network transparency} at the language level. -The \l {QML Elements} are a sophisticated set of graphical and behavioral building -blocks. \l {QML Elements} are combined together in \l {QML Documents} to build components -ranging in complexity from simple pushbuttons and sliders, to complete -internet-enabled applications like a \l {http://www.flickr.com}{flickr} photo browser. +The QML elements are a sophisticated set of graphical and behavioral building +blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components +ranging in complexity from simple buttons and sliders, to complete +internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser. Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}. -QML can be be used to incrementally extend an existing application or to build +QML can be be used to incrementally extend an existing application or to build completely new applications. QML is fully \l {Extending QML}{extensible from C++}. \section1 Getting Started: @@ -76,7 +76,7 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+ \o \l {Tutorial}{Tutorial: 'Hello World'} \o \l {advtutorial.html}{Tutorial: 'Same Game'} \o \l {QML Examples and Walkthroughs} -\o \l {Using QML in C++ Applications} +\o \l {Using QML in C++ Applications} \endlist \section1 Core QML Features: -- cgit v0.12 From a42f90483e0adc0199f54fde66ab17b2fb019954 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 23 Nov 2009 13:43:33 +1000 Subject: cleanup slideswitch example --- examples/declarative/slideswitch/Switch.qml | 58 -- examples/declarative/slideswitch/background.svg | 23 - .../declarative/slideswitch/content/Switch.qml | 63 ++ .../declarative/slideswitch/content/background.svg | 23 + examples/declarative/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ examples/declarative/slideswitch/display.qml | 10 - examples/declarative/slideswitch/knob.svg | 867 --------------------- examples/declarative/slideswitch/slideswitch.qml | 11 + 8 files changed, 964 insertions(+), 958 deletions(-) delete mode 100644 examples/declarative/slideswitch/Switch.qml delete mode 100644 examples/declarative/slideswitch/background.svg create mode 100644 examples/declarative/slideswitch/content/Switch.qml create mode 100644 examples/declarative/slideswitch/content/background.svg create mode 100644 examples/declarative/slideswitch/content/knob.svg delete mode 100644 examples/declarative/slideswitch/display.qml delete mode 100644 examples/declarative/slideswitch/knob.svg create mode 100644 examples/declarative/slideswitch/slideswitch.qml diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml deleted file mode 100644 index 4e13976..0000000 --- a/examples/declarative/slideswitch/Switch.qml +++ /dev/null @@ -1,58 +0,0 @@ -import Qt 4.6 - -Item { - id: mySwitch - width: groove.width; height: groove.height - - property var on - - Script { - - function toggle() { - if(mySwitch.state == "On") - mySwitch.state = "Off"; - else - mySwitch.state = "On"; - } - function dorelease() { - if(knob.x == 1) { - if(mySwitch.state == "Off") - return; - } - - if(knob.x == 78) { - if(mySwitch.state == "On") - return; - } - - toggle(); - } - - } - Image { id: groove; source: "background.svg" } - MouseRegion { anchors.fill: groove; onClicked: { toggle() } } - Image { id: knob; source: "knob.svg"; x: 1; y: 2 } - MouseRegion { - anchors.fill: knob - onClicked: { toggle() } - onReleased: { dorelease() } - drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78 - } - states: [ - State { - name: "On" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: mySwitch; on: true } - }, - State { - name: "Off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: mySwitch; on: false } - } - ] - transitions: [ - Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 } - } - ] -} diff --git a/examples/declarative/slideswitch/background.svg b/examples/declarative/slideswitch/background.svg deleted file mode 100644 index f920d3e..0000000 --- a/examples/declarative/slideswitch/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml new file mode 100644 index 0000000..b65936a --- /dev/null +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -0,0 +1,63 @@ +import Qt 4.6 + +Item { + id: mySwitch + width: background.width; height: background.height + + property bool on: false + + Script { + function toggle() { + if (mySwitch.state == "On") + mySwitch.state = "Off"; + else + mySwitch.state = "On"; + } + + function dorelease() { + if (knob.x == 1) { + if (mySwitch.state == "Off") + return; + } + + if (knob.x == 78) { + if (mySwitch.state == "On") + return; + } + toggle(); + } + } + + Image { + id: background; source: "background.svg" + MouseRegion { anchors.fill: parent; onClicked: toggle() } + } + + Image { + id: knob; source: "knob.svg"; x: 1; y: 2 + + MouseRegion { + anchors.fill: parent + drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: dorelease() + } + } + + states: [ + State { + name: "On" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: mySwitch; on: true } + }, + State { + name: "Off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: mySwitch; on: false } + } + ] + + transitions: Transition { + NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 } + } +} diff --git a/examples/declarative/slideswitch/content/background.svg b/examples/declarative/slideswitch/content/background.svg new file mode 100644 index 0000000..f920d3e --- /dev/null +++ b/examples/declarative/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/declarative/slideswitch/content/knob.svg b/examples/declarative/slideswitch/content/knob.svg new file mode 100644 index 0000000..fb69337 --- /dev/null +++ b/examples/declarative/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/display.qml deleted file mode 100644 index 346ffb1..0000000 --- a/examples/declarative/slideswitch/display.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 - -Rectangle { - color: "white" - width: 150 - height: 150 - Switch { - anchors.centerIn: parent - } -} diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/knob.svg deleted file mode 100644 index fb69337..0000000 --- a/examples/declarative/slideswitch/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml new file mode 100644 index 0000000..9b46cd1 --- /dev/null +++ b/examples/declarative/slideswitch/slideswitch.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + + Switch { + anchors.centerIn: parent + } +} -- cgit v0.12 From a8549cfee8b6ec393dcea6314e6ac7d6c102dc07 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:08:07 +1000 Subject: Webkit console.log() compatibility. This allows avoiding the more non-standard print(). --- src/declarative/qml/qmlengine.cpp | 27 ++++++++++++++++++++++++++- src/declarative/qml/qmlengine_p.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index e292e5c..0a00092 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -145,6 +145,12 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); + //firebug/webkit compat + QScriptValue consoleObject = scriptEngine.newObject(); + consoleObject.setProperty(QLatin1String("log"),scriptEngine.newFunction(consoleLog, 1)); + consoleObject.setProperty(QLatin1String("debug"),scriptEngine.newFunction(consoleLog, 1)); + scriptEngine.globalObject().setProperty(QLatin1String("console"), consoleObject); + scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"), scriptEngine.newFunction(QmlEnginePrivate::createQmlObject, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createComponent"), @@ -800,7 +806,7 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin return e->newVariant(QVariant(ret)); } -QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) +QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *) { QByteArray data; @@ -812,6 +818,25 @@ QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) return QScriptValue(QLatin1String(result.toHex())); } +QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e) +{ + if(ctxt->argumentCount() < 1) + return e->newVariant(QVariant(false)); + + QByteArray msg; + + for (int i=0; iargumentCount(); ++i) { + if (!msg.isEmpty()) msg += ' '; + msg += ctxt->argument(i).toString().toLocal8Bit(); + // does not support firebug "%[a-z]" formatting, since firebug really + // does just ignore the format letter, which makes it pointless. + } + + qDebug("%s",msg.data()); + + return e->newVariant(QVariant(true)); +} + QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 2) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 2f41651..c11a399 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -269,6 +269,7 @@ public: static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); static QScriptValue md5(QScriptContext*, QScriptEngine*); + static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast(e)->p->q_func(); } -- cgit v0.12 From 3c4df26a8d184b728395c8aad26b05626176b7b5 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:26:49 +1000 Subject: Use console.log, not print. --- tests/auto/declarative/qmldebug/tst_qmldebug.cpp | 2 +- tests/auto/declarative/qmlecmascript/data/scriptErrors.qml | 2 +- tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp | 2 +- tests/auto/declarative/qmlgraphicslistview/data/listview.qml | 12 ++++++------ .../auto/declarative/qmlgraphicspathview/data/datamodel.qml | 2 +- tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml | 2 +- tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml | 2 +- tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp | 4 ++-- tests/auto/declarative/qmllanguage/data/OnCompletedType.qml | 2 +- .../qmllanguage/data/customParserIdNotAllowed.errors.txt | 2 +- tests/auto/declarative/qmllanguage/data/defaultGrouped.qml | 2 +- tests/auto/declarative/qmllanguage/data/doubleSignal.qml | 4 ++-- .../declarative/qmllanguage/data/dynamicSignalsAndSlots.qml | 2 +- .../qmllanguage/data/invalidGroupedProperty.7.qml | 2 +- tests/auto/declarative/qmllanguage/data/missingSignal.qml | 2 +- tests/auto/declarative/qmllanguage/data/onCompleted.qml | 4 ++-- tests/auto/declarative/qmllanguage/data/scriptString.qml | 2 +- tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp | 4 +++- .../auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp | 4 ++-- tests/auto/declarative/qmlqt/data/consoleLog.qml | 8 ++++++++ tests/auto/declarative/qmlqt/tst_qmlqt.cpp | 11 +++++++++++ tests/auto/declarative/valuetypes/data/deletedObject.js | 4 ++-- tests/auto/declarative/visual/focusscope/test.qml | 10 +++++----- tests/auto/declarative/visual/focusscope/test3.qml | 4 ++-- tests/auto/declarative/visual/webview/zooming/zooming.qml | 4 ++-- 25 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 tests/auto/declarative/qmlqt/data/consoleLog.qml diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp index 6916cc9..785d55f 100644 --- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp +++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp @@ -816,7 +816,7 @@ int main(int argc, char *argv[]) "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" "Text { color: blueRect.color; }" "MouseRegion {" - "onEntered: { print('hello') }" + "onEntered: { console.log('hello') }" "}" "}"; // add second component to test multiple root contexts diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml index ff22990..9d99b41 100644 --- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml +++ b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml @@ -9,7 +9,7 @@ MyQmlObject { property int x: undefinedObject property int y: (a.value, undefinedObject) - onBasicSignal: { print(a.value); } + onBasicSignal: { console.log(a.value); } } diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 983ddd0..fe3ae6b 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -218,7 +218,7 @@ void tst_qmlecmascript::basicExpressions_data() QTest::addColumn("result"); QTest::addColumn("nest"); - QTest::newRow("Syntax error (self test)") << "{print({'a':1'}.a)}" << QVariant() << false; + QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false; QTest::newRow("Context property") << "a" << QVariant(1944) << false; QTest::newRow("Context property") << "a" << QVariant(1944) << true; QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false; diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index b64b399..99b3db6 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -7,23 +7,23 @@ Rectangle { function checkProperties() { testObject.error = false; if (list.model != testModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } if (!testObject.animate && list.delegate != myDelegate) { - print("delegate property incorrect - expected myDelegate"); + console.log("delegate property incorrect - expected myDelegate"); testObject.error = true; } if (testObject.animate && list.delegate != animatedDelegate) { - print("delegate property incorrect - expected animatedDelegate"); + console.log("delegate property incorrect - expected animatedDelegate"); testObject.error = true; } if (testObject.invalidHighlight && list.highlight != invalidHl) { - print("highlight property incorrect - expected invalidHl"); + console.log("highlight property incorrect - expected invalidHl"); testObject.error = true; } if (!testObject.invalidHighlight && list.highlight != myHighlight) { - print("highlight property incorrect - expected myHighlight"); + console.log("highlight property incorrect - expected myHighlight"); testObject.error = true; } } @@ -85,7 +85,7 @@ Rectangle { } color: ListView.isCurrentItem ? "lightsteelblue" : "white" ListView.onRemove: SequentialAnimation { - ScriptAction { script: print("Fix PropertyAction with attached properties") } + ScriptAction { script: console.log("Fix PropertyAction with attached properties") } /* PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" } diff --git a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml b/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml index 6aea96b..9d08e5d 100644 --- a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml +++ b/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml @@ -9,7 +9,7 @@ PathView { function checkProperties() { testObject.error = false; if (testObject.useModel && view.model != itemModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml index 2d6eae8..cf1fb4d 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml @@ -10,7 +10,7 @@ Rectangle { function checkProperties() { testObject.error = false; if (repeater.delegate != comp) { - print("delegate property incorrect"); + console.log("delegate property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml index 8d28bf8..fc6b34c 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml @@ -11,7 +11,7 @@ Rectangle { function checkProperties() { testObject.error = false; if (testObject.useModel && view.model != itemModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp index f493e0e..1173f85 100644 --- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp +++ b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp @@ -316,7 +316,7 @@ void tst_qmlinstruction::dump() } { - data->primitives << "print(1921)"; + data->primitives << "console.log(1921)"; QmlInstruction i; i.line = 27; @@ -564,7 +564,7 @@ void tst_qmlinstruction::dump() << "24\t\t24\tSTORE_OBJECT\t\t21" << "25\t\t25\tSTORE_VARIANT_OBJECT\t22" << "26\t\t26\tSTORE_INTERFACE\t\t23" - << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"print(1921)\"" + << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\"" << "28\t\t28\tSTORE_SCRIPT\t\t2\t18\t28" << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1" << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\"" diff --git a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml index cdba495..2889caf 100644 --- a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml +++ b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml @@ -4,5 +4,5 @@ import Qt 4.6 MyQmlObject { property int a: Math.max(10, 9) property int b: 11 - Component.onCompleted: print("Completed " + a + " " + b); + Component.onCompleted: console.log("Completed " + a + " " + b); } diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt index d28c0bd..43a8bb2 100644 --- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt @@ -1 +1 @@ -4:19:Cannot use reserved "id" property in ListModel +4:19:ListElement: cannot use reserved "id" property diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml index 532b2bb..0fd1404 100644 --- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml +++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml @@ -3,7 +3,7 @@ import Qt 4.6 MyTypeObject { grouped { - script: print(1921) + script: console.log(1921) QtObject {} } } diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml index ec813c9..fb07b9f 100644 --- a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml +++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml @@ -1,7 +1,7 @@ import Test 1.0 MyQmlObject { - onBasicSignal: print(1921) - onBasicSignal: print(1921) + onBasicSignal: console.log(1921) + onBasicSignal: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml index 737681e..2a834e8 100644 --- a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml +++ b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml @@ -6,5 +6,5 @@ QtObject { function slot2() {} property int test: 0 - function slot3(a) { print(1921); test = a; } + function slot3(a) { console.log(1921); test = a; } } diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml index b77fb90..977539a 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - nullGrouped.script: print(1921) + nullGrouped.script: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.qml b/tests/auto/declarative/qmllanguage/data/missingSignal.qml index 8a87437..3bf75f6 100644 --- a/tests/auto/declarative/qmllanguage/data/missingSignal.qml +++ b/tests/auto/declarative/qmllanguage/data/missingSignal.qml @@ -1,5 +1,5 @@ import Test 1.0 import Qt 4.6 QtObject { - onClicked: print("Hello world!") + onClicked: console.log("Hello world!") } diff --git a/tests/auto/declarative/qmllanguage/data/onCompleted.qml b/tests/auto/declarative/qmllanguage/data/onCompleted.qml index ae47d4b..5725f85 100644 --- a/tests/auto/declarative/qmllanguage/data/onCompleted.qml +++ b/tests/auto/declarative/qmllanguage/data/onCompleted.qml @@ -5,13 +5,13 @@ MyTypeObject { // We set a and b to ensure that onCompleted is executed after bindings and // constants have been assigned property int a: Math.min(6, 7) - Component.onCompleted: print("Completed " + a + " " + nestedObject.b) + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) objectProperty: OnCompletedType { qmlobjectProperty: MyQmlObject { id: nestedObject property int b: 10 - Component.onCompleted: print("Completed " + a + " " + nestedObject.b) + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) } } } diff --git a/tests/auto/declarative/qmllanguage/data/scriptString.qml b/tests/auto/declarative/qmllanguage/data/scriptString.qml index 51e6e48..40a3bbe 100644 --- a/tests/auto/declarative/qmllanguage/data/scriptString.qml +++ b/tests/auto/declarative/qmllanguage/data/scriptString.qml @@ -2,5 +2,5 @@ import Test 1.0 MyTypeObject { scriptProperty: foo + bar - grouped.script: print(1921) + grouped.script: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 892d2eb..685beaf 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -606,6 +606,8 @@ void tst_qmllanguage::dynamicObjectProperties() // Tests the declaration of dynamic signals and slots void tst_qmllanguage::dynamicSignalsAndSlots() { + QTest::ignoreMessage(QtDebugMsg, "1921"); + QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -956,7 +958,7 @@ void tst_qmllanguage::scriptString() QCOMPARE(object->scriptProperty().context(), qmlContext(object)); QVERIFY(object->grouped() != 0); - QCOMPARE(object->grouped()->script().script(), QString("print(1921)")); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); QCOMPARE(object->grouped()->script().scopeObject(), object); QCOMPARE(object->grouped()->script().context(), qmlContext(object)); } diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index d6e88b5..8dcfc11 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -854,12 +854,12 @@ void tst_qmlmetaproperty::write() { PropertyObject o; QmlMetaProperty p(&o, "onClicked"); - QCOMPARE(p.write(QVariant("print(1921)")), false); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); QVERIFY(0 == p.setSignalExpression(new QmlExpression())); QVERIFY(0 != p.signalExpression()); - QCOMPARE(p.write(QVariant("print(1921)")), false); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); QVERIFY(0 != p.signalExpression()); } diff --git a/tests/auto/declarative/qmlqt/data/consoleLog.qml b/tests/auto/declarative/qmlqt/data/consoleLog.qml new file mode 100644 index 0000000..e657ff1 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/consoleLog.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +QtObject { + Component.onCompleted: { + console.log("completed", "ok") + console.log("completed ok") + } +} diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp index 292102a..21c5478 100644 --- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -72,6 +72,7 @@ private slots: void md5(); void createComponent(); void createQmlObject(); + void consoleLog(); private: QmlEngine engine; @@ -353,6 +354,16 @@ void tst_qmlqt::createQmlObject() delete object; } +void tst_qmlqt::consoleLog() +{ + QTest::ignoreMessage(QtDebugMsg, "completed ok"); + QTest::ignoreMessage(QtDebugMsg, "completed ok"); + QmlComponent component(&engine, TEST_FILE("consoleLog.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + QTEST_MAIN(tst_qmlqt) #include "tst_qmlqt.moc" diff --git a/tests/auto/declarative/valuetypes/data/deletedObject.js b/tests/auto/declarative/valuetypes/data/deletedObject.js index f554a0f..af298ff 100644 --- a/tests/auto/declarative/valuetypes/data/deletedObject.js +++ b/tests/auto/declarative/valuetypes/data/deletedObject.js @@ -3,11 +3,11 @@ var savedReference; function startup() { savedReference = object.rect; - print("Test: " + savedReference.x); + console.log("Test: " + savedReference.x); } function afterDelete() { - print("Test: " + savedReference.x); + console.log("Test: " + savedReference.x); } diff --git a/tests/auto/declarative/visual/focusscope/test.qml b/tests/auto/declarative/visual/focusscope/test.qml index 77ffb84..dd6d726 100644 --- a/tests/auto/declarative/visual/focusscope/test.qml +++ b/tests/auto/declarative/visual/focusscope/test.qml @@ -5,13 +5,13 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: MyScope focus: true - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -27,7 +27,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Top Left"); + Keys.onDigit9Pressed: console.log("Top Left"); KeyNavigation.right: Item2 focus: true @@ -44,7 +44,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: Item1 - Keys.onDigit9Pressed: print("Top Right"); + Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -64,7 +64,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Bottom Left"); + Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: MyScope Rectangle { diff --git a/tests/auto/declarative/visual/focusscope/test3.qml b/tests/auto/declarative/visual/focusscope/test3.qml index b5feeb5..4be9dc7 100644 --- a/tests/auto/declarative/visual/focusscope/test3.qml +++ b/tests/auto/declarative/visual/focusscope/test3.qml @@ -23,10 +23,10 @@ Rectangle { FocusScope { id: Root width: 50; height: 50; - Keys.onDigit9Pressed: print("Error - " + name) + Keys.onDigit9Pressed: console.log("Error - " + name) Rectangle { focus: true - Keys.onDigit9Pressed: print(name) + Keys.onDigit9Pressed: console.log(name) width: 50; height: 50; color: Root.ListView.isCurrentItem?"red":"green" Text { text: name; anchors.centerIn: parent } diff --git a/tests/auto/declarative/visual/webview/zooming/zooming.qml b/tests/auto/declarative/visual/webview/zooming/zooming.qml index 3ac57f6..0ea9131 100644 --- a/tests/auto/declarative/visual/webview/zooming/zooming.qml +++ b/tests/auto/declarative/visual/webview/zooming/zooming.qml @@ -12,6 +12,6 @@ WebView { url: "zooming.html" preferredWidth: width preferredHeight: height - onDoubleClick: {print(clickX,clickY);heuristicZoom(clickX,clickY,2)} - onZoomTo: {print(zoom);scale=zoom;x=width/2-centerX;y=height/2-centerY} + onDoubleClick: {console.log(clickX,clickY);heuristicZoom(clickX,clickY,2)} + onZoomTo: {console.log(zoom);scale=zoom;x=width/2-centerX;y=height/2-centerY} } -- cgit v0.12 From 62b51f36c41fdef46b785d8f3a9443c016a9263a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:27:13 +1000 Subject: Use console.log, not print --- examples/declarative/behaviours/test.qml | 2 +- examples/declarative/extending/binding/example.qml | 2 +- examples/declarative/extending/signal/example.qml | 2 +- .../declarative/extending/valuesource/example.qml | 2 +- examples/declarative/focusscope/test.qml | 10 ++++----- examples/declarative/focusscope/test3.qml | 4 ++-- examples/declarative/focusscope/test4.qml | 10 ++++----- examples/declarative/mouseregion/mouse.qml | 24 +++++++++++----------- .../tutorials/samegame/samegame1/samegame.qml | 2 +- examples/declarative/xmldata/daringfireball.qml | 2 +- examples/declarative/xmldata/yahoonews.qml | 2 +- examples/declarative/xmlhttprequest/test.qml | 18 ++++++++-------- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml index 4a44fd7..1869c45 100644 --- a/examples/declarative/behaviours/test.qml +++ b/examples/declarative/behaviours/test.qml @@ -7,7 +7,7 @@ Rectangle { id: page MouseRegion { anchors.fill: parent - onClicked: { bluerect.parent = page; print(mouseX); bluerect.x = mouseX; } + onClicked: { bluerect.parent = page; console.log(mouseX); bluerect.x = mouseX; } } MyRect { color: "green" diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml index 352bb70..b66bc86 100644 --- a/examples/declarative/extending/binding/example.qml +++ b/examples/declarative/extending/binding/example.qml @@ -11,7 +11,7 @@ BirthdayParty { shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } // ![0] - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); Boy { diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml index e46bf32..c7d4792 100644 --- a/examples/declarative/extending/signal/example.qml +++ b/examples/declarative/extending/signal/example.qml @@ -2,7 +2,7 @@ import People 1.0 // ![0] BirthdayParty { - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); // ![0] celebrant: Boy { diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml index 6d47350..7cdf8c0 100644 --- a/examples/declarative/extending/valuesource/example.qml +++ b/examples/declarative/extending/valuesource/example.qml @@ -5,7 +5,7 @@ BirthdayParty { speaker: HappyBirthday { name: "Bob Jones" } // ![0] - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); celebrant: Boy { diff --git a/examples/declarative/focusscope/test.qml b/examples/declarative/focusscope/test.qml index ab5a143..e4332e7 100644 --- a/examples/declarative/focusscope/test.qml +++ b/examples/declarative/focusscope/test.qml @@ -5,13 +5,13 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: myScope focus: true - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -27,7 +27,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Top Left"); + Keys.onDigit9Pressed: console.log("Top Left"); KeyNavigation.right: item2 focus: true @@ -44,7 +44,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: item1 - Keys.onDigit9Pressed: print("Top Right"); + Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -64,7 +64,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Bottom Left"); + Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope Rectangle { diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml index 1b3181b..9344d07 100644 --- a/examples/declarative/focusscope/test3.qml +++ b/examples/declarative/focusscope/test3.qml @@ -23,10 +23,10 @@ Rectangle { FocusScope { id: root width: 50; height: 50; - Keys.onDigit9Pressed: print("Error - " + name) + Keys.onDigit9Pressed: console.log("Error - " + name) Rectangle { focus: true - Keys.onDigit9Pressed: print(name) + Keys.onDigit9Pressed: console.log(name) width: 50; height: 50; color: root.ListView.isCurrentItem?"red":"green" Text { text: name; anchors.centerIn: parent } diff --git a/examples/declarative/focusscope/test4.qml b/examples/declarative/focusscope/test4.qml index 5d4fe35..cc96df9 100644 --- a/examples/declarative/focusscope/test4.qml +++ b/examples/declarative/focusscope/test4.qml @@ -5,12 +5,12 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: myScope - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -26,7 +26,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Error - Top Left"); + Keys.onDigit9Pressed: console.log("Error - Top Left"); KeyNavigation.right: item2 focus: true @@ -43,7 +43,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: item1 - Keys.onDigit9Pressed: print("Error - Top Right"); + Keys.onDigit9Pressed: console.log("Error - Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -63,7 +63,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Error - Bottom Left"); + Keys.onDigit9Pressed: console.log("Error - Bottom Left"); KeyNavigation.up: myScope Rectangle { diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index 91f3b6e..d07d471 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -10,13 +10,13 @@ Rectangle { MouseRegion { hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } - onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } - onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } - onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } - onPressAndHold: { print('press and hold') } - onEntered: { print('entered ' + pressed) } - onExited: { print('exited ' + pressed) } + onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } + onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } + onPressAndHold: { console.log('press and hold') } + onEntered: { console.log('entered ' + pressed) } + onExited: { console.log('exited ' + pressed) } anchors.fill: parent } } @@ -29,11 +29,11 @@ Rectangle { drag.axis: "XAxis" drag.minimumX: 0 drag.maximumX: 150 - onPressed: { print('press') } - onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } - onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') } - onDoubleClicked: { print('double click') } - onPressAndHold: { print('press and hold') } + onPressed: { console.log('press') } + onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { console.log('double click') } + onPressAndHold: { console.log('press and hold') } anchors.fill: parent } } diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index 289579a..fad2175 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -24,7 +24,7 @@ Rectangle { anchors.bottom: Screen.bottom Button { - id: btnA; text: "New Game"; onClicked: print("Implement me!"); + id: btnA; text: "New Game"; onClicked: console.log("Implement me!"); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 938bdd5..456f309 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -33,7 +33,7 @@ Rectangle { text: content anchors.top: titleText.bottom width: 580; wrap: true - onLinkActivated: { print('link clicked: ' + link) } + onLinkActivated: { console.log('link clicked: ' + link) } } } } diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index 4add361..bd14516 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -37,7 +37,7 @@ Rectangle { x: 10; y: 5 text: '' + title + '' font.bold: true; font.family: "Helvetica"; font.pointSize: 14 - onLinkActivated: { print('link clicked: ' + link) } + onLinkActivated: { console.log('link clicked: ' + link) } } Text { diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml index 18447e5..18e328b 100644 --- a/examples/declarative/xmlhttprequest/test.qml +++ b/examples/declarative/xmlhttprequest/test.qml @@ -10,21 +10,21 @@ Rectangle { var doc = new XMLHttpRequest(); doc.onreadystatechange = function() { if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - print ("Headers -->"); - print (doc.getAllResponseHeaders ()); - print ("Last modified -->"); - print (doc.getResponseHeader ("Last-Modified")); + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); } else if (doc.readyState == XMLHttpRequest.DONE) { var a = doc.responseXML.documentElement; for (var ii = 0; ii < a.childNodes.length; ++ii) { - print (a.childNodes[ii].nodeName); + console.log(a.childNodes[ii].nodeName); } - print ("Headers -->"); - print (doc.getAllResponseHeaders ()); - print ("Last modified -->"); - print (doc.getResponseHeader ("Last-Modified")); + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); } } -- cgit v0.12 From 8ac4581718767c498192cdffdfc97211d0030e7b Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:27:32 +1000 Subject: Use console.log, not print --- demos/declarative/twitter/content/AuthView.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml index c924649..8fb00f8 100644 --- a/demos/declarative/twitter/content/AuthView.qml +++ b/demos/declarative/twitter/content/AuthView.qml @@ -30,7 +30,7 @@ Item { Item { id: tabber //Note: it's not working yet - Keys.onPressed: {if(event.key == Qt.Key_Tab){print('Tab works!'); passIn.focus = true; accept(); }} + Keys.onPressed: {if(event.key == Qt.Key_Tab){console.log('Tab works!'); passIn.focus = true; accept(); }} } } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 345c9af..bfc0749 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -196,7 +196,7 @@ Item { fillColor: "white" focus: true - onAlert: print(message) + onAlert: console.log(message) function doZoom(zoom,centerX,centerY) { -- cgit v0.12