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.1
19 import "../Components/Flickables" as Flickables
21 Flickables.Flickable {
24 signal clicked(int index, var result, var itemModel)
25 signal pressAndHold(int index)
27 property var cardTool: null
28 property real scopeHeight: 0
29 property real scopeWidth: 0
30 property real appliedScale: 1
31 property int currentIndex: -1
32 property var currentItem: currentIndex < repeater.count ? repeater.itemAt(currentIndex) : null
34 property alias model: repeater.model
37 contentWidth: repeater.count * root.scopeWidth + units.gu(2) / appliedScale * (repeater.count - 1)
40 var indexX = currentIndex * scopeWidth + units.gu(2) / appliedScale * currentIndex;
41 var newContentX = indexX - (width - scopeWidth) / 2;
42 newContentX = Math.min(Math.max(newContentX, 0), contentWidth - width);
48 objectName: "scopesOverviewFavoritesRepeater"
53 x: index * root.scopeWidth + units.gu(2) / appliedScale * index
56 sourceComponent: cardTool.cardComponent
58 item.fixedArtShapeSize = Qt.binding(function() { return Qt.size(root.scopeWidth, root.scopeHeight); });
59 item.fixedHeaderHeight = Qt.binding(function() { return cardTool.headerHeight / appliedScale; });
60 item.fontScale = Qt.binding(function() { return 1 / appliedScale; });
61 item.height = Qt.binding(function() { return root.scopeHeight; });
62 item.width = Qt.binding(function() { return root.scopeWidth; });
63 item.cardData = Qt.binding(function() { return model; });
64 item.template = Qt.binding(function() { return cardTool.template; });
65 item.components = Qt.binding(function() { return cardTool.components; });
66 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
71 onClicked: root.clicked(index, result, model)