@@ -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\
@@ -268,6 +283,15 @@ var kSubtitleLabelCode = 'Label { \n\
268 horizontalAlignment: root.headerAlignment; \n\
283 horizontalAlignment: root.headerAlignment; \n\
286+// %1 is used as anchors of attributesRow
287+var kAttributesRowCode = 'CardAttributes { \n\
288+ id: attributesRow; \n\
289+ objectName: "attributesRow"; \n\
292+ model: cardData["attributes"]; \n\
271// %1 is used as top anchor of summary
295// %1 is used as top anchor of summary
272// %2 is used as topMargin anchor of summary
296// %2 is used as topMargin anchor of summary
273// %3 is used as color of summary
297// %3 is used as color of summary
@@ -318,6 +342,7 @@ function cardString(template, components) {
318 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
342 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
319 var hasSubtitle = hasTitle && components["subtitle"] || false;
343 var hasSubtitle = hasTitle && components["subtitle"] || false;
320 var hasHeaderRow = hasMascot && hasTitle;
344 var hasHeaderRow = hasMascot && hasTitle;
345+ var hasAttributes = hasTitle && components["attributes"] || false;
322 if (hasBackground) {
347 if (hasBackground) {
323 code += kBackgroundLoaderCode;
348 code += kBackgroundLoaderCode;
@@ -387,6 +412,14 @@ function cardString(template, components) {
387 code += 'readonly property int headerHeight: row.height;\n'
412 code += 'readonly property int headerHeight: row.height;\n'
388 } else if (hasMascot) {
413 } else if (hasMascot) {
389 code += 'readonly property int headerHeight: mascotImage.height;\n'
414 code += 'readonly property int headerHeight: mascotImage.height;\n'
415+ } else if (hasAttributes) {
416+ if (hasTitle && hasSubtitle) {
417+ code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
418+ } else if (hasTitle) {
419+ code += 'readonly property int headerHeight: titleLabel.height + attributesRow.height + attributesRow.anchors.topMargin;\n'
421+ code += 'readonly property int headerHeight: attributesRow.height;\n'
390 } else if (hasSubtitle) {
423 } else if (hasSubtitle) {
391 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
424 code += 'readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;\n'
392 } else if (hasTitle) {
425 } else if (hasTitle) {
@@ -435,10 +468,12 @@ function cardString(template, components) {
436 var titleAnchors;
469 var titleAnchors;
437 var subtitleAnchors;
470 var subtitleAnchors;
471+ var attributesAnchors;
438− if (hasMascot && hasSubtitle) {
472+ if (hasMascot && (hasSubtitle || hasAttributes)) {
439 // Using row + column
473 // Using row + column
440 titleAnchors = 'left: parent.left; right: parent.right';
474 titleAnchors = 'left: parent.left; right: parent.right';
441 subtitleAnchors = titleAnchors;
475 subtitleAnchors = titleAnchors;
476+ attributesAnchors = subtitleAnchors;
442 } else if (hasMascot) {
477 } else if (hasMascot) {
443 // Using row + label
478 // Using row + label
444 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
479 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'
@@ -448,11 +483,13 @@ function cardString(template, components) {
448 titleAnchors = 'left: parent.left; \n\
483 titleAnchors = 'left: parent.left; \n\
449 leftMargin: units.gu(1); \n\
484 leftMargin: units.gu(1); \n\
450 right: parent.right; \n\
485 right: parent.right; \n\
486+ rightMargin: units.gu(1); \n\
451 top: overlayLoader.top; \n\
487 top: overlayLoader.top; \n\
452 topMargin: units.gu(1);\n';
488 topMargin: units.gu(1);\n';
454 // Using anchors to the mascot/parent
490 // Using anchors to the mascot/parent
455− titleAnchors = "right: parent.right;";
491+ titleAnchors = "right: parent.right;\n";
492+ titleAnchors += "rightMargin: units.gu(1);\n";
456 titleAnchors += headerLeftAnchor;
493 titleAnchors += headerLeftAnchor;
457 titleAnchors += headerVerticalAnchors;
494 titleAnchors += headerVerticalAnchors;
458 if (!headerLeftAnchorHasMargin) {
495 if (!headerLeftAnchorHasMargin) {
@@ -462,8 +499,19 @@ function cardString(template, components) {
462 subtitleAnchors = 'left: titleLabel.left; \n\
499 subtitleAnchors = 'left: titleLabel.left; \n\
463 leftMargin: titleLabel.leftMargin; \n\
500 leftMargin: titleLabel.leftMargin; \n\
464 right: titleLabel.right; \n\
501 right: titleLabel.right; \n\
502+ rightMargin: titleLabel.rightMargin; \n\
465 top: titleLabel.bottom; \n\
503 top: titleLabel.bottom; \n\
466 topMargin: units.dp(2);\n';
504 topMargin: units.dp(2);\n';
506+ attributesAnchors = 'left: subtitleLabel.left; \n\
507+ leftMargin: subtitleLabel.leftMargin; \n\
508+ right: subtitleLabel.right; \n\
509+ rightMargin: subtitleLabel.rightMargin; \n\
510+ top: subtitleLabel.bottom; \n\
511+ topMargin: units.dp(2);\n';
513+ attributesAnchors = subtitleAnchors;
469 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
517 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
@@ -473,11 +521,27 @@ function cardString(template, components) {
473 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
521 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
476− if (hasMascot && hasSubtitle) {
524+ if (hasMascot && (hasSubtitle || hasAttributes)) {
477 // If using row + column wrap the code in the column
525 // If using row + column wrap the code in the column
478 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
526 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
527+ if (hasSubtitle && hasAttributes) {
528+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
529+ titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
530+ } else if (hasSubtitle) {
531+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
532+ } else if (hasAttributes) {
533+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
534+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(attributesCode);
480− titleSubtitleCode = titleCode + subtitleCode;
537+ titleSubtitleCode = titleCode;
539+ titleSubtitleCode = titleSubtitleCode + subtitleCode;
541+ if (hasAttributes) {
542+ var attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(color);
543+ titleSubtitleCode = titleSubtitleCode + attributesCode;
@@ -497,6 +561,7 @@ function cardString(template, components) {
497 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
561 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
498 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
562 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
499 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
563 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
564+ else if (hasAttributes) summaryTopAnchor = "attributesRow.bottom";
500 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
565 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
501 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
566 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
502 else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
567 else if (hasArt) summaryTopAnchor = "artShapeHolder.bottom";
@@ -509,7 +574,7 @@ function cardString(template, components) {
509 color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
574 color = 'root.scopeStyle ? root.scopeStyle.foreground : "grey"';
512− var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
577+ var summaryTopMargin = (hasMascot || hasSubtitle || hasAttributes ? 'anchors.margins' : '0');
514 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
579 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(color);
@@ -530,6 +595,8 @@ function cardString(template, components) {
530 code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
595 code += 'implicitHeight: row.y + row.height + units.gu(1);\n';
531 } else if (hasMascot) {
596 } else if (hasMascot) {
532 code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
597 code += 'implicitHeight: mascotImage.y + mascotImage.height;\n';
598+ } else if (hasAttributes) {
599+ code += 'implicitHeight: attributesRow.y + attributesRow.height + units.gu(1);\n';
533 } else if (hasSubtitle) {
600 } else if (hasSubtitle) {
534 code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
601 code += 'implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
535 } else if (hasTitle) {
602 } else if (hasTitle) {
@@ -546,8 +613,10 @@ function cardString(template, components) {
546function createCardComponent(parent, template, components) {
613function createCardComponent(parent, template, components) {
547 var imports = 'import QtQuick 2.2; \n\
614 var imports = 'import QtQuick 2.2; \n\
548 import Ubuntu.Components 0.1; \n\
615 import Ubuntu.Components 0.1; \n\
549− import Ubuntu.Thumbnailer 0.1;\n';
616+ import Ubuntu.Thumbnailer 0.1;\n\
617+ import Dash 0.1;\n';
550 var card = cardString(template, components);
618 var card = cardString(template, components);
551 var code = imports + 'Component {\n' + card + '}\n';
619 var code = imports + 'Component {\n' + card + '}\n';
552 return Qt.createQmlObject(code, parent, "createCardComponent");
621 return Qt.createQmlObject(code, parent, "createCardComponent");