Unity 8
 All Classes Functions Properties
CardFilterGrid.qml
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 "../Components"
19 
20 DashRenderer {
21  id: genericFilterGrid
22 
23  expandable: filterGrid.expandable
24  collapsedHeight: filterGrid.collapsedHeight
25  margins: filterGrid.margins
26  uncollapsedHeight: filterGrid.uncollapsedHeight
27  originY: filterGrid.originY
28  verticalSpacing: units.gu(1)
29  currentItem: filterGrid.currentItem
30  height: filterGrid.height
31 
32  function startFilterAnimation(filter) {
33  filterGrid.startFilterAnimation(filter)
34  }
35 
36  FilterGrid {
37  id: filterGrid
38  width: genericFilterGrid.width
39  minimumHorizontalSpacing: units.gu(1)
40  delegateWidth: cardTool.cardWidth
41  delegateHeight: cardTool.cardHeight
42  verticalSpacing: genericFilterGrid.verticalSpacing
43  model: genericFilterGrid.model
44  filter: genericFilterGrid.filter
45  collapsedRowCount: Math.min(2, cardTool && cardTool.template && cardTool.template["collapsed-rows"] || 2)
46  delegateCreationBegin: genericFilterGrid.delegateCreationBegin
47  delegateCreationEnd: genericFilterGrid.delegateCreationEnd
48  delegate: Loader {
49  asynchronous: true
50  width: filterGrid.cellWidth
51  height: filterGrid.cellHeight
52  Card {
53  id: card
54  width: cardTool.cardWidth
55  height: cardTool.cardHeight
56  fixedHeaderHeight: cardTool.headerHeight
57  anchors.horizontalCenter: parent.horizontalCenter
58  objectName: "delegate" + index
59  cardData: model
60  template: cardTool.template
61  components: cardTool.components
62 
63  headerAlignment: cardTool.headerAlignment
64 
65  onClicked: genericFilterGrid.clicked(index, card.y)
66  onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
67  }
68  }
69 
70  onFilterChanged: {
71  genericFilterGrid.filter = filter
72  filter = Qt.binding(function() { return genericFilterGrid.filter })
73  }
74  }
75 }