diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-23 02:15:40 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-23 02:15:40 (GMT) |
commit | 8386980c83a7d0377b8b642a6cec41641070db77 (patch) | |
tree | 7bd363eabc37e52a6aa10da249674aa5eb08ab52 | |
parent | 51c4944a90cca18679cfdb22f9bb5ef47664e465 (diff) | |
parent | 2d7a9570814891ba4a86ab9472d8c8ee8315b22b (diff) | |
download | Qt-8386980c83a7d0377b8b642a6cec41641070db77.zip Qt-8386980c83a7d0377b8b642a6cec41641070db77.tar.gz Qt-8386980c83a7d0377b8b642a6cec41641070db77.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | examples/declarative/tabwidget/TabWidget.qml | 42 | ||||
-rw-r--r-- | examples/declarative/tabwidget/tabs.qml | 29 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 6 | ||||
-rw-r--r-- | src/declarative/util/qmlnumberformatter.cpp | 92 | ||||
-rw-r--r-- | tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 1 | ||||
-rw-r--r-- | tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 55 |
8 files changed, 200 insertions, 28 deletions
@@ -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 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; i<stack.children.length; ++i) { + stack.children[i].opacity = i==current ? 1 : 0 + } + } + Row { + id: header + Repeater { + delegate: + Rectangle { + width: page.width / stack.children.length + height: 15 + color: page.current == index ? "grey" : "lightGrey" + Text { + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + } + MouseRegion { + anchors.fill: parent + onClicked: page.current = index + } + } + model: stack.children.length + } + } + Item { + id: stack + anchors.top: header.bottom + anchors.bottom: page.bottom + width: page.width + } +} diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml new file mode 100644 index 0000000..54ed7df --- /dev/null +++ b/examples/declarative/tabwidget/tabs.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +TabWidget { + id: tabs + width: 200 + height: 200 + current: 2 + Rectangle { + property string title: "Red" + color: "red" + anchors.fill: parent + Text { anchors.centerIn: parent; text: "<div align=center>Roses 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: "<div align=center>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: "<div align=center>Violets are blue"; color: "white"; font.pixelSize: 24 + wrap: true; width: parent.width-20 } + } +} 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 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<QmlCustomParserProperty> &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(); } 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. - <br> + 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. - <br> + 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. - <table border="0" align="center"> - <tr style="background-color: #D6E2E8"><th> Character </th><th> Meaning </th></tr> - <tr><td> # </td><td> Any digit(s), zero shows as absent (for leading/trailing zeroes) </td></tr> - <tr><td> 0 </td><td> Implicit digit. Zero will show in the case that the input number is too small.</td></tr> - <tr><td> . </td><td> Decimal separator. Output decimal seperator will be dependant on system locale.</td></tr> - <tr><td> , </td><td> Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize)</td></tr> - <tr><td> other </td><td> Any other character will be taken as a string literal and placed directly into the output string </td></tr> - </table> + \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.<br> + Invalid formats will not guarantee a meaningful text output. - \note <i>Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point </i> + \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. - <table border="0" align="center"> - <tr style="background-color: #D6E2E8"><th> Format </th><th> Number </th><th> Output </th></tr> - <tr><td> ### </td><td> 123456 </td><td> 123456 </td></tr> - <tr><td> 000 </td><td> 123456 </td><td> 123456 </td></tr> - <tr><td> ###### </td><td> 1234 </td><td> 1234 </td></tr> - <tr><td> 000000 </td><td> 1234 </td><td> 001234 </td></tr> - <tr><td> ##,##0.## </td><td> 1234.456 </td><td> 1,234.46 (for US locale)<br> 1 234,46 (for FR locale)</td></tr> - <tr><td> 000000,000.# </td><td> 123456 </td><td> 000,123,456 (for US locale)<br> 000 123 456 (for FR locale)</td></tr> - <tr><td> 0.0### </td><td> 0.999997 </td><td> 1.0 </td></tr> - <tr><td> (000) 000 - 000 </td><td> 12345678 </td><td> (012) 345 - 678 </td></tr> - <tr><td> #A</td><td>12</td><td>12A</td></tr> - </table> + \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 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); diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 80efd94..f2ffb7b 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -41,6 +41,7 @@ #include <qtest.h> #include <QtDeclarative/private/qmllistmodel_p.h> #include <QtDeclarative/private/qmlexpression_p.h> +#include <QmlComponent> #include <QDebug> 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() @@ -104,6 +107,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 << ""; @@ -111,6 +115,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 << ""; @@ -153,6 +158,56 @@ void tst_QmlListModel::dynamic() QCOMPARE(actual,result); } +void tst_QmlListModel::error_data() +{ + QTest::addColumn<QString>("qml"); + QTest::addColumn<QString>("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<QmlError> errors = component.errors(); + QCOMPARE(errors.count(),1); + QCOMPARE(errors.at(0).description(),error); + } +} + QTEST_MAIN(tst_QmlListModel) #include "tst_qmllistmodel.moc" |