@@ -28,20 +28,47 @@ import QtQuick 2.0
30 id: cardTool
30 id: cardTool
33+ type:int \brief number of cards.
38+ type:real \brief width of the category view.
40+ property real viewWidth
43+ type:real \brief Scaling factor of selected Carousel item.
45+ readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
32 \brief Template supplied for the category.
48 \brief Template supplied for the category.
34 property var template
50 property var template
53+ \brief Tool component for Carousel.
55+ property var carouselTool
37 \brief Component mapping supplied for the category.
58 \brief Component mapping supplied for the category.
39 property var components
60 property var components
42− \brief Width of the view, based on which carousel width is calculated.
63+ type:string \brief The category layout for this card tool.
44− property var viewWidth
65+ property string categoryLayout: {
66+ var layout = template["category-layout"];
68+ // carousel fallback mode to grid
69+ if (layout === "carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout = "grid";
46 // FIXME: Saviq
73 // FIXME: Saviq
47 // Only way for the card below to actually be laid out completely.
74 // Only way for the card below to actually be laid out completely.
@@ -56,7 +83,7 @@ Item {
56 If undefined, should use implicit width of the actual card.
83 If undefined, should use implicit width of the actual card.
58 readonly property var cardWidth: {
85 readonly property var cardWidth: {
59− switch (template !== undefined && template["category-layout"]) {
86+ switch (categoryLayout) {
60 case "grid":
87 case "grid":
61 case "vertical-journal":
88 case "vertical-journal":
62 if (template["card-layout"] === "horizontal") return units.gu(38);
89 if (template["card-layout"] === "horizontal") return units.gu(38);
@@ -66,10 +93,7 @@ Item {
67 return units.gu(18.5);
94 return units.gu(18.5);
68 case "carousel":
95 case "carousel":
69− if (viewWidth === undefined) return undefined
96+ return carouselTool.minimumTileWidth;
70− if (viewWidth <= units.gu(40)) return units.gu(18)
71− if (viewWidth >= units.gu(128)) return units.gu(26)
72− return units.gu(18 + Math.round((viewWidth - units.gu(40))/ units.gu(11)))
73 case undefined:
97 case undefined:
74 case "organic-grid":
98 case "organic-grid":
75 case "journal":
99 case "journal":
@@ -84,7 +108,7 @@ Item {
84 If undefined, should use implicit height of the actual card.
108 If undefined, should use implicit height of the actual card.
86 readonly property var cardHeight: {
110 readonly property var cardHeight: {
87− switch (template !== undefined && template["category-layout"]) {
111+ switch (categoryLayout) {
88 case "journal":
112 case "journal":
89 if (template["card-size"] >= 12 && template["card-size"] <= 38) return units.gu(template["card-size"]);
113 if (template["card-size"] >= 12 && template["card-size"] <= 38) return units.gu(template["card-size"]);
90 return units.gu(18.5);
114 return units.gu(18.5);
@@ -123,6 +147,25 @@ Item {
123 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;
147 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;
153+ property real minimumTileWidth: {
154+ if (cardTool.viewWidth === undefined) return undefined;
155+ if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
156+ if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
157+ return units.gu(18 + Math.round((cardTool.viewWidth - units.gu(40)) / units.gu(11)));
160+ readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
162+ property real realPathItemCount: {
163+ var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
164+ var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
165+ return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
128 objectName: "card"
171 objectName: "card"