on xenial help sign in
Integrate Card with scopes-ng and introduce CardFilterGrid.qml.
967bf53Michał Sawicz
Dash/Card.qml+2−1
@@ -31,7 +31,8 @@ Item {
31 width: root.width
31 width: root.width
32 height: width / artShape.aspect
32 height: width / artShape.aspect
33 objectName: "artImage"
33 objectName: "artImage"
34+ // FIXME should be no need for "icon"
34− source: cardData && cardData["art"] || ""
35+ source: cardData && cardData["art"] || cardData["icon"] || ""
35 //sourceSize.width: width > height ? width : 0
36 //sourceSize.width: width > height ? width : 0
36 //sourceSize.height: height > width ? height : -1
37 //sourceSize.height: height > width ? height : -1
37 fillMode: components["art"]["fill-mode"] == "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
38 fillMode: components["art"]["fill-mode"] == "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
Dash/CardFilterGrid.qmlnew file+44
@@ -0,0 +1,44 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+
20+DashFilterGrid {
21+ id: genericFilterGrid
22+
23+ minimumHorizontalSpacing: units.gu(0.5)
24+ // FIXME calculate the size correctly
25+ delegateWidth: grid.currentItem.width
26+ delegateHeight: grid.currentItem.height
27+ verticalSpacing: units.gu(2)
28+
29+ delegate: Card {
30+ id: tile
31+ objectName: "delegate" + index
32+ cardData: model
33+ template: genericFilterGrid.template
34+ components: {
35+ "art": {
36+ "aspect-ratio": 1.0,
37+ "fill-mode": "crop"
38+ }
39+ }
40+
41+ //onClicked: genericFilterGrid.clicked(index, tile.y)
42+ //onPressAndHold: genericFilterGrid.pressAndHold(index, tile.y)
43+ }
44+}
Dash/DashFilterGrid.qml+2
@@ -29,6 +29,8 @@ DashRenderer {
29 property alias maximumNumberOfColumns: filterGrid.maximumNumberOfColumns
29 property alias maximumNumberOfColumns: filterGrid.maximumNumberOfColumns
30 property alias minimumHorizontalSpacing: filterGrid.minimumHorizontalSpacing
30 property alias minimumHorizontalSpacing: filterGrid.minimumHorizontalSpacing
31
31
32+ property FilterGrid grid: filterGrid
33+
32 collapsedHeight: filterGrid.collapsedHeight
34 collapsedHeight: filterGrid.collapsedHeight
33 collapsedRowCount: filterGrid.collapsedRowCount
35 collapsedRowCount: filterGrid.collapsedRowCount
34 columns: filterGrid.columns
36 columns: filterGrid.columns
Dash/DashRenderer.qml+6
@@ -62,4 +62,10 @@ Item {
62
62
63 function startFilterAnimation(filter) {
63 function startFilterAnimation(filter) {
64 }
64 }
65+
66+ /// Category template definition from the scope
67+ property var template
68+
69+ /// Component mapping and configuration from the scope
70+ property var components
65}
71}
Dash/GenericScopeView.qml+4−1
@@ -163,6 +163,9 @@ FocusScope {
163 }
163 }
164 }
164 }
165 updateDelegateCreationRange();
165 updateDelegateCreationRange();
166+ // FIXME: should be "template", not "renderer"
167+ item.template = Qt.binding(function() { return model.renderer });
168+ item.components = Qt.binding(function() { return model.components });
166 }
169 }
167
170
168 Component.onDestruction: {
171 Component.onDestruction: {
@@ -340,7 +343,7 @@ FocusScope {
340 default: return "Generic/GenericFilterGrid.qml";
343 default: return "Generic/GenericFilterGrid.qml";
341 }
344 }
342 }
345 }
343− default: return "Generic/GenericFilterGrid.qml";
346+ default: return "CardFilterGrid.qml";
344 }
347 }
345 }
348 }
346
349