@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818
19−ListView {
19+Flickable {
2020 id: root
2121
2222 signal clicked(int index, var result)
@@ -26,30 +26,46 @@ ListView {
2626 property real scopeHeight: 0
2727 property real scopeWidth: 0
2828 property real appliedScale: 1
29+ property int currentIndex: -1
30+ property var currentItem: repeater.itemAt(currentIndex);
2931
30− orientation: ListView.Horizontal
31− highlightMoveDuration: 0
32+ property alias model: repeater.model
3233
33− spacing: units.gu(2) / appliedScale
34+ contentHeight: height
35+ contentWidth: repeater.count * root.scopeWidth + units.gu(2) / appliedScale * (repeater.count - 1)
3436
35− delegate: Loader {
36− id: loader
37+ contentX: {
38+ var indexX = currentIndex * scopeWidth + units.gu(2) / appliedScale * currentIndex;
39+ var newContentX = indexX - (width - scopeWidth) / 2;
40+ newContentX = Math.min(Math.max(newContentX, 0), contentWidth - width);
41+ return newContentX;
42+ }
3743
38− sourceComponent: cardTool.cardComponent
39− onLoaded: {
40− item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight / appliedScale; });
41− item.fontScale = Qt.binding(function() { return 1 / appliedScale; });
42− item.height = Qt.binding(function() { return root.scopeHeight; });
43− item.width = Qt.binding(function() { return root.scopeWidth; });
44− item.cardData = Qt.binding(function() { return model; });
45− item.template = Qt.binding(function() { return cardTool.template; });
46− item.components = Qt.binding(function() { return cardTool.components; });
47− item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
48− }
44+ Repeater {
45+ id: repeater
46+
47+ delegate: Loader {
48+ id: loader
49+
50+ x: index * root.scopeWidth + units.gu(2) / appliedScale * index
51+ asynchronous: true
52+
53+ sourceComponent: cardTool.cardComponent
54+ onLoaded: {
55+ item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight / appliedScale; });
56+ item.fontScale = Qt.binding(function() { return 1 / appliedScale; });
57+ item.height = Qt.binding(function() { return root.scopeHeight; });
58+ item.width = Qt.binding(function() { return root.scopeWidth; });
59+ item.cardData = Qt.binding(function() { return model; });
60+ item.template = Qt.binding(function() { return cardTool.template; });
61+ item.components = Qt.binding(function() { return cardTool.components; });
62+ item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
63+ }
4964
50− Connections {
51− target: loader.item
52− onClicked: root.clicked(index, result)
65+ Connections {
66+ target: loader.item
67+ onClicked: root.clicked(index, result)
68+ }
5369 }
5470 }
5571}