on fcccc72 help sign in
unity8/qml/Dash/PreviewListView.qml
121 lines 3.7 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 int initialIndex: -1
27 property var scope: null
28 property var scopeStyle: null
30 property alias showSignatureLine: header.showSignatureLine
32 property alias open: previewListView.open
33 property alias model: previewListView.model
34 property alias currentIndex: previewListView.currentIndex
35 property alias currentItem: previewListView.currentItem
36 property alias count: previewListView.count
38 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
39 || currentItem.previewModel.processingAction)
41 signal backClicked()
43 PageHeader {
44 id: header
45 objectName: "pageHeader"
46 width: parent.width
47 title: root.scope ? root.scope.name : ""
48 showBackButton: true
49 searchEntryEnabled: false
50 scopeStyle: root.scopeStyle
52 onBackClicked: root.backClicked()
53 }
55 ListView {
56 id: previewListView
57 objectName: "listView"
58 anchors {
59 top: header.bottom
60 bottom: parent.bottom
61 left: parent.left
62 right: parent.right
63 }
64 orientation: ListView.Horizontal
65 highlightRangeMode: ListView.StrictlyEnforceRange
66 snapMode: ListView.SnapOneItem
67 boundsBehavior: Flickable.DragAndOvershootBounds
68 highlightMoveDuration: 250
69 flickDeceleration: units.gu(625)
70 maximumFlickVelocity: width * 5
71 cacheBuffer: 0
73 property bool open: false
75 onOpenChanged: {
76 if (!open) {
77 // Cancel any pending preview requests or actions
78 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
79 previewListView.currentItem.previewData.cancelAction();
80 }
81 root.scope.cancelActivation();
82 model = undefined;
83 }
84 }
86 onCountChanged: {
87 if (count > 0 && initialIndex >= 0) {
88 currentIndex = initialIndex;
89 initialIndex = -1;
90 }
91 }
93 delegate: Previews.Preview {
94 id: preview
95 objectName: "preview" + index
96 height: previewListView.height
97 width: previewListView.width
99 isCurrent: ListView.isCurrentItem
101 previewModel: {
102 var previewStack = root.scope.preview(result);
103 return previewStack.getPreviewModel(0);
104 }
105 scopeStyle: root.scopeStyle
106 }
107 }
109 MouseArea {
110 id: processingMouseArea
111 objectName: "processingMouseArea"
112 anchors {
113 left: parent.left
114 right: parent.right
115 top: header.bottom
116 bottom: parent.bottom
117 }
119 enabled: root.processing
120 }