on xenial help sign in
return -1 instead of undefined
5637c5dAlbert Astals Cid
qml/Dash/CardTool.qml+6−6
@@ -78,7 +78,7 @@ Item {
78 /*!
78 /*!
79 type:real \brief Width to be enforced on the card in this configuration.
79 type:real \brief Width to be enforced on the card in this configuration.
80
80
81− If undefined, should use implicit width of the actual card.
81+ If -1, should use implicit width of the actual card.
82 */
82 */
83 property real cardWidth: {
83 property real cardWidth: {
84 switch (categoryLayout) {
84 switch (categoryLayout) {
@@ -106,14 +106,14 @@ Item {
106 case "organic-grid":
106 case "organic-grid":
107 case "journal":
107 case "journal":
108 default:
108 default:
109− return undefined;
109+ return -1;
110 }
110 }
111 }
111 }
112
112
113 /*!
113 /*!
114 type:real \brief Height to be enforced on the card in this configuration.
114 type:real \brief Height to be enforced on the card in this configuration.
115
115
116− If undefined, should use implicit height of the actual card.
116+ If -1, should use implicit height of the actual card.
117 */
117 */
118 readonly property real cardHeight: {
118 readonly property real cardHeight: {
119 switch (categoryLayout) {
119 switch (categoryLayout) {
@@ -129,7 +129,7 @@ Item {
129 case "organic-grid":
129 case "organic-grid":
130 case "vertical-journal":
130 case "vertical-journal":
131 default:
131 default:
132− return undefined;
132+ return -1;
133 }
133 }
134 }
134 }
135
135
@@ -221,8 +221,8 @@ Item {
221 item.objectName = "cardToolCard";
221 item.objectName = "cardToolCard";
222 item.asynchronous = false;
222 item.asynchronous = false;
223 item.components = Qt.binding(function() { return cardTool.components; });
223 item.components = Qt.binding(function() { return cardTool.components; });
224− item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
224+ item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
225− item.height = Qt.binding(function() { return cardTool.cardHeight || item.implicitHeight; });
225+ item.height = Qt.binding(function() { return cardTool.cardHeight !== -1 ? cardTool.cardHeight : item.implicitHeight; });
226 }
226 }
227 Connections {
227 Connections {
228 target: cardTool
228 target: cardTool
tests/qmltests/Dash/tst_CardTool.qml+6−6
@@ -107,8 +107,8 @@ Rectangle {
107 Repeater {
107 Repeater {
108 model: [
108 model: [
109 { label: "View width", value: cardTool.viewWidth && cardTool.viewWidth / units.gu(1) },
109 { label: "View width", value: cardTool.viewWidth && cardTool.viewWidth / units.gu(1) },
110− { label: "Card width", value: cardTool.cardWidth && cardTool.cardWidth / units.gu(1) },
110+ { label: "Card width", value: cardTool.cardWidth !== -1 ? cardTool.cardWidth / units.gu(1) : undefined },
111− { label: "Card height", value: cardTool.cardHeight && cardTool.cardHeight / units.gu(1) },
111+ { label: "Card height", value: cardTool.cardHeight !== -1 ? cardTool.cardHeight / units.gu(1) : undefined },
112 ]
112 ]
113
113
114 delegate: Row {
114 delegate: Row {
@@ -265,10 +265,10 @@ Rectangle {
265 { tag: "Small", width: units.gu(12), height: function() { return internalCard ? internalCard.height : 0 }, index: 7 },
265 { tag: "Small", width: units.gu(12), height: function() { return internalCard ? internalCard.height : 0 }, index: 7 },
266 { tag: "Large", width: units.gu(38), height: function() { return internalCard ? internalCard.height : 0 }, index: 8 },
266 { tag: "Large", width: units.gu(38), height: function() { return internalCard ? internalCard.height : 0 }, index: 8 },
267 { tag: "Horizontal", width: units.gu(38), height: function() { return internalCard ? internalCard.height : 0 }, index: 9 },
267 { tag: "Horizontal", width: units.gu(38), height: function() { return internalCard ? internalCard.height : 0 }, index: 9 },
268− { tag: "OrganicGrid", width: undefined, height: undefined, index: 0, layout_index: 1},
268+ { tag: "OrganicGrid", width: -1, height: -1, index: 0, layout_index: 1},
269− { tag: "Journal", width: undefined, height: units.gu(20), size: 20, index: 0, layout_index: 2 },
269+ { tag: "Journal", width: -1, height: units.gu(20), size: 20, index: 0, layout_index: 2 },
270− { tag: "OversizedJournal", width: undefined, height: units.gu(18.5), size: 40, index: 0, layout_index: 2 },
270+ { tag: "OversizedJournal", width: -1, height: units.gu(18.5), size: 40, index: 0, layout_index: 2 },
271− { tag: "VerticalJournal", width: units.gu(18), height: undefined, index: 0, layout_index: 3 },
271+ { tag: "VerticalJournal", width: units.gu(18), height: -1, index: 0, layout_index: 3 },
272 { tag: "SmallCarousel", width: units.gu(18), height: units.gu(18), viewWidth: 30, index: 0, layout_index: 4},
272 { tag: "SmallCarousel", width: units.gu(18), height: units.gu(18), viewWidth: 30, index: 0, layout_index: 4},
273 { tag: "MediumCarousel", width: units.gu(22), height: units.gu(22), viewWidth: 84, index: 0, layout_index: 4},
273 { tag: "MediumCarousel", width: units.gu(22), height: units.gu(22), viewWidth: 84, index: 0, layout_index: 4},
274 { tag: "LargeCarousel", width: units.gu(26), height: units.gu(26), viewWidth: 140, index: 0, layout_index: 4},
274 { tag: "LargeCarousel", width: units.gu(26), height: units.gu(26), viewWidth: 140, index: 0, layout_index: 4},