diff options
36 files changed, 1542 insertions, 284 deletions
diff --git a/doc/src/images/declarative-tutorial-list-closed.png b/doc/src/images/declarative-tutorial-list-closed.png Binary files differnew file mode 100644 index 0000000..4a0fee9 --- /dev/null +++ b/doc/src/images/declarative-tutorial-list-closed.png diff --git a/doc/src/images/declarative-tutorial-list-open.png b/doc/src/images/declarative-tutorial-list-open.png Binary files differnew file mode 100644 index 0000000..16a9c94 --- /dev/null +++ b/doc/src/images/declarative-tutorial-list-open.png diff --git a/doc/src/images/declarative-tutorial-list.png b/doc/src/images/declarative-tutorial-list.png Binary files differnew file mode 100644 index 0000000..723fe2f --- /dev/null +++ b/doc/src/images/declarative-tutorial-list.png diff --git a/doc/src/topics.qdoc b/doc/src/topics.qdoc index 301f0d4..33bf21a 100644 --- a/doc/src/topics.qdoc +++ b/doc/src/topics.qdoc @@ -226,6 +226,13 @@ system. application. This tutorial is also available with \l{Tutoriel "Carnet d'adresses"}{French explanation}. + \section1 \l{Declarative UI Tutorial} + + \inlineimage declarative-tutorial-list-open.png + + A beginner's guide to getting started with Declarative UI and QML. This + allows for creating user interfaces that are highly animated and + graphically rich. */ /*! diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index 9b9c90f..543f274 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -84,7 +84,6 @@ \o \l{tutorials/declarative/contacts/part1}{Drawing and Animation} \o \l{tutorials/declarative/contacts/part2}{Reusing QML Components} \o \l{tutorials/declarative/contacts/part3}{Models, Views and Delegates} - \o \l{tutorials/declarative/contacts/part4}{Other Tricks} \endlist */ @@ -126,7 +125,7 @@ some simple properties. In QML all components start with a capital letter, and their properties with lower case letters. - Apart from the properties all QML components share, the \l{qml-rect}{Rect} component has the properties + Apart from the properties all QML components share, the \l{Rect}{Rect} component has the properties \list \o color - The background color of the rectangle @@ -137,7 +136,7 @@ \endlist There are also a number of properties all QML components shares, described - in the \l{qml-item}{Item} element reference documentation. The rectangle drawn in the + in the \l{Item}{Item} element reference documentation. The rectangle drawn in the above code uses the properties; \list @@ -152,12 +151,12 @@ \section1 Layout The next step of the tutorial adds an image over the rectangle. We - will do this by adding an \l{qml-image}{Image} component as a child of the - \l{qml-rect}{Rect} component. All QML components have a list of children which + will do this by adding an \l{Image}{Image} component as a child of the + \l{Rect}{Rect} component. All QML components have a list of children which are drawn in order after the parent component has been drawn. - By having the \l{qml-image}{Image} - component as a child of the \l{qml-rect}{Rect} component we ensure it is drawn - over the \l{qml-rect}{Rect} component. Children also are affected by the opacity + By having the \l{Image}{Image} + component as a child of the \l{Rect}{Rect} component we ensure it is drawn + over the \l{Rect}{Rect} component. Children also are affected by the opacity of the parent component and calculate their position in within the bounds of the parent component. @@ -167,27 +166,27 @@ The trashIcon image is added as a child of the Rectangle. In this case the children property isn't explicitly used because the default property - of the \l{qml-rect}{Rect} component is its children. Some elements often don't have children + of the \l{Rect}{Rect} component is its children. Some elements often don't have children and use some other default component. When this is the case its possible to explicitly list the sub component as a child as follows: \snippet declarative/tutorials/contacts/1_Drawing_and_Animation/2a/RemoveButton.qml 0 - The \l{qml-image}{Image} element allows loading an image file for display. The source + The \l{Image}{Image} element allows loading an image file for display. The source specified is a URL, and in this case refers to a portable network graphics file in a relative directory to where the QML file was loaded from. Also new in this code is the use of anchors. In QML components can either have their position and size specified explicitly using x, y, width and height, or they can instead specify the size and position in relation - to either parent or sibling elements. The \l{qml-image}{Image} component uses + to either parent or sibling elements. The \l{Image}{Image} component uses a combination of both styles. It has a fixed size, but specifies its position to align to the right of its parent and for its vertical center to align with the vertical center of its parent. Setting a property by the identifier of a separate property binds them. This means - that if while running the example the position of the \l{qml-rect}{Rect} component's + that if while running the example the position of the \l{Rect}{Rect} component's vertical center changed, so to would the vertical center of - the \l{qml-image}{Image} component. + the \l{Image}{Image} component. The parent value is a special identifier that always refers to the parent component of a component. @@ -216,7 +215,7 @@ understand the alternate state we are aiming for and how it relates to transitioning between states. - We also introduce the \l{qml-text}{Text} element. + We also introduce the \l{Text}{Text} element. Left and Right anchors are specified in terms of the neighboring icons because we want text to fill the space between the icons. This means as the parent removeButton gets wider, so will the text component. @@ -322,7 +321,7 @@ Any QML component can have a set of resources specified. One of those resources is any Script that might be needed. See the - \l{qtscript}{QtScript Module} for more information on how to write + \l{QtScript Module} for more information on how to write script code in Qt. It is possible to refer to identified QML components @@ -406,7 +405,7 @@ This can be useful when the component is not complex enough to justify its own file. The third way to reuse components allows for delaying loading - of the QML until some later event. Each \l{qml-item}{Item} includes + of the QML until some later event. Each \l{Item}{Item} includes a special child, qmlItem, which has its definition provided by the contents of the qml property of its parent. @@ -542,7 +541,6 @@ \page tutorials-declarative-contacts-part3.html \contentspage {Declarative UI Tutorial}{Contents} \previouspage {tutorials/declarative/contacts/part2}{Chapter 2} - \nextpage {tutorials/declarative/contacts/part4}{Chapter 4} \example tutorials/declarative/contacts/part3 \title Models, Views and Delegates \tableofcontents @@ -553,7 +551,7 @@ As the previous elements will not be changed in this section, they have been moved to a lib directory for this tutorial and the relevant - name space path has been used. + import path has been used. \section1 Simple List View @@ -561,6 +559,8 @@ data displayed, a delegate to indicate how elements are drawn and a view to arrange the elements. + \image declarative-tutorial-list.png + For the purposes of this tutorial we will be using an SQL query as our data model. This can be declared in the resources section of the parent item. @@ -579,16 +579,16 @@ and orders the results by the label of the contact first, and then by the recid for any contacts with equivalent labels. - The ListView component is suitable for displaying models, and is declared - much like any other QML component. However since it might have any number - of child items in the list, it has a property that defines how to construct - components for items when displayed. + The ListView component is suitable for displaying models and is declared + much like any other QML component. The ListView component also has + a delegate property that defines how to construct components for items in the list. \snippet declarative/tutorials/contacts/3_Collections/1/ContactView.qml delegate Unlike a child element, this describes a template on how to build the component for each element, much in the same way that components are loaded from - files such as RemoveButton.qml. + files such as RemoveButton.qml. The are constructed or destroyed as items + scroll into our out of the visible area of the list. The entire view component will look like: @@ -596,8 +596,6 @@ This gives us a list of contacts that the user can flick through. - .image. - \section1 Animating Delegates The next step is to allow the user to click on a contact to edit the @@ -606,6 +604,9 @@ similar to how the contents of the FieldText and RemoveButton components are swapped in and out. + \image declarative-tutorial-list-closed.png + \image declarative-tutorial-list-open.png + \snippet declarative/tutorials/contacts/3_Collections/2/ContactView.qml components The first step is to have two children of our delegate component that can @@ -619,9 +620,8 @@ component to that of the whole list view, pushing the other items off each end of the list. It sets the lists views scroll yPosition of the ListView to the y value of the delegate so that the top of the delegate matches the top of the list view. - The next step is to lock the list view. This prevents the user being able to flick - the list view, meaning while in this state the delegate will continue to - fill the ListView's visible area. The final to properties that are set should + The next step is to lock the list view. This prevents the user being able to flick + the list view. The final to properties that are set should be familiar from previous chapters, setting the opacity of the items such that the new item is visible and the old item hidden. @@ -629,12 +629,9 @@ \snippet declarative/tutorials/contacts/3_Collections/2/ContactView.qml transitions - This allows the user to click on an item to enter the open state. + This allows the user to click on an item to enter the open state. Elsewhere on our + contact view we add a button so that the user can leave the detailed view of the contact. - .image. - - Elsewhere on our contact view we add a button so that the user can leave the - detailed view of the contact. \snippet declarative/tutorials/contacts/3_Collections/2/ContactView.qml button And connect it's clicked value to some script to set the state of the delegate @@ -654,27 +651,27 @@ and while the list cleans up after itself and only has delegate components constructed for visible items and any single point of animation, the list can scroll very quickly. This means potentially thousands of delegate components will be constructed and - destroyed when the user is flipping through the list. + destroyed when the user is flicking through the list. Its important then to try and minimize the complexity of the delegate. This can be done by delaying the loading of the component. By using the qml property - of the \l{qml-item}{Item} component, we can delay building the Contact.qml item until the user + of the \l{Item}{Item} component, we can delay building the Contact.qml item until the user attempts to open the list. \snippet declarative/tutorials/contacts/3_Collections/3/ContactView.qml setting qml Each item has a qml property that represents the filename for the contents of - a special qmlItem child of the \l{qml-item}{Item}. By setting the qml property of the Details + a special qmlItem child of the \l{Item}{Item}. By setting the qml property of the Details component on clicking the mouse region, the more complex component isn't loaded until needed. The down side about this though is the properties of Contact - cannot be set until the item is loaded. This requires using the Bind - properties of an item. + cannot be set until the item is loaded. This requires using the Bind element. + \snippet declarative/tutorials/contacts/3_Collections/3/ContactView.qml binding - The Bind properties bind a value to another component, however the target of - this binding can be changed, unlike when setting the properties of a component - directly. This means that when the qml property is set, it will change the + Unlike binding a value to the property of a component directly, the Bind element + allows both the target and the property set to themselves be to dynamic values. + This means that when the qml property is set, it will change the qmlItem property of the Details component. This in turn triggers the Bind elements to set the required properties of the qmlItem, which is now an instance of the Contact component. diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml index dc49d8e..99a521d 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml @@ -5,13 +5,8 @@ Rect { height: 30 color: "red" radius: 5 - properties: Property { - name: "expandedWidth" - value: 230 - } - signals: Signal { - name: "confirmed" - } + property var expandedWidth: 230 + signal confirmed //! [define properties and signals] resources: [ Script { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml index 4d95424..6ad2eb5 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml @@ -17,10 +17,6 @@ Rect { label: "Loading: qml property" } GroupBox { - contents: "1b/ContactField.qml" - label: "Loading: added path" - } - GroupBox { contents: "2/ContactField.qml" label: "Using properties" } @@ -29,12 +25,6 @@ Rect { contents: "3/ContactField.qml" label: "Defining signals" } - Rect { - color: "black" - opacity: 0.3 - width: prev.width - height: prev.height - } GroupBox { contents: "3/Contact.qml" label: "Multiple Items" diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml index 23560ce..763a771 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml @@ -3,22 +3,15 @@ Item { width: 230 height: layout.height - properties: Property { - name: "contactid" - value: "" - } - properties: Property { - name: "label" - onValueChanged: { labelField.value = label } - } - properties: Property { - name: "phone" - onValueChanged: { phoneField.value = phone } - } - properties: Property { - name: "email" - onValueChanged: { emailField.value = email } - } + property var contactId: "" + property var label: "" + property var phone: "" + property var email: "" + + onLabelChanged: { labelField.value = label } + onEmailChanged: { emailField.value = email } + onPhoneChanged: { phoneField.value = phone } + VerticalLayout { id: layout anchors.fill: parent diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml index 2d3d58a..890d781 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml @@ -4,17 +4,9 @@ Item { clip: true width: 230 height: 30 - properties: Property { - name: "label" - value: "Name" - } - properties: Property { - name: "icon" - value: "../../shared/pics/phone.png" - } - properties: Property { - name: "value" - } + property var label: "Name" + property var icon: "../../shared/pics/phone.png" + property var value: "" RemoveButton { id: removeButton anchors.right: parent.right diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml index cf654cf..f6cc1e4 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml @@ -4,19 +4,11 @@ Rect { height: 30 radius: 5 color: "white" - properties: Property { - name: "text" - value: "" - onValueChanged: { reset() } - } + property var text: "" + onTextChanged: { reset() } //! [value change] - properties: Property { - name: "label" - value: "" - } - signals: Signal { - name: "confirmed" - } + property var label: "" + signal confirmed resources: [ Script { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml index 8d82e89..2f27a69 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml @@ -5,13 +5,8 @@ Rect { height: 30 color: "red" radius: 5 - properties: Property { - name: "expandedWidth" - value: 230 - } - signals: Signal { - name: "confirmed" - } + property var expandedWidth: 230 + signal confirmed resources: [ Script { function toggle() { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml index 0587a51..bcb242f 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml @@ -3,27 +3,18 @@ Item { id: contactDetails width: 230 height: layout.height - properties: Property { - name: "mouseGrabbed" - value: false - } + property var mouseGrabbed: false //! [grab property] - properties: Property { - name: "contactid" - value: "" - } - properties: Property { - name: "label" - onValueChanged: { labelField.value = label } - } - properties: Property { - name: "phone" - onValueChanged: { phoneField.value = phone } - } - properties: Property { - name: "email" - onValueChanged: { emailField.value = email } - } + + property var contactId: "" + property var label: "" + property var phone: "" + property var email: "" + + onLabelChanged: { labelField.value = label } + onEmailChanged: { emailField.value = email } + onPhoneChanged: { phoneField.value = phone } + VerticalLayout { id: layout anchors.fill: parent diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml index 0c422b7..e9927e9 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml @@ -2,15 +2,9 @@ Item { id: contactField clip: true height: 30 - properties: Property { - name: "label" - } - properties: Property { - name: "icon" - } - properties: Property { - name: "value" - } + property var label: "Name" + property var icon: "../../shared/pics/phone.png" + property var value: "" RemoveButton { id: removeButton anchors.right: parent.right diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml index 6bb4e0a..e969f7b 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml @@ -3,18 +3,10 @@ Rect { height: 30 radius: 5 color: "white" - properties: Property { - name: "text" - value: "" - onValueChanged: { reset() } - } - properties: Property { - name: "label" - value: "" - } - signals: Signal { - name: "confirmed" - } + property var text: "" + property var label: "" + onTextChanged: { reset() } + signal confirmed resources: [ Script { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml index b57a95b..bfe496e 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml @@ -4,13 +4,8 @@ Rect { height: 30 color: "red" radius: 5 - properties: Property { - name: "expandedWidth" - value: 230 - } - signals: Signal { - name: "confirmed" - } + property var expandedWidth: 230 + signal confirmed resources: [ //! [grab] Script { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml index 665c072..edaae72 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml @@ -2,12 +2,10 @@ FocusRealm { id: groupBox width: Math.max(270, subItem.width+40) height: Math.max(70, subItem.height+40) - properties: Property { - name: "contents" - } - properties: Property { - name: "label" - } + + property var contents + property var label + Rect { id: wrapper x: 5 diff --git a/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml index ce338e2..5400544 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml @@ -3,10 +3,7 @@ Item { id: contacts width: 240 height: 230 - properties: Property { - name: "mouseGrabbed" - value: false - } + property var mouseGrabbed: false resources: [ //! [model] SqlConnection { diff --git a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml index b6b3c31..0a293f5 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml @@ -3,10 +3,7 @@ Item { id: contacts width: 240 height: 230 - properties: Property { - name: "mouseGrabbed" - value: false - } + property var mouseGrabbed: false resources: [ SqlConnection { id: contactDatabase @@ -58,12 +55,12 @@ Item { } MouseRegion { anchors.fill: label - onClicked: { wrapper.state='opened' } + onClicked: { wrapper.state='opened'; } } Contact { - id: details + id: Details anchors.fill: parent - contactid: model.recid + contactId: model.recid label: model.label email: model.email phone: model.phone @@ -95,7 +92,7 @@ Item { value: 0 } SetProperty { - target: details + target: Details property: "opacity" value: 1 } diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml index f0b55db..7a44a3f 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml @@ -3,10 +3,7 @@ Item { id: contacts width: 240 height: 230 - properties: Property { - name: "mouseGrabbed" - value: false - } + property var mouseGrabbed: false resources: [ SqlConnection { id: contactDatabase @@ -17,7 +14,7 @@ Item { SqlQuery { id: contactList connection: contactDatabase - query: "SELECT recid AS contactid, label, email, phone FROM contacts ORDER BY label, recid" + query: "SELECT recid, label, email, phone FROM contacts ORDER BY label, recid" } ] Button { @@ -49,9 +46,9 @@ Item { x: 45 y: 12 width: parent.width-45 - text: model.label color: "black" font.bold: true + text: model.label } //! [setting qml] MouseRegion { @@ -63,14 +60,14 @@ Item { } Item { id: Details - anchors.fill: wrapper + anchors.fill: parent opacity: 0 //! [setting qml] //! [binding] Bind { target: Details.qmlItem - property: "contactid" - value: model.contactid + property: "contactId" + value: model.recid } Bind { target: Details.qmlItem diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml index e8d9a19..7d9937c 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml @@ -15,15 +15,15 @@ Rect { height: contents.height GroupBox { contents: "1/ContactView.qml" - label: "something" + label: "list only" } GroupBox { contents: "2/ContactView.qml" - label: "something" + label: "dynamic delegate" } GroupBox { contents: "3/ContactView.qml" - label: "something" + label: "delayed loading" } } } diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml index 665c072..edaae72 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml @@ -2,12 +2,10 @@ FocusRealm { id: groupBox width: Math.max(270, subItem.width+40) height: Math.max(70, subItem.height+40) - properties: Property { - name: "contents" - } - properties: Property { - name: "label" - } + + property var contents + property var label + Rect { id: wrapper x: 5 diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml index 57267f8..d9f1236 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml @@ -2,12 +2,8 @@ Item { id: button width: 30 height: 30 - properties: Property { - name: "icon" - } - signals: Signal { - name: "clicked" - } + property var icon: "" + signal clicked Rect { id: buttonRect anchors.fill: parent diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml index a7e78dc..6832076 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml @@ -1,22 +1,16 @@ Item { id: contactDetails anchors.fill: parent - properties: Property { - name: "contactid" - value: "" - } - properties: Property { - name: "label" - onValueChanged: { labelField.value = label } - } - properties: Property { - name: "phone" - onValueChanged: { phoneField.value = phone } - } - properties: Property { - name: "email" - onValueChanged: { emailField.value = email } - } + + property var contactId: "" + property var label: "" + property var phone: "" + property var email: "" + + onLabelChanged: { labelField.value = label } + onEmailChanged: { emailField.value = email } + onPhoneChanged: { phoneField.value = phone } + VerticalLayout { id: layout anchors.fill: parent diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml index 0c422b7..e9927e9 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml @@ -2,15 +2,9 @@ Item { id: contactField clip: true height: 30 - properties: Property { - name: "label" - } - properties: Property { - name: "icon" - } - properties: Property { - name: "value" - } + property var label: "Name" + property var icon: "../../shared/pics/phone.png" + property var value: "" RemoveButton { id: removeButton anchors.right: parent.right diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml index 8ba01da..427e2b0 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml @@ -3,18 +3,10 @@ Rect { height: 30 radius: 5 color: "white" - properties: Property { - name: "text" - value: "" - onValueChanged: { reset() } - } - properties: Property { - name: "label" - value: "" - } - signals: Signal { - name: "confirmed" - } + property var text: "" + property var label: "" + onTextChanged: { reset() } + signal confirmed resources: [ Script { diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml index 0b90e48..c0ea79d 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml @@ -4,13 +4,8 @@ Rect { height: 30 color: "red" radius: 5 - properties: Property { - name: "expandedWidth" - value: 230 - } - signals: Signal { - name: "confirmed" - } + property var expandedWidth: 230 + signal confirmed resources: [ Script { function toggle() { diff --git a/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl b/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl new file mode 100755 index 0000000..2d328da --- /dev/null +++ b/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl @@ -0,0 +1,82 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +my $count = shift; + +open(MFIRST, "<english-m.txt") or die "Could not open male names"; +open(FFIRST, "<english-f.txt") or die "Could not open female names"; +open(SURNAME, "<english-s.txt") or die "Could not open surnames names"; +open(ISP, "<email.txt") or die "Could not open isp names"; + +my @mnames = <MFIRST>; +my @fnames = <FFIRST>; +my @surnames = <SURNAME>; +my @isps = <ISP>; + +print "BEGIN;\n"; +print "CREATE TABLE contacts (recid INTEGER PRIMARY KEY, label TEXT, phone TEXT, email TEXT);\n"; +print "CREATE INDEX contactSortOrder ON contacts(label, recid);\n"; + +my $i = 0; +while ($i < $count) { + $i++; + my $fn = randomFirstName(); + my $sn = randomLastName(); + my $em = randomEmail($fn, $sn); + my $ph = randomPhoneNumber(); + + $fn =~ s/'/''/g; + $sn =~ s/'/''/g; + $em =~ s/'/''/g; + print "INSERT INTO contacts (label, email, phone) VALUES('$fn $sn', '$em', '$ph');\n" +} + +print "COMMIT;\n"; + + +sub randomFirstName +{ + my $name; + if (int(rand 2) == 1) { + $name = $mnames[int(rand @mnames)]; + } else { + $name = $fnames[int(rand @fnames)]; + } + chomp $name; + $name; +} + +sub randomLastName +{ + my $name = $surnames[int(rand @surnames)]; + chomp $name; + $name; +} + +sub randomEmail +{ + my ($fn, $ln) = @_; + my $isp = $isps[int(rand @isps)]; + chomp $isp; + my $path = int(rand 3); + my $email; + if ($path == 0) { + $email = "$fn.$ln\@$isp"; + } elsif ($path == 1) { + $email = "$fn\@$isp"; + } elsif ($path == 2) { + $email = "$ln\@$isp"; + } +} + +sub randomPhoneNumber +{ + my @digits = qw(1 2 3 4 5 6 7 8 9 0); + my $phonenumber; + for (1 .. 8) { + $phonenumber .= $digits[int(rand @digits)]; + } + $phonenumber; +} diff --git a/examples/declarative/tutorials/contacts/shared/contacts.sqlite b/examples/declarative/tutorials/contacts/shared/contacts.sqlite Binary files differindex 6918878..d903775 100644 --- a/examples/declarative/tutorials/contacts/shared/contacts.sqlite +++ b/examples/declarative/tutorials/contacts/shared/contacts.sqlite diff --git a/examples/declarative/tutorials/contacts/shared/email.txt b/examples/declarative/tutorials/contacts/shared/email.txt new file mode 100644 index 0000000..de9894b --- /dev/null +++ b/examples/declarative/tutorials/contacts/shared/email.txt @@ -0,0 +1,7 @@ +emails.com +emails.net +mailserver.org +mailserver.net +mailserver.com +BobsMail.com +BillMail.com diff --git a/examples/declarative/tutorials/contacts/shared/english-f.txt b/examples/declarative/tutorials/contacts/shared/english-f.txt new file mode 100644 index 0000000..7da5474 --- /dev/null +++ b/examples/declarative/tutorials/contacts/shared/english-f.txt @@ -0,0 +1,143 @@ +Aimee +Aleksandra +Alice +Alicia +Allison +Alyssa +Amy +Andrea +Angel +Angela +Ann +Anna +Anne +Anne +Marie +Annie +Ashley +Barbara +Beatrice +Beth +Betty +Brenda +Brooke +Candace +Cara +Caren +Carol +Caroline +Carolyn +Carrie +Cassandra +Catherine +Charlotte +Chrissy +Christen +Christina +Christine +Christy +Claire +Claudia +Courtney +Crystal +Cynthia +Dana +Danielle +Deanne +Deborah +Deirdre +Denise +Diane +Dianne +Dorothy +Eileen +Elena +Elizabeth +Emily +Erica +Erin +Frances +Gina +Giulietta +Heather +Helen +Jane +Janet +Janice +Jenna +Jennifer +Jessica +Joanna +Joyce +Julia +Juliana +Julie +Justine +Kara +Karen +Katharine +Katherine +Kathleen +Kathryn +Katrina +Kelly +Kerry +Kim +Kimberly +Kristen +Kristina +Kristine +Laura +Laurel +Lauren +Laurie +Leah +Linda +Lisa +Lori +Marcia +Margaret +Maria +Marina +Marisa +Martha +Mary +Mary +Ann +Maya +Melanie +Melissa +Michelle +Monica +Nancy +Natalie +Nicole +Nina +Pamela +Patricia +Rachel +Rebecca +Renee +Sandra +Sara +Sharon +Sheri +Shirley +Sonia +Stefanie +Stephanie +Susan +Suzanne +Sylvia +Tamara +Tara +Tatiana +Terri +Theresa +Tiffany +Tracy +Valerie +Veronica +Vicky +Vivian +Wendy diff --git a/examples/declarative/tutorials/contacts/shared/english-m.txt b/examples/declarative/tutorials/contacts/shared/english-m.txt new file mode 100644 index 0000000..3c7b13e --- /dev/null +++ b/examples/declarative/tutorials/contacts/shared/english-m.txt @@ -0,0 +1,130 @@ +Aaron +Adam +Adrian +Alan +Alejandro +Alex +Allen +Andrew +Andy +Anthony +Art +Arthur +Barry +Bart +Ben +Benjamin +Bill +Bobby +Brad +Bradley +Brendan +Brett +Brian +Bruce +Bryan +Carlos +Chad +Charles +Chris +Christopher +Chuck +Clay +Corey +Craig +Dan +Daniel +Darren +Dave +David +Dean +Dennis +Denny +Derek +Don +Doug +Duane +Edward +Eric +Eugene +Evan +Frank +Fred +Gary +Gene +George +Gordon +Greg +Harry +Henry +Hunter +Ivan +Jack +James +Jamie +Jason +Jay +Jeff +Jeffrey +Jeremy +Jim +Joe +Joel +John +Jonathan +Joseph +Justin +Keith +Ken +Kevin +Larry +Logan +Marc +Mark +Matt +Matthew +Michael +Mike +Nat +Nathan +Patrick +Paul +Perry +Peter +Philip +Phillip +Randy +Raymond +Ricardo +Richard +Rick +Rob +Robert +Rod +Roger +Ross +Ruben +Russell +Ryan +Sam +Scot +Scott +Sean +Shaun +Stephen +Steve +Steven +Stewart +Stuart +Ted +Thomas +Tim +Toby +Todd +Tom +Troy +Victor +Wade +Walter +Wayne +William diff --git a/examples/declarative/tutorials/contacts/shared/english-s.txt b/examples/declarative/tutorials/contacts/shared/english-s.txt new file mode 100644 index 0000000..1f3682d --- /dev/null +++ b/examples/declarative/tutorials/contacts/shared/english-s.txt @@ -0,0 +1,1003 @@ +Adams +Adamson +Adler +Akers +Akin +Aleman +Alexander +Allen +Allison +Allwood +Anderson +Andreou +Anthony +Appelbaum +Applegate +Arbore +Arenson +Armold +Arntzen +Askew +Athanas +Atkinson +Ausman +Austin +Averitt +Avila-Sakar +Badders +Baer +Baggerly +Bailliet +Baird +Baker +Ball +Ballentine +Ballew +Banks +Baptist-Nguyen +Barbee +Barber +Barchas +Barcio +Bardsley +Barkauskas +Barnes +Barnett +Barnwell +Barrera +Barreto +Barroso +Barrow +Bart +Barton +Bass +Bates +Bavinger +Baxter +Bazaldua +Becker +Beeghly +Belforte +Bellamy +Bellavance +Beltran +Belusar +Bennett +Benoit +Bensley +Berger +Berggren +Bergman +Berry +Bertelson +Bess +Beusse +Bickford +Bierner +Bird +Birdwell +Bixby +Blackmon +Blackwell +Blair +Blankinship +Blanton +Block +Blomkalns +Bloomfield +Blume +Boeckenhauer +Bolding +Bolt +Bolton +Book +Boucher +Boudreau +Bowman +Boyd +Boyes +Boyles +Braby +Braden +Bradley +Brady +Bragg +Brandow +Brantley +Brauner +Braunhardt +Bray +Bredenberg +Bremer +Breyer +Bricout +Briggs +Brittain +Brockman +Brockmoller +Broman +Brooks +Brown +Brubaker +Bruce +Brumfield +Brumley +Bruning +Buck +Budd +Buhler +Buhr +Burleson +Burns +Burton +Bush +Butterfield +Byers +Byon +Byrd +Bzostek +Cabrera +Caesar +Caffey +Caffrey +Calhoun +Call +Callahan +Campbell +Cano +Capri +Carey +Carlisle +Carlson +Carmichael +Carnes +Carr +Carreira +Carroll +Carson +Carswell +Carter +Cartwright +Cason +Cates +Catlett +Caudle +Cavallaro +Cave +Cazamias +Chabot +Chance +Chapman +Characklis +Cheatham +Chen +Chern +Cheville +Chong +Christensen +Church +Claibourn +Clark +Clasen +Claude +Close +Coakley +Coffey +Cohen +Cole +Collier +Conant +Connell +Conte +Conway +Cooley +Cooper +Copeland +Coram +Corbett +Cort +Cortes +Cousins +Cowsar +Cox +Coyne +Crain +Crankshaw +Craven +Crawford +Cressman +Crestani +Crier +Crocker +Cromwell +Crouse +Crowder +Crowe +Culpepper +Cummings +Cunningham +Currie +Cusey +Cutcher +Cyprus +D'Ascenzo +Dabak +Dakoulas +Daly +Dana +Danburg +Danenhauer +Darley +Darrouzet +Dartt +Daugherty +Davila +Davis +Dawkins +Day +DeHart +DeMoss +DeMuth +DeVincentis +Deaton +Dees +Degenhardt +Deggeller +Deigaard +Delabroy +Delaney +Demir +Denison +Denney +Derr +Deuel +Devitt +Diamond +Dickinson +Dietrich +Dilbeck +Dobson +Dodds +Dodson +Doherty +Dooley +Dorsey +Dortch +Doughty +Dove +Dowd +Dowling +Drescher +Drucker +Dryer +Dryver +Duckworth +Dunbar +Dunham +Dunn +Duston +Dettweiler +Dyson +Eason +Eaton +Ebert +Eckhoff +Edelman +Edmonds +Eichhorn +Eisbach +Elders +Elias +Elijah +Elizabeth +Elliott +Elliston +Elms +Emerson +Engelberg +Engle +Eplett +Epp +Erickson +Estades +Etezadi +Evans +Ewing +Fair +Farfan +Fargason +Farhat +Farry +Fawcett +Faye +Federle +Felcher +Feldman +Ferguson +Fergusson +Fernandez +Ferrer +Fine +Fineman +Fisher +Flanagan +Flathmann +Fleming +Fletcher +Folk +Fortune +Fossati +Foster +Foulston +Fowler +Fox +Francis +Frantom +Franz +Frazer +Fredericks +Frey +Freymann +Fuentes +Fuller +Fundling +Furlong +Gainer +Galang +Galeazzi +Gamse +Gannaway +Garcia +Gardner +Garneau +Gartler +Garverick +Garza +Gatt +Gattis +Gayman +Geiger +Gelder +George +Gerbino +Gerbode +Gibson +Gifford +Gillespie +Gillingham +Gilpin +Gilyot +Girgis +Gjertsen +Glantz +Glaze +Glenn +Glotzbach +Gobble +Gockenbach +Goff +Goffin +Golden +Goldwyn +Gomez +Gonzalez +Good +Graham +Gramm +Granlund +Grant +Gray +Grayson +Greene +Greenslade +Greenwood +Greer +Griffin +Grinstein +Grisham +Gross +Grove +Guthrie +Guyton +Haas +Hackney +Haddock +Hagelstein +Hagen +Haggard +Haines +Hale +Haley +Hall +Halladay +Hamill +Hamilton +Hammer +Hancock +Hane +Hansen +Harding +Harless +Harms +Harper +Harrigan +Harris +Harrison +Hart +Harton +Hartz +Harvey +Hastings +Hauenstein +Haushalter +Haven +Hawes +Hawkins +Hawley +Haygood +Haylock +Hazard +Heath +Heidel +Heins +Hellums +Hendricks +Henry +Henson +Herbert +Herman +Hernandez +Herrera +Hertzmann +Hewitt +Hightower +Hildebrand +Hill +Hindman +Hirasaki +Hirsh +Hochman +Hocker +Hoffman +Hoffmann +Holder +Holland +Holloman +Holstein +Holt +Holzer +Honeyman +Hood +Hooks +Hopper +Horne +House +Houston +Howard +Howell +Howley +Huang +Hudgings +Huffman +Hughes +Humphrey +Hunt +Hunter +Hurley +Huston +Hutchinson +Hyatt +Irving +Jacobs +Jaramillo +Jaranson +Jarboe +Jarrell +Jenkins +Johnson +Johnston +Jones +Joy +Juette +Julicher +Jumper +Kabir +Kamberova +Kamen +Kamine +Kampe +Kane +Kang +Kapetanovic +Kargatis +Karlin +Karlsson +Kasbekar +Kasper +Kastensmidt +Katz +Kauffman +Kavanagh +Kaydos +Kearsley +Keleher +Kelly +Kelty +Kendrick +Key +Kicinski +Kiefer +Kielt +Kim +Kimmel +Kincaid +King +Kinney +Kipp +Kirby +Kirk +Kirkland +Kirkpatrick +Klamczynski +Klein +Kopnicky +Kotsonis +Koutras +Kramer +Kremer +Krohn +Kuhlken +Kunitz +LaLonde +LaValle +LaWare +Lacy +Lam +Lamb +Lampkin +Lane +Langston +Lanier +Larsen +Lassiter +Latchford +Lawera +LeBlanc +LeGrand +Leatherbury +Lebron +Ledman +Lee +Leinenbach +Leslie +Levy +Lewis +Lichtenstein +Lisowski +Liston +Litvak +Llano-Restrepo +Lloyd +Lock +Lodge +Logan +Lomonaco +Long +Lopez +Lopez-Bassols +Loren +Loughridge +Love +Ludtke +Luers +Lukes +Luxemburg +MacAllister +MacLeod +Mackey +Maddox +Magee +Mallinson +Mann +Manning +Manthos +Marie +Marrow +Marshall +Martin +Martinez +Martisek +Massey +Mathis +Matt +Maxwell +Mayer +Mazurek +McAdams +McAfee +McAlexander +McBride +McCarthy +McClure +McCord +McCoy +McCrary +McCrossin +McDonald +McElfresh +McFarland +McGarr +McGhee +McGoldrick +McGrath +McGuire +McKinley +McMahan +McMahon +McMath +McNally +Mcdonald +Meade +Meador +Mebane +Medrano +Melton +Merchant +Merwin +Millam +Millard +Miller +Mills +Milstead +Minard +Miner +Minkoff +Minnotte +Minyard +Mirza +Mitchell +Money +Monk +Montgomery +Monton +Moore +Moren +Moreno +Morris +Morse +Moss +Moyer +Mueller +Mull +Mullet +Mullins +Munn +Murdock +Murphey +Murphy +Murray +Murry +Mutchler +Myers +Myrick +Nassar +Nathan +Nazzal +Neal +Nederveld +Nelson +Nguyen +Nichols +Nielsen +Nockton +Nolan +Noonan +Norbury +Nordlander +Norris +Norvell +Noyes +Nugent +Nunn +O'Brien +O'Connell +O'Neill +O'Steen +Ober +Odegard +Oliver +Ollmann +Olson +Ongley +Ordway +Ortiz +Ouellette +Overcash +Overfelt +Overley +Owens +Page +Paige +Pardue +Parham +Parker +Parks +Patterson +Patton +Paul +Payne +Peck +Penisson +Percer +Perez +Perlioni +Perrino +Peterman +Peters +Pfeiffer +Phelps +Philip +Philippe +Phillips +Pickett +Pippenger +Pistole +Platzek +Player +Poddar +Poirier +Poklepovic +Polk +Polking +Pond +Popish +Porter +Pound +Pounds +Powell +Powers +Prado +Preston +Price +Prichep +Priour +Prischmann +Pryor +Puckett +Raglin +Ralston +Rampersad +Ratner +Rawles +Ray +Read +Reddy +Reed +Reese +Reeves +Reichenbach +Reifel +Rein +Reiten +Reiter +Reitmeier +Reynolds +Richardson +Rider +Rhinehart +Ritchie +Rittenbach +Roberts +Robinson +Rodriguez +Rogers +Roper +Rosemblun +Rosen +Rosenberg +Rosenblatt +Ross +Roth +Rowatt +Roy +Royston +Rozendal +Rubble +Ruhlin +Rupert +Russell +Ruthruff +Ryan +Rye +Sabry +Sachitano +Sachs +Sammartino +Sands +Saunders +Savely +Scales +Schaefer +Schafer +Scheer +Schild +Schlitt +Schmitz +Schneider +Schoenberger +Schoppe +Scott +Seay +Segura +Selesnick +Self +Seligmann +Sewall +Shami +Shampine +Sharp +Shaw +Shefelbine +Sheldon +Sherrill +Shidle +Shifley +Shillingsburg +Shisler +Shopbell +Shupack +Sievert +Simpson +Sims +Sissman +Smayling +Smith +Snyder +Solomon +Solon +Soltero +Sommers +Sonneborn +Sorensen +Southworth +Spear +Speight +Spencer +Spruell +Spudich +Stacy +Staebel +Steele +Steinhour +Steinke +Stepp +Stevens +Stewart +Stickel +Stine +Stivers +Stobb +Stone +Stratmann +Stubbers +Stuckey +Stugart +Sullivan +Sultan +Sumrall +Sunley +Sunshine +Sutton +Swaim +Swales +Sweed +Swick +Swift +Swindell +Swint +Symonds +Syzdek +Szafranski +Takimoto +Talbott +Talwar +Tanner +Taslimi +Tate +Tatum +Taylor +Tchainikov +Terk +Thacker +Thomas +Thompson +Thomson +Thornton +Thurman +Thurow +Tilley +Tolle +Towns +Trafton +Tran +Trevas +Trevino +Triggs +Truchard +Tunison +Turner +Twedell +Tyler +Tyree +Unger +Van +Vanderzanden +Vanlandingham +Varanasi +Varela +Varman +Venier +Verspoor +Vick +Visinsky +Voltz +Wagner +Wake +Walcott +Waldron +Walker +Wallace +Walters +Walton +Ward +Wardle +Warnes +Warren +Washington +Watson +Watters +Webber +Weidenfeller +Weien +Weimer +Weiner +Weinger +Weinheimer +Weirich +Welch +Wells +Wendt +West +Westmoreland +Wex +Whitaker +White +Whitley +Wiediger +Wilburn +Williams +Williamson +Willman +Wilson +Winger +Wise +Wisur +Witt +Wong +Woodbury +Wooten +Workman +Wright +Wyatt +Yates +Yeamans +Yen +York +Yotov +Younan +Young +Zeldin +Zettner +Ziegler +Zitterkopf +Zucker diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 68453c3..cf33610 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -136,7 +136,7 @@ void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority) QmlContext context(engine.rootContext()); context.setContextProperty("myModel", modelData); - QmlComponent component("<ListView model=\"{myModel}\" />"); + QmlComponent component("ListView { model=myModel }"); component.create(&context); \endcode @@ -163,7 +163,7 @@ void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority) QmlContext context(engine.rootContext()); context.addDefaultObject(&myDataSet); - QmlComponent component("<ListView model=\"{myModel}\" />"); + QmlComponent component("ListView { model=myModel }"); component.create(&context); \endcode diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 4d6b64f..7dcab6f 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -501,33 +501,22 @@ void QmlEngine::addNameSpacePath(const QString& ns, const QString& path) /*! Returns the mapping from namespace URIs to URLs. - Namespaces in QML allow types to be specified by a URI, - using standard XML namespaces: + Currently, only the empty namespace is supported + (i.e. types cannot be qualified with a namespace). - \code - <Item xmlns:foo="xyz://abc/def"> - <foo:Bar/> - </Item> - \endcode - - Actual QML types can be defined in URLs, in which case a mapping - may be made from URIs (such as "xyz://abc/def/Bar.qml" above, to - URLs (such as "file:///opt/abcdef/Bar.qml"): + The QML \c import statement can be used to import a directory of + components into the empty namespace. - \code - engine->addNameSpacePath("xyz://abc/def","file:///opt/abcdef"); - \endcode + \qml + import "MyModuleDirectory" + \endqml - If only a prefix of the URI is mapped, the path of the URI is - mapped similarly to the URL: + This is also possible from C++: \code - engine->addNameSpacePath("xyz://abc","file:///opt/jkl"); + engine->addNameSpacePath("","file:///opt/abcdef"); \endcode - In the above case, "xyz://abc/def/Bar.qml" would then map to - "file:///opt/jkl/def/Bar.qml". - \sa componentUrl() */ QMap<QString,QString> QmlEngine::nameSpacePaths() const diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 6ad0cb9..1cd2f69 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -72,24 +72,25 @@ Q_DECLARE_METATYPE(QListModelInterface *); \qmlclass ListModel \brief The ListModel element defines a free-form list data source. - The ListModel is a simple XML heirarchy of items containing data roles. + The ListModel is a simple heirarchy of items containing data roles. For example: \code - <ListModel id="FruitModel"> - <Fruit> - <name>Apple</name> - <cost>2.45</cost> - <Fruit> - <Fruit> - <name>Orange</name> - <cost>3.25</cost> - </Fruit> - <Fruit> - <name>Banana</name> - <cost>1.95</cost> - </Fruit> - </ListModel> + ListModel { + id: FruitModel + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } \endcode Elements beginning with a capital are items. Elements beginning @@ -98,14 +99,26 @@ Q_DECLARE_METATYPE(QListModelInterface *); The defined model can be used in views such as ListView: \code - <Component id="FruitDelegate"> - <Item width="200" height="50"> - <Text text="{name}"/> - <Text text="{'$'+cost}" anchors.right="{parent.right}"/> - </Item> - </Component> - - <ListView model="{FruitModel}" delegate="{FruitDelegate}" anchors.fill="{parent}"/> + Component { + id: FruitDelegate + Item { + width: 200 + height: 50 + Text { + text: name + } + Text { + text: '$'+cost + anchors.right: parent.right + } + } + } + + ListView { + model: FruitModel + delegate: FruitDelegate + anchors.fill: parent + } \endcode */ diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 47e70ad..26ed8b1 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -265,7 +265,7 @@ void QmlTransition::setToState(const QString &t) This property holds a list of the animations to be run for this transition. The top-level animations in operations are run in parallel. - To run them sequentially, you can create a single <SequentialAnimation> + To run them sequentially, you can create a single SequentialAnimation which contains all the animations, and assign that to operations. \default */ |