@@ -193,6 +193,21 @@ var kHeaderColumnCode = 'Column { \n\
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\
206+ var args = Array.prototype.slice.call(arguments);
207+ var code = headerColumnCodeTemplate.arg(args.join(',\n'));
196// %1 is used as anchors of mascotShapeLoader
211// %1 is used as anchors of mascotShapeLoader
197var kMascotShapeLoaderCode = 'Loader { \n\
212var kMascotShapeLoaderCode = 'Loader { \n\
198 id: mascotShapeLoader; \n\
213 id: mascotShapeLoader; \n\
@@ -224,7 +239,7 @@ var kMascotImageCode = 'Image { \n\
226// %1 is used as anchors of titleLabel
241// %1 is used as anchors of titleLabel
227−// %1 is used as color of titleLabel
242+// %2 is used as color of titleLabel
228// %3 is used as extra condition for visible of titleLabel
243// %3 is used as extra condition for visible of titleLabel
229var kTitleLabelCode = 'Label { \n\
244var kTitleLabelCode = 'Label { \n\
230 id: titleLabel; \n\
245 id: titleLabel; \n\
@@ -258,6 +273,15 @@ var kSubtitleLabelCode = 'Label { \n\
258 horizontalAlignment: root.headerAlignment; \n\
273 horizontalAlignment: root.headerAlignment; \n\
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\
282+ model: cardData["attributes"] \n\
261// %1 is used as top anchor of summary
285// %1 is used as top anchor of summary
262// %2 is used as topMargin anchor of summary
286// %2 is used as topMargin anchor of summary
263// %3 is used as color of summary
287// %3 is used as color of summary
@@ -308,6 +332,7 @@ function cardString(template, components) {
308 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
332 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
309 var hasSubtitle = hasTitle && components["subtitle"] || false;
333 var hasSubtitle = hasTitle && components["subtitle"] || false;
310 var hasHeaderRow = hasMascot && hasTitle;
334 var hasHeaderRow = hasMascot && hasTitle;
335+ var hasAttributes = components["attributes"] || false;
312 if (hasBackground) {
337 if (hasBackground) {
313 code += kBackgroundLoaderCode;
338 code += kBackgroundLoaderCode;
@@ -377,6 +402,8 @@ function cardString(template, components) {
377 code += 'readonly property int headerHeight: row.height;\n'
402 code += 'readonly property int headerHeight: row.height;\n'
378 } else if (hasMascot) {
403 } else if (hasMascot) {
379 code += 'readonly property int headerHeight: mascotImage.height;\n'
404 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'
380 } else if (hasSubtitle) {
407 } else if (hasSubtitle) {
381 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
408 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
382 } else if (hasTitle) {
409 } else if (hasTitle) {
@@ -425,10 +452,12 @@ function cardString(template, components) {
426 var titleAnchors;
453 var titleAnchors;
427 var subtitleAnchors;
454 var subtitleAnchors;
455+ var attributesAnchors;
428 if (hasMascot && hasSubtitle) {
456 if (hasMascot && hasSubtitle) {
429 // Using row + column
457 // Using row + column
430 titleAnchors = 'left: parent.left; right: parent.right';
458 titleAnchors = 'left: parent.left; right: parent.right';
431 subtitleAnchors = titleAnchors;
459 subtitleAnchors = titleAnchors;
460+ attributesAnchors = subtitleAnchors;
432 } else if (hasMascot) {
461 } else if (hasMascot) {
433 // Using row + label
462 // Using row + label
434 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
463 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
@@ -454,6 +483,11 @@ function cardString(template, components) {
454 right: titleLabel.right; \n\
483 right: titleLabel.right; \n\
455 top: titleLabel.bottom; \n\
484 top: titleLabel.bottom; \n\
456 topMargin: units.dp(2);\n';
485 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';
459 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
493 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
@@ -466,8 +500,16 @@ function cardString(template, components) {
466 if (hasMascot && hasSubtitle) {
500 if (hasMascot && hasSubtitle) {
467 // If using row + column wrap the code in the column
501 // If using row + column wrap the code in the column
468 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
502 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
503+ if (hasAttributes) {
504+ var attributesCode = kAttributesRowCode.arg(attributesAnchors);
505+ titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
470 titleSubtitleCode = titleCode + subtitleCode;
508 titleSubtitleCode = titleCode + subtitleCode;
509+ if (hasAttributes) {
510+ var attributesCode = kAttributesRowCode.arg(attributesAnchors);
511+ titleSubtitleCode = titleSubtitleCode + attributesCode;
@@ -526,7 +568,8 @@ function cardString(template, components) {
526function createCardComponent(parent, template, components) {
568function createCardComponent(parent, template, components) {
527 var imports = 'import QtQuick 2.2; \n\
569 var imports = 'import QtQuick 2.2; \n\
528 import Ubuntu.Components 0.1; \n\
570 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';
530 var card = cardString(template, components);
573 var card = cardString(template, components);
531 var code = imports + 'Component {\n' + card + '}\n';
574 var code = imports + 'Component {\n' + card + '}\n';
532 return Qt.createQmlObject(code, parent, "createCardComponent");
575 return Qt.createQmlObject(code, parent, "createCardComponent");