@@ -19,42 +19,63 @@ import Ubuntu.Components 0.1
1919import "../Components"
2020
2121DashRenderer {
22− id: genericVerticalJournal
22+ id: root
2323
24− property alias minimumColumnSpacing: cardVerticalJournal.minimumColumnSpacing
25− property alias maximumNumberOfColumns: cardVerticalJournal.maximumNumberOfColumns
26− property alias columnWidth: cardVerticalJournal.columnWidth
27− property alias rowSpacing: cardVerticalJournal.rowSpacing
24+ readonly property double collapseLimit: units.gu(35)
2825
29− anchors.fill: parent
26+ uncollapsedHeight: cardVerticalJournal.implicitHeight
27+ collapsedHeight: Math.min(collapseLimit, cardVerticalJournal.implicitHeight)
28+ expandable: uncollapsedHeight > collapseLimit
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 it's 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+ height: filtered ? Math.max(collapsedHeight, minHeight) : uncollapsedHeight
36+
37+ Behavior on height {
38+ id: heightBehaviour
39+ animation: UbuntuNumberAnimation { }
40+ }
41+
42+ function setFilter(filter, animate) {
43+ heightBehaviour.enabled = animate;
44+ filtered = filter;
45+ }
3046
3147 ResponsiveVerticalJournal {
3248 id: cardVerticalJournal
49+
50+ model: root.model
51+
3352 anchors.fill: parent
34− maximumNumberOfColumns: 2
35− minimumColumnSpacing: units.gu(1)
36− rowSpacing: units.gu(1)
37− model: genericVerticalJournal.model
38−
39− columnWidth: {
40− if (genericVerticalJournal.template !== undefined) {
41− switch (genericVerticalJournal.template['card-size']) {
42− case "small": return units.gu(12);
43− case "large": return units.gu(38);
44− }
45− }
46− return units.gu(18.5);
47− }
53+ rowSpacing: minimumColumnSpacing
54+ columnWidth: cardTool.cardWidth
4855
49− delegate: Card {
50− id: card
51− objectName: "delegate" + index
52− cardData: model
53− template: genericVerticalJournal.template
54− components: genericVerticalJournal.components
56+ displayMarginBeginning: root.displayMarginBeginning
57+ displayMarginEnd: root.displayMarginEnd
5558
56− //onClicked: cardVerticalJournal.clicked(index, tile.y)
57− //onPressAndHold: cardVerticalJournal.pressAndHold(index, tile.y)
59+ delegate: Loader {
60+ id: loader
61+ sourceComponent: cardTool.cardComponent
62+ width: cardTool.cardWidth
63+ anchors.horizontalCenter: parent.horizontalCenter
64+ onLoaded: {
65+ item.objectName = "delegate" + index;
66+ item.width = Qt.binding(function() { return cardTool.cardWidth; });
67+ item.height = Qt.binding(function() { return cardTool.cardHeight; });
68+ item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
69+ item.cardData = Qt.binding(function() { return model; });
70+ item.template = Qt.binding(function() { return cardTool.template; });
71+ item.components = Qt.binding(function() { return cardTool.components; });
72+ item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
73+ }
74+ Connections {
75+ target: loader.item
76+ onClicked: root.clicked(index, result)
77+ onPressAndHold: root.pressAndHold(index)
78+ }
5879 }
5980 }
6081}