2 * Copyright (C) 2013 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
20 import "../Components"
21 import "Previews" as Previews
26 property int initialIndex: -1
27 property var initialIndexPreviewStack: null
28 property var scope: null
29 property var scopeStyle: null
30 property string categoryId
31 property bool usedInitialIndex: false
33 property alias showSignatureLine: header.showSignatureLine
35 property alias open: previewListView.open
36 property alias model: previewListView.model
37 property alias currentIndex: previewListView.currentIndex
38 property alias currentItem: previewListView.currentItem
39 property alias count: previewListView.count
41 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
42 || currentItem.previewModel.processingAction)
48 objectName: "pageHeader"
50 title: root.scope ? root.scope.name : ""
52 searchEntryEnabled: false
53 scopeStyle: root.scopeStyle
55 onBackClicked: root.backClicked()
60 objectName: "listView"
67 orientation: ListView.Horizontal
68 highlightRangeMode: ListView.StrictlyEnforceRange
69 snapMode: ListView.SnapOneItem
70 boundsBehavior: Flickable.DragAndOvershootBounds
71 highlightMoveDuration: 250
72 flickDeceleration: units.gu(625)
73 maximumFlickVelocity: width * 5
76 property bool open: false
80 // Cancel any pending preview requests or actions
81 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
82 previewListView.currentItem.previewData.cancelAction();
84 root.scope.cancelActivation();
90 if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
91 usedInitialIndex = true;
92 previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
96 delegate: Previews.Preview {
98 objectName: "preview" + index
99 height: previewListView.height
100 width: previewListView.width
102 isCurrent: ListView.isCurrentItem
104 readonly property var previewStack: {
106 if (index === root.initialIndex) {
107 return root.initialIndexPreviewStack;
109 return root.scope.preview(result, root.categoryId);
118 return previewStack.getPreviewModel(0);
124 scopeStyle: root.scopeStyle
129 id: processingMouseArea
130 objectName: "processingMouseArea"
135 bottom: parent.bottom
138 enabled: root.processing