on xenial help sign in
Fix CardTool to generate attributes dynamically.
commit173de1649570751fd20ca73f1eeac5e0bfa61128 authorYing-Chun Liu <paul.liu@canonical.com> dateFri 25 Jul 2014, 17:23 (12 years ago) parentd8825a4
1 file changed+23−1
qml/Dash/CardTool.qml+23−1
qml/Dash/CardTool.qml+23−1
@@ -165,6 +165,28 @@ Item {
165165 }
166166 }
167167
168+ Item {
169+ id: attributesModel
170+ property int numOfAttributes: 0
171+ property var model: []
172+ property bool hasAttributes: {
173+ var attributes = components["attributes"];
174+ var hasAttributesFlag = attributes != undefined;
175+ // TODO: we should get num of attributes from components
176+ if (hasAttributesFlag) {
177+ numOfAttributes = 3;
178+ }
179+ return hasAttributesFlag
180+ }
181+
182+ onNumOfAttributesChanged: {
183+ model = []
184+ for (var i = 0; i < numOfAttributes; i++) {
185+ model.push( {"value":"text"+(i+1), "icon":"image://theme/ok" } );
186+ }
187+ }
188+ }
189+
168190 Loader {
169191 id: cardLoader
170192 property var fields: ["art", "mascot", "title", "subtitle", "summary", "attributes"]
@@ -174,7 +196,7 @@ Item {
174196 "title": "—\n—",
175197 "subtitle": "—",
176198 "summary": "—\n—\n—\n—\n—",
177− "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3","icon":"image://theme/ok"}]
199+ "attributes": attributesModel.model
178200 }
179201 sourceComponent: cardTool.cardComponent
180202 onLoaded: {