summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/listview/dynamic.qml60
1 files changed, 54 insertions, 6 deletions
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml
index 58ce4b4..f615c24 100644
--- a/examples/declarative/listview/dynamic.qml
+++ b/examples/declarative/listview/dynamic.qml
@@ -1,43 +1,75 @@
import Qt 4.6
Item {
- width: 300
- height: 300
+ width: 320
+ height: 500
ListModel {
id: FruitModel
ListElement {
name: "Apple"
cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
}
ListElement {
name: "Banana"
cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
}
ListElement {
name: "Cumquat"
cost: 3.25
+ types: [ "Small", "Smaller" ]
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
}
ListElement {
name: "Durian"
cost: 9.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Smelly" }
+ ]
}
ListElement {
name: "Elderberry"
cost: 0.05
+ attributes: [
+ ListElement { description: "Berry" }
+ ]
}
ListElement {
name: "Fig"
cost: 0.25
+ attributes: [
+ ListElement { description: "Flower" }
+ ]
}
}
Component {
id: FruitDelegate
Item {
- width: parent.width; height: 35
- Text { font.pixelSize: 24; text: name }
+ width: parent.width; height: 55
+ Text { id: Label; font.pixelSize: 24; text: name }
Text { font.pixelSize: 24; text: '$'+Number(cost).toFixed(2); anchors.right: ItemButtons.left }
+ Row {
+ anchors.top: Label.bottom
+ spacing: 5
+ Repeater {
+ model: attributes
+ Component {
+ Text { text: description }
+ }
+ }
+ }
Row {
id: ItemButtons
anchors.right: parent.right
@@ -79,10 +111,26 @@ Item {
anchors.bottom: parent.bottom
id: Buttons
Image { source: "content/pics/add.png"
- MouseRegion { anchors.fill: parent; onClicked: FruitModel.append({"name":"Pizza", "cost":5.95}) }
+ MouseRegion { anchors.fill: parent;
+ onClicked: {
+ FruitModel.append({
+ "name":"Pizza Margarita",
+ "cost":5.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"}]
+ })
+ }
+ }
}
Image { source: "content/pics/add.png"
- MouseRegion { anchors.fill: parent; onClicked: FruitModel.insert(0,{"name":"Pizza", "cost":5.95}) }
+ MouseRegion { anchors.fill: parent;
+ onClicked: {
+ FruitModel.insert(0,{
+ "name":"Pizza Supreme",
+ "cost":9.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}]
+ })
+ }
+ }
}
Image { source: "content/pics/trash.png"
MouseRegion { anchors.fill: parent; onClicked: FruitModel.clear() }