@@ -194,6 +194,21 @@ var kHeaderColumnCode = 'Column { \n\
197+// multiple column version of kHeaderColumnCode.
198+function kHeaderColumnCodeGenerator() {
199+ var headerColumnCodeTemplate = 'Column { \n\
200+ anchors.verticalCenter: parent.verticalCenter; \n\
201+ spacing: units.dp(2); \n\
202+ width: parent.width - x;\n\
207+ var args = Array.prototype.slice.call(arguments);
208+ var code = headerColumnCodeTemplate.arg(args.join(',\n'));
197// %1 is used as anchors of mascotShapeLoader
212// %1 is used as anchors of mascotShapeLoader
198var kMascotShapeLoaderCode = 'Loader { \n\
213var kMascotShapeLoaderCode = 'Loader { \n\
199 id: mascotShapeLoader; \n\
214 id: mascotShapeLoader; \n\
@@ -225,7 +240,7 @@ var kMascotImageCode = 'Image { \n\
227// %1 is used as anchors of titleLabel
242// %1 is used as anchors of titleLabel
228−// %1 is used as color of titleLabel
243+// %2 is used as color of titleLabel
229// %3 is used as extra condition for visible of titleLabel
244// %3 is used as extra condition for visible of titleLabel
230var kTitleLabelCode = 'Label { \n\
245var kTitleLabelCode = 'Label { \n\
231 id: titleLabel; \n\
246 id: titleLabel; \n\
@@ -259,6 +274,15 @@ var kSubtitleLabelCode = 'Label { \n\
259 horizontalAlignment: root.headerAlignment; \n\
274 horizontalAlignment: root.headerAlignment; \n\
277+// %1 is used as anchors of attributesRow
278+var kAttributesRowCode = 'CardAttributes { \n\
279+ id: attributesRow; \n\
280+ objectName: "attributesRow"; \n\
283+ model: cardData && cardData["attributes"] || undefined; \n\
262// %1 is used as top anchor of summary
286// %1 is used as top anchor of summary
263// %2 is used as topMargin anchor of summary
287// %2 is used as topMargin anchor of summary
264// %3 is used as color of summary
288// %3 is used as color of summary
@@ -309,6 +333,7 @@ function cardString(template, components) {
309 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
333 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
310 var hasSubtitle = hasTitle && components["subtitle"] || false;
334 var hasSubtitle = hasTitle && components["subtitle"] || false;
311 var hasHeaderRow = hasMascot && hasTitle;
335 var hasHeaderRow = hasMascot && hasTitle;
336+ var hasAttributes = hasTitle && components["attributes"] || false;
313 if (hasBackground) {
338 if (hasBackground) {
314 code += kBackgroundLoaderCode;
339 code += kBackgroundLoaderCode;
@@ -378,6 +403,14 @@ function cardString(template, components) {
378 code += 'readonly property int headerHeight: row.height;\n'
403 code += 'readonly property int headerHeight: row.height;\n'
379 } else if (hasMascot) {
404 } else if (hasMascot) {
380 code += 'readonly property int headerHeight: mascotImage.height;\n'
405 code += 'readonly property int headerHeight: mascotImage.height;\n'
406+ } else if (hasAttributes) {
407+ if (hasTitle && hasSubtitle) {
408+ code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
409+ } else if (hasTitle) {
410+ code += 'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
412+ code += 'readonly property int headerHeight: attributesRow.height;\n'
381 } else if (hasSubtitle) {
414 } else if (hasSubtitle) {
382 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
415 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
383 } else if (hasTitle) {
416 } else if (hasTitle) {
@@ -426,10 +459,12 @@ function cardString(template, components) {
427 var titleAnchors;
460 var titleAnchors;
428 var subtitleAnchors;
461 var subtitleAnchors;
462+ var attributesAnchors;
429− if (hasMascot && hasSubtitle) {
463+ if (hasMascot && (hasSubtitle || hasAttributes)) {
430 // Using row + column
464 // Using row + column
431 titleAnchors = 'left: parent.left; right: parent.right';
465 titleAnchors = 'left: parent.left; right: parent.right';
432 subtitleAnchors = titleAnchors;
466 subtitleAnchors = titleAnchors;
467+ attributesAnchors = subtitleAnchors;
433 } else if (hasMascot) {
468 } else if (hasMascot) {
434 // Using row + label
469 // Using row + label
435 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
470 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
@@ -439,11 +474,13 @@ function cardString(template, components) {
439 titleAnchors = 'left: parent.left; \n\
474 titleAnchors = 'left: parent.left; \n\
440 leftMargin: units.gu(1); \n\
475 leftMargin: units.gu(1); \n\
441 right: parent.right; \n\
476 right: parent.right; \n\
477+ rightMargin: units.gu(1); \n\
442 top: overlayLoader.top; \n\
478 top: overlayLoader.top; \n\
443 topMargin: units.gu(1);\n';
479 topMargin: units.gu(1);\n';
445 // Using anchors to the mascot/parent
481 // Using anchors to the mascot/parent
446− titleAnchors = "right: parent.right;";
482+ titleAnchors = "right: parent.right;\n";
483+ titleAnchors += "rightMargin: units.gu(1);\n";
447 titleAnchors += headerLeftAnchor;
484 titleAnchors += headerLeftAnchor;
448 titleAnchors += headerVerticalAnchors;
485 titleAnchors += headerVerticalAnchors;
449 if (!headerLeftAnchorHasMargin) {
486 if (!headerLeftAnchorHasMargin) {
@@ -453,8 +490,19 @@ function cardString(template, components) {
453 subtitleAnchors = 'left: titleLabel.left; \n\
490 subtitleAnchors = 'left: titleLabel.left; \n\
454 leftMargin: titleLabel.leftMargin; \n\
491 leftMargin: titleLabel.leftMargin; \n\
455 right: titleLabel.right; \n\
492 right: titleLabel.right; \n\
493+ rightMargin: titleLabel.rightMargin; \n\
456 top: titleLabel.bottom; \n\
494 top: titleLabel.bottom; \n\
457 topMargin: units.dp(2);\n';
495 topMargin: units.dp(2);\n';
497+ attributesAnchors = 'left: subtitleLabel.left; \n\
498+ leftMargin: subtitleLabel.leftMargin; \n\
499+ right: subtitleLabel.right; \n\
500+ rightMargin: subtitleLabel.rightMargin; \n\
501+ top: subtitleLabel.bottom; \n\
502+ topMargin: units.dp(2);\n';
504+ attributesAnchors = subtitleAnchors;
460 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
508 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
@@ -464,11 +512,27 @@ function cardString(template, components) {
464 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
512 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
467− if (hasMascot && hasSubtitle) {
515+ if (hasMascot && (hasSubtitle || hasAttributes)) {
468 // If using row + column wrap the code in the column
516 // If using row + column wrap the code in the column
469 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
517 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
518+ if (hasSubtitle && hasAttributes) {
519+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
520+ titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
521+ } else if (hasSubtitle) {
522+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
523+ } else if (hasAttributes) {
524+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
525+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(attributesCode);
471− titleSubtitleCode = titleCode + subtitleCode;
528+ titleSubtitleCode = titleCode;
530+ titleSubtitleCode = titleSubtitleCode + subtitleCode;
532+ if (hasAttributes) {
533+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
534+ titleSubtitleCode = titleSubtitleCode + attributesCode;
@@ -488,6 +552,7 @@ function cardString(template, components) {
488 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
552 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
489 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
553 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
490 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
554 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
555+ else if (hasAttributes) summaryTopAnchor = "attributesRow.bottom";
491 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
556 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
492 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
557 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
493 else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
558 else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
@@ -500,7 +565,7 @@ function cardString(template, components) {
500 color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
565 color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
503− var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
568+ var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
505 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
570 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
@@ -511,6 +576,8 @@ function cardString(template, components) {
511 code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
576 code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
512 } else if (hasMascot) {
577 } else if (hasMascot) {
513 code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
578 code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
579+ } else if (hasAttributes) {
580+ code += 'implicitHeight: attributesRow.y + attributesRow.height + units.gu(1);\n';
514 } else if (hasSubtitle) {
581 } else if (hasSubtitle) {
515 code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
582 code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
516 } else if (hasTitle) {
583 } else if (hasTitle) {
@@ -527,8 +594,10 @@ function cardString(template, components) {
527function createCardComponent(parent, template, components) {
594function createCardComponent(parent, template, components) {
528 var imports = 'import QtQuick 2.2; \n\
595 var imports = 'import QtQuick 2.2; \n\
529 import Ubuntu.Components 0.1; \n\
596 import Ubuntu.Components 0.1; \n\
530− import Ubuntu.Thumbnailer 0.1;\n';
597+ import Ubuntu.Thumbnailer 0.1;\n\
598+ import Dash 0.1;\n';
531 var card = cardString(template, components);
599 var card = cardString(template, components);
532 var code = imports + 'Component {\n' + card + '}\n';
600 var code = imports + 'Component {\n' + card + '}\n';
533 return Qt.createQmlObject(code, parent, "createCardComponent");
602 return Qt.createQmlObject(code, parent, "createCardComponent");