on xenial help sign in
return -1 instead of undefined
commit5637c5deffb313c958cb992d3e26cea85fb552aa authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 28 Oct 2015, 16:17 (11 years ago) parentea2eceb
2 files changed+12−12
qml/Dash/CardTool.qml+6−6 tests/qmltests/Dash/tst_CardTool.qml+6−6
qml/Dash/CardTool.qml+6−6
@@ -78,7 +78,7 @@ Item {
7878 /*!
7979 type:real \brief Width to be enforced on the card in this configuration.
8080
81− If undefined, should use implicit width of the actual card.
81+ If -1, should use implicit width of the actual card.
8282 */
8383 property real cardWidth: {
8484 switch (categoryLayout) {
@@ -106,14 +106,14 @@ Item {
106106 case "organic-grid":
107107 case "journal":
108108 default:
109− return undefined;
109+ return -1;
110110 }
111111 }
112112
113113 /*!
114114 type:real \brief Height to be enforced on the card in this configuration.
115115
116− If undefined, should use implicit height of the actual card.
116+ If -1, should use implicit height of the actual card.
117117 */
118118 readonly property real cardHeight: {
119119 switch (categoryLayout) {
@@ -129,7 +129,7 @@ Item {
129129 case "organic-grid":
130130 case "vertical-journal":
131131 default:
132− return undefined;
132+ return -1;
133133 }
134134 }
135135
@@ -221,8 +221,8 @@ Item {
221221 item.objectName = "cardToolCard";
222222 item.asynchronous = false;
223223 item.components = Qt.binding(function() { return cardTool.components; });
224− item.width = Qt.binding(function() { return cardTool.cardWidth || item.implicitWidth; });
225− item.height = Qt.binding(function() { return cardTool.cardHeight || item.implicitHeight; });
224+ item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
225+ item.height = Qt.binding(function() { return cardTool.cardHeight !== -1 ? cardTool.cardHeight : item.implicitHeight; });
226226 }
227227 Connections {
228228 target: cardTool
tests/qmltests/Dash/tst_CardTool.qml+6−6
@@ -107,8 +107,8 @@ Rectangle {
107107 Repeater {
108108 model: [
109109 { label: "View width", value: cardTool.viewWidth && cardTool.viewWidth / units.gu(1) },
110− { label: "Card width", value: cardTool.cardWidth && cardTool.cardWidth / units.gu(1) },
111− { label: "Card height", value: cardTool.cardHeight && cardTool.cardHeight / units.gu(1) },
110+ { label: "Card width", value: cardTool.cardWidth !== -1 ? cardTool.cardWidth / units.gu(1) : undefined },
111+ { label: "Card height", value: cardTool.cardHeight !== -1 ? cardTool.cardHeight / units.gu(1) : undefined },
112112 ]
113113
114114 delegate: Row {
@@ -265,10 +265,10 @@ Rectangle {
265265 { tag: "Small", width: units.gu(12), height: function() { return internalCard ? internalCard.height : 0 }, index: 7 },
266266 { tag: "Large", width: units.gu(38), height: function() { return internalCard ? internalCard.height : 0 }, index: 8 },
267267 { 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},
269− { tag: "Journal", width: undefined, 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 },
271− { tag: "VerticalJournal", width: units.gu(18), height: undefined, index: 0, layout_index: 3 },
268+ { tag: "OrganicGrid", width: -1, height: -1, index: 0, layout_index: 1},
269+ { tag: "Journal", width: -1, height: units.gu(20), size: 20, 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: -1, index: 0, layout_index: 3 },
272272 { tag: "SmallCarousel", width: units.gu(18), height: units.gu(18), viewWidth: 30, index: 0, layout_index: 4},
273273 { tag: "MediumCarousel", width: units.gu(22), height: units.gu(22), viewWidth: 84, index: 0, layout_index: 4},
274274 { tag: "LargeCarousel", width: units.gu(26), height: units.gu(26), viewWidth: 140, index: 0, layout_index: 4},