@@ -193,6 +193,21 @@ var kHeaderColumnCode = 'Column { \n\
193193 ] \n\
194194 }\n';
195195
196+// multiple column version of kHeaderColumnCode.
197+function kHeaderColumnCodeGenerator() {
198+ var headerColumnCodeTemplate = 'Column { \n\
199+ anchors.verticalCenter: parent.verticalCenter; \n\
200+ spacing: units.dp(2); \n\
201+ width: parent.width - x;\n\
202+ data: [ \n\
203+ %1 \n\
204+ ]\n\
205+ }\n';
206+ var args = Array.prototype.slice.call(arguments);
207+ var code = headerColumnCodeTemplate.arg(args.join(',\n'));
208+ return code;
209+}
210+
196211// %1 is used as anchors of mascotShapeLoader
197212var kMascotShapeLoaderCode = 'Loader { \n\
198213 id: mascotShapeLoader; \n\
@@ -224,7 +239,7 @@ var kMascotImageCode = 'Image { \n\
224239 }\n';
225240
226241// %1 is used as anchors of titleLabel
227−// %1 is used as color of titleLabel
242+// %2 is used as color of titleLabel
228243// %3 is used as extra condition for visible of titleLabel
229244var kTitleLabelCode = 'Label { \n\
230245 id: titleLabel; \n\
@@ -258,6 +273,15 @@ var kSubtitleLabelCode = 'Label { \n\
258273 horizontalAlignment: root.headerAlignment; \n\
259274 }\n';
260275
276+// %1 is used as anchors of attributesRow
277+var kAttributesRowCode = 'CardAttributesGrid { \n\
278+ id: attributesRow; \n\
279+ objectName: "attributesRow"; \n\
280+ height: units.gu(1.5); \n\
281+ anchors { %1 } \n\
282+ model: cardData["attributes"] \n\
283+ }\n';
284+
261285// %1 is used as top anchor of summary
262286// %2 is used as topMargin anchor of summary
263287// %3 is used as color of summary
@@ -308,6 +332,7 @@ function cardString(template, components) {
308332 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
309333 var hasSubtitle = hasTitle && components["subtitle"] || false;
310334 var hasHeaderRow = hasMascot && hasTitle;
335+ var hasAttributes = components["attributes"] || false;
311336
312337 if (hasBackground) {
313338 code += kBackgroundLoaderCode;
@@ -377,6 +402,8 @@ function cardString(template, components) {
377402 code += 'readonly property int headerHeight: row.height;\n'
378403 } else if (hasMascot) {
379404 code += 'readonly property int headerHeight: mascotImage.height;\n'
405+ } else if (hasAttributes) {
406+ code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
380407 } else if (hasSubtitle) {
381408 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
382409 } else if (hasTitle) {
@@ -425,10 +452,12 @@ function cardString(template, components) {
425452
426453 var titleAnchors;
427454 var subtitleAnchors;
455+ var attributesAnchors;
428456 if (hasMascot && hasSubtitle) {
429457 // Using row + column
430458 titleAnchors = 'left: parent.left; right: parent.right';
431459 subtitleAnchors = titleAnchors;
460+ attributesAnchors = subtitleAnchors;
432461 } else if (hasMascot) {
433462 // Using row + label
434463 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
@@ -454,6 +483,11 @@ function cardString(template, components) {
454483 right: titleLabel.right; \n\
455484 top: titleLabel.bottom; \n\
456485 topMargin: units.dp(2);\n';
486+ attributesAnchors = 'left: subtitleLabel.left; \n\
487+ leftMargin: subtitleLabel.leftMargin; \n\
488+ right: subtitleLabel.right; \n\
489+ top: subtitleLabel.bottom; \n\
490+ topMargin: units.dp(2);\n';
457491 }
458492
459493 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
@@ -466,8 +500,16 @@ function cardString(template, components) {
466500 if (hasMascot && hasSubtitle) {
467501 // If using row + column wrap the code in the column
468502 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
503+ if (hasAttributes) {
504+ var attributesCode = kAttributesRowCode.arg(attributesAnchors);
505+ titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
506+ }
469507 } else {
470508 titleSubtitleCode = titleCode + subtitleCode;
509+ if (hasAttributes) {
510+ var attributesCode = kAttributesRowCode.arg(attributesAnchors);
511+ titleSubtitleCode = titleSubtitleCode + attributesCode;
512+ }
471513 }
472514 }
473515
@@ -526,7 +568,8 @@ function cardString(template, components) {
526568function createCardComponent(parent, template, components) {
527569 var imports = 'import QtQuick 2.2; \n\
528570 import Ubuntu.Components 0.1; \n\
529− import Ubuntu.Thumbnailer 0.1;\n';
571+ import Ubuntu.Thumbnailer 0.1;\n\
572+ import Dash 0.1;\n';
530573 var card = cardString(template, components);
531574 var code = imports + 'Component {\n' + card + '}\n';
532575 return Qt.createQmlObject(code, parent, "createCardComponent");