2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 1.3
19 import "../Components"
24 readonly property double collapseLimit: units.gu(35)
26 expandedHeight: Math.max(cardVerticalJournal.implicitHeight, minHeight)
27 collapsedHeight: Math.max(Math.min(collapseLimit, cardVerticalJournal.implicitHeight), minHeight)
28 // TODO: implement collapsedItemCount
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
36 function clearView() {
37 cardVerticalJournal.model = null;
38 cardVerticalJournal.model = root.model;
41 // Clear the view if the cardTool changes its sizes
42 // means it is still settling. This is
43 // necessary because the VerticalJournal does
44 // not support its elements changing height so
45 // we need to construct all the items with the settled
46 // size of the cardTool
49 onArtShapeSizeChanged: root.clearView();
50 onHeaderHeightChanged: root.clearView();
53 ResponsiveVerticalJournal {
54 id: cardVerticalJournal
59 rowSpacing: minimumColumnSpacing
60 columnWidth: cardTool.cardWidth
62 cacheBuffer: root.cacheBuffer
63 displayMarginBeginning: root.displayMarginBeginning
64 displayMarginEnd: root.displayMarginEnd
68 sourceComponent: cardTool.cardComponent
69 width: cardTool.cardWidth
71 item.objectName = "delegate" + index;
72 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
73 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight; });
74 item.cardData = Qt.binding(function() { return model; });
75 item.components = Qt.binding(function() { return cardTool.components; });
76 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
77 item.scopeStyle = root.scopeStyle;
81 onClicked: root.clicked(index, result, loader.item, model)
82 onPressAndHold: root.pressAndHold(index, result, model)