diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-12 08:33:06 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-12 08:33:06 (GMT) |
commit | 1ed2d93f4aeceb024934af00a8b075813cbd8dc1 (patch) | |
tree | ad132383d45323b7e5ae40b596240c22d6de9778 | |
parent | 8d22b82d3883518b83bfb49dcc6e3506d0a8731e (diff) | |
parent | 3a83d69ee744216bc72c1b67ad752a9640bb3605 (diff) | |
download | Qt-1ed2d93f4aeceb024934af00a8b075813cbd8dc1.zip Qt-1ed2d93f4aeceb024934af00a8b075813cbd8dc1.tar.gz Qt-1ed2d93f4aeceb024934af00a8b075813cbd8dc1.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | doc/src/declarative/qmlmodels.qdoc | 108 | ||||
-rw-r--r-- | examples/declarative/border-image/MyBorderImage.qml | 8 | ||||
-rw-r--r-- | src/declarative/QmlChanges.txt | 28 | ||||
-rw-r--r-- | src/declarative/qml/parser/qmljslexer.cpp | 11 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 8 | ||||
-rw-r--r-- | src/declarative/util/qmltimer.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/I18n.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/i18nScript.qml | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/i18nStrings.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/i18nType.qml | 5 |
13 files changed, 168 insertions, 40 deletions
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc index d0a5464..6ebb734 100644 --- a/doc/src/declarative/qmlmodels.qdoc +++ b/doc/src/declarative/qmlmodels.qdoc @@ -71,14 +71,87 @@ or C++ (via QmlContext::setContextProperty(), for example). \section1 QML Data Models -\list -\o ListModel is a simple hierarchy of elements specified in QML. The +\section2 ListModel + +ListModel is a simple hierarchy of elements specified in QML. The available roles are specified by the \l ListElement properties. -\o XmlListModel allows construction of a model from an XML data source. The roles + +\code +ListModel { + id: fruitModel + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +} +\endcode + +The above model has two roles, \e name and \e cost. These can be bound +bound to by a ListView delegate, for example: + +\code +Component { + id: fruitDelegate + Row { + Text { text: "Fruit: " + name } + Text { text: "Cost: $" + cost } + } +} +ListView { + model: fruitModel + delegate: fruitDelegate +} +\endcode + + +\section2 XmlListModel + +XmlListModel allows construction of a model from an XML data source. The roles are specified via the \l XmlRole element. -\o VisualItemModel allows QML items to be provided as a model. This model contains + +The following model has three roles, \e title, \e link and \e description: +\code +XmlListModel { + id: feedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "/rss/channel/item" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } +} +\endcode + + +\section2 VisualItemModel + +VisualItemModel allows QML items to be provided as a model. This model contains both the data and delegate (its child items). This model does not provide any roles. -\endlist + +\code + VisualItemModel { + id: itemModel + Rectangle { height: 30; width: 80; color: "red" } + Rectangle { height: 30; width: 80; color: "green" } + Rectangle { height: 30; width: 80; color: "blue" } + } + + ListView { + anchors.fill: parent + model: itemModel + } +\endcode + +Note that in the above example there is no delegate required. +The items of the model itself provide the visual elements that +will be positioned by the view. \section1 C++ Data Models @@ -92,11 +165,28 @@ both the data and delegate (its child items). This model does not provide any r \section1 Other Data Models -\list -\o An Integer specifies a model containing the integer number of elements. + +\section2 An Integer + +An Integer specifies a model containing the integer number of elements. There are no data roles. -\o An Object Instance specifies a model with a single Object element. The + +The following example creates a ListView with five elements: +\code +Component { + id: itemDelegate + Text { text: "I am item number: " + index } +} +ListView { + model: 5 + delegate: itemDelegate +} +\endcode + + +\section2 An Object Instance + +An Object Instance specifies a model with a single Object element. The properties of the object are provided as roles. -\endlist */ diff --git a/examples/declarative/border-image/MyBorderImage.qml b/examples/declarative/border-image/MyBorderImage.qml index d64bfb2..9eb1270 100644 --- a/examples/declarative/border-image/MyBorderImage.qml +++ b/examples/declarative/border-image/MyBorderImage.qml @@ -1,9 +1,10 @@ import Qt 4.6 Item { - property var horizontalMode : BorderImage.Stretch - property var verticalMode : BorderImage.Stretch + property alias horizontalMode: image.horizontalTileMode + property alias verticalMode: image.verticalTileMode property alias source: image.source + property int minWidth property int minHeight property int maxWidth @@ -12,6 +13,7 @@ Item { id: container width: 240; height: 240 + BorderImage { id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2 @@ -27,8 +29,6 @@ Item { NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" } } - horizontalTileMode: container.horizontalMode - verticalTileMode: container.verticalMode border.top: container.margin border.left: container.margin border.bottom: container.margin diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index ee5acd4..6a6c394 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,10 +1,9 @@ QML API Review ============== -The QML API is being reviewed from 17 to 4 September 2009. This -file documents the changes. Note that the changes are incremental, -so a rename A->B for example may be follow by another subseqent -rename B->C, if later reviews override earlier reviews. +The QML API is being reviewed. This file documents the changes. +Note that the changes are incremental, so a rename A->B for example may be followed +by another subsequent rename B->C, if later reviews override earlier reviews. API Changes =========== @@ -95,21 +94,14 @@ ListView: removed currentItemMode. Replaced by highligh range. ListView: removed snapPos. Other Changes: +ids must be lowercase: Text { id: foo }, not Text { id: Foo } Drag: axis becomes an enum with values "XAxis", "YAxis", "XandYAxis" Image: scaleGrid property removed. New item called BorderImage instead. KeyActions: changed to a Keys attached property on any item. KeyProxy: changed to a Keys.forwardTo property on any item. - -Pending Changes -=============== - -Renamed elements: - -Renamed properties: - -Removed Properties: -PropertyAction::property -PropertyAction::target (if possible) - -Additions: -Connection: add "slot" property +Script: now an intrinsic type in the language + - cannot be assigned to properties + - good: Item { Script { ... } } + - bad: Item { resources: Script { ... } } +Script: delay-loaded of the QML file until their source has been loaded (this only effects QML files loaded across the network.) +Scope: declared properties shadow a property of the same name (was previously the reverse) diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index f71b92f..54f8d78 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -867,11 +867,16 @@ bool Lexer::isLineTerminator() const bool Lexer::isIdentLetter(ushort c) { - /* TODO: allow other legitimate unicode chars */ - return ((c >= 'a' && c <= 'z') + // ASCII-biased, since all reserved words are ASCII, aand hence the + // bulk of content to be parsed. + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '$' - || c == '_'); + || c == '_') + return true; + if (c < 128) + return false; + return QChar(c).isLetterOrNumber(); } bool Lexer::isDecimalDigit(ushort c) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 023903d..431f9f6 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -817,7 +817,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) if (!obj->metadata.isEmpty()) { QmlInstruction meta; meta.type = QmlInstruction::StoreMetaObject; - meta.line = -1; + meta.line = 0; meta.storeMeta.data = output->indexForByteArray(obj->metadata); meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata); meta.storeMeta.propertyCache = output->propertyCaches.count(); @@ -830,7 +830,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) if (!obj->id.isEmpty()) { QmlInstruction id; id.type = QmlInstruction::SetId; - id.line = -1; + id.line = 0; id.setId.value = output->indexForString(obj->id); id.setId.index = obj->idIndex; output->bytecode << id; @@ -840,7 +840,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) for (int ii = 0; ii < obj->scriptBlocks.count(); ++ii) { QmlInstruction script; script.type = QmlInstruction::StoreScript; - script.line = -1; // ### + script.line = 0; // ### script.storeScript.fileName = output->indexForString(obj->scriptBlocksFile.at(ii)); script.storeScript.lineNumber = obj->scriptBlocksLineNumber.at(ii); script.storeScript.value = output->indexForString(obj->scriptBlocks.at(ii)); @@ -1007,7 +1007,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) if (!obj->id.isEmpty()) { QmlInstruction id; id.type = QmlInstruction::SetId; - id.line = -1; + id.line = 0; id.setId.value = output->indexForString(obj->id); id.setId.index = obj->idIndex; output->bytecode << id; diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index fdc57ff..3fbe15c 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -207,7 +207,6 @@ void QmlTimer::setTriggeredOnStart(bool triggeredOnStart) */ void QmlTimer::start() { - Q_D(QmlTimer); setRunning(true); } @@ -220,7 +219,6 @@ void QmlTimer::start() */ void QmlTimer::stop() { - Q_D(QmlTimer); setRunning(false); } diff --git a/tests/auto/declarative/qmllanguage/data/I18n.qml b/tests/auto/declarative/qmllanguage/data/I18n.qml new file mode 100644 index 0000000..dbbd4bd --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/I18n.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Text { + property int áâãäå: 10 + text: "Test áâãäå: " + áâãäå +} diff --git a/tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml b/tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml new file mode 100644 index 0000000..6a841d1 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +Text { +} diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml new file mode 100644 index 0000000..dbbd4bd --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Text { + property int áâãäå: 10 + text: "Test áâãäå: " + áâãäå +} diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml new file mode 100644 index 0000000..240d7c1 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +I18n { + áâãäå: 15 +} diff --git a/tests/auto/declarative/qmllanguage/data/i18nScript.qml b/tests/auto/declarative/qmllanguage/data/i18nScript.qml new file mode 100644 index 0000000..6d07b03 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/i18nScript.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Text { + Script { + function val() { + var áâãäå = 10 + return "Test áâãäå: " + áâãäå + } + + } + text: val() +} diff --git a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml b/tests/auto/declarative/qmllanguage/data/i18nStrings.qml new file mode 100644 index 0000000..062191f --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/i18nStrings.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "Test áâãäå (5 accented 'a' letters)" +} diff --git a/tests/auto/declarative/qmllanguage/data/i18nType.qml b/tests/auto/declarative/qmllanguage/data/i18nType.qml new file mode 100644 index 0000000..1a73096 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/i18nType.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +I18nÁâãäå { + text: "TEST" +} |