on aa5da49 help sign in
unity8/qml/Dash/PreviewListView.qml
109 lines 3.3 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Unity 0.2
20import "../Components"
21import "Previews" as Previews
23Item {
24 id: root
26 property var scope: null
27 property var scopeStyle: null
29 property alias open: previewListView.open
30 property alias model: previewListView.model
31 property alias currentIndex: previewListView.currentIndex
32 property alias currentItem: previewListView.currentItem
33 property alias count: previewListView.count
35 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
36 || currentItem.previewModel.processingAction)
38 PageHeader {
39 id: header
40 objectName: "pageHeader"
41 width: parent.width
42 title: scope ? scope.name : ""
43 showBackButton: true
44 searchEntryEnabled: false
45 scopeStyle: root.scopeStyle
47 onBackClicked: root.open = false
48 }
50 ListView {
51 id: previewListView
52 objectName: "listView"
53 anchors {
54 top: header.bottom
55 bottom: parent.bottom
56 left: parent.left
57 right: parent.right
58 }
59 orientation: ListView.Horizontal
60 highlightRangeMode: ListView.StrictlyEnforceRange
61 snapMode: ListView.SnapOneItem
62 boundsBehavior: Flickable.DragAndOvershootBounds
63 highlightMoveDuration: 250
64 flickDeceleration: units.gu(625)
65 maximumFlickVelocity: width * 5
66 cacheBuffer: 0
68 property bool open: false
70 onOpenChanged: {
71 if (!open) {
72 // Cancel any pending preview requests or actions
73 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
74 previewListView.currentItem.previewData.cancelAction();
75 }
76 scope.cancelActivation();
77 model = undefined;
78 }
79 }
81 delegate: Previews.Preview {
82 id: preview
83 objectName: "preview" + index
84 height: previewListView.height
85 width: previewListView.width
87 isCurrent: ListView.isCurrentItem
89 previewModel: {
90 var previewStack = root.scope.preview(result);
91 return previewStack.getPreviewModel(0);
92 }
93 scopeStyle: root.scopeStyle
94 }
95 }
97 MouseArea {
98 id: processingMouseArea
99 objectName: "processingMouseArea"
100 anchors {
101 left: parent.left
102 right: parent.right
103 top: header.bottom
104 bottom: parent.bottom
105 }
107 enabled: root.processing
108 }