Unity 8
CardHorizontalList.qml
1 /*
2  * Copyright (C) 2014-2015 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.4
18 import Ubuntu.Components 1.3
19 import "../Components"
20 
21 DashRenderer {
22  id: root
23 
24  expandedHeight: cardTool.cardHeight + units.gu(2)
25  collapsedHeight: expandedHeight
26  growsVertically: false
27  innerWidth: Math.max(0, listView.width)
28  clip: true
29 
30  ListView {
31  id: listView
32  anchors {
33  fill: parent
34  margins: units.gu(1)
35  rightMargin: 0
36  }
37  rightMargin: units.gu(1)
38  spacing: units.gu(1)
39  model: root.model
40  orientation: ListView.Horizontal
41  cacheBuffer: root.cacheBuffer
42  displayMarginBeginning: root.displayMarginBeginning
43  displayMarginEnd: root.displayMarginEnd
44 
45  delegate: Loader {
46  id: loader
47  sourceComponent: cardTool.cardComponent
48  anchors { top: parent.top; bottom: parent.bottom }
49  width: cardTool.cardWidth
50  asynchronous: true
51  onLoaded: {
52  item.objectName = "delegate" + index;
53  item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
54  item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
55  item.cardData = Qt.binding(function() { return model; });
56  item.components = Qt.binding(function() { return cardTool.components; });
57  item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
58  item.scopeStyle = root.scopeStyle;
59  }
60  Connections {
61  target: loader.item
62  onClicked: root.clicked(index, result, loader.item, model)
63  onPressAndHold: root.pressAndHold(index, result, model)
64  }
65  }
66  }
67 }