Unity 8
 All Classes Functions
CardVerticalJournal.qml
1 /*
2  * Copyright (C) 2014 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 import "../Components"
20 
21 DashRenderer {
22  id: root
23 
24  readonly property double collapseLimit: units.gu(35)
25 
26  expandedHeight: Math.max(cardVerticalJournal.implicitHeight, minHeight)
27  collapsedHeight: Math.max(Math.min(collapseLimit, cardVerticalJournal.implicitHeight), minHeight)
28  // TODO: implement collapsedItemCount
29 
30  // This minHeight is used as bootstrapper for the height. Vertical Journal
31  // is special by the fact that it doesn't know how to calculate its implicit height unless we give it
32  // enough height that it can start creating its children so we make sure it has enough height for that
33  // in case the model is non empty
34  readonly property double minHeight: root.model.count >= 1 ? cardVerticalJournal.rowSpacing + 1 : 0
35 
36  ResponsiveVerticalJournal {
37  id: cardVerticalJournal
38 
39  model: root.model
40 
41  anchors.fill: parent
42  rowSpacing: minimumColumnSpacing
43  columnWidth: cardTool.cardWidth
44 
45  displayMarginBeginning: root.displayMarginBeginning
46  displayMarginEnd: root.displayMarginEnd
47 
48  delegate: Loader {
49  id: loader
50  sourceComponent: cardTool.cardComponent
51  width: cardTool.cardWidth
52  onLoaded: {
53  item.objectName = "delegate" + index;
54  item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
55  item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
56  item.cardData = Qt.binding(function() { return model; });
57  item.template = Qt.binding(function() { return cardTool.template; });
58  item.components = Qt.binding(function() { return cardTool.components; });
59  item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
60  item.scopeStyle = root.scopeStyle;
61  }
62  Connections {
63  target: loader.item
64  onClicked: root.clicked(index, result, loader.item, model)
65  onPressAndHold: root.pressAndHold(index, model)
66  }
67  }
68  }
69 }