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/>.
18import Ubuntu.Components 0.1
20import "../Components/ListItems" as ListItems
24 readonly property alias previewShown: previewLoader.onScreen
27 pageHeader.resetSearch();
28 previewLoader.open = false;
31 onMovementStarted: categoryView.showHeader()
34 target: scopeView.scope
35 property: "searchQuery"
36 value: pageHeader.searchQuery
41 property: "searchQuery"
42 value: scopeView.scope.searchQuery
47 onSearchClicked: if (isCurrent) {
48 pageHeader.triggerSearch()
49 categoryView.showHeader()
54 target: scopeView.scope
55 onShowDash: previewLoader.open = false;
56 onHideDash: previewLoader.open = false;
62 model: scopeView.categories
63 forceNoClip: previewLoader.onScreen
65 onAtYEndChanged: if (atYEnd) endReached()
66 onMovingChanged: if (moving && atYEnd) endReached()
68 property string expandedCategoryId: ""
70 delegate: ListItems.Base {
71 highlightWhenPressed: false
73 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
74 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
75 readonly property string category: categoryId
85 source: getRenderer(model.renderer, model.contentType)
88 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
89 // TODO: the running apps grid doesn't support standard scope results model yet
90 item.firstModel = Qt.binding(function() { return results.firstModel })
91 item.secondModel = Qt.binding(function() { return results.secondModel })
93 item.model = Qt.binding(function() { return results })
95 item.objectName = Qt.binding(function() { return categoryId })
96 if (item.expandable) {
97 var shouldFilter = categoryId != categoryView.expandedCategoryId;
98 if (shouldFilter != item.filter) {
99 item.filter = shouldFilter;
105 target: rendererLoader.item
107 effect.positionPx = mapToItem(categoryView, 0, itemY).y
108 scopeView.scope.activate(delegateItem.model.uri,
109 delegateItem.model.icon,
110 delegateItem.model.category,
112 delegateItem.model.mimetype,
113 delegateItem.model.title,
114 delegateItem.model.comment,
115 delegateItem.model.dndUri,
116 delegateItem.model.metadata)
119 effect.positionPx = mapToItem(categoryView, 0, itemY).y
120 scopeView.scope.preview( delegateItem.model.uri,
121 delegateItem.model.icon,
122 delegateItem.model.category,
124 delegateItem.model.mimetype,
125 delegateItem.model.title,
126 delegateItem.model.comment,
127 delegateItem.model.dndUri,
128 delegateItem.model.metadata)
133 onExpandedCategoryIdChanged: {
134 var item = rendererLoader.item;
135 if (item.expandable) {
136 var shouldFilter = categoryId != categoryView.expandedCategoryId;
137 if (shouldFilter != item.filter) {
138 // If the filter animation will be seen start it, otherwise, just flip the switch
139 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
140 var growingVisible = !shouldFilter && y + height < categoryView.height;
141 if (shrinkingVisible || growingVisible) {
142 item.startFilterAnimation(shouldFilter)
144 item.filter = shouldFilter;
147 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
156 sectionProperty: "name"
157 sectionDelegate: ListItems.Header {
158 property var delegate: categoryView.item(delegateIndex)
159 width: categoryView.width
162 if (delegate && delegate.expandable)
163 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
167 if (categoryView.expandedCategoryId != delegate.category)
168 categoryView.expandedCategoryId = delegate.category;
170 categoryView.expandedCategoryId = "";
173 pageHeader: PageHeader {
175 objectName: "pageHeader"
176 width: categoryView.width
177 text: scopeView.scope.name
178 searchEntryEnabled: true
182 function getDefaultRendererId(contentType) {
183 switch (contentType) {
184 default: return "grid";
188 function getRenderer(rendererId, contentType) {
189 if (rendererId == "default") {
190 rendererId = getDefaultRendererId(contentType);
192 switch (rendererId) {
194 switch (contentType) {
195 case "video": return "Generic/GenericFilterGridPotrait.qml";
196 case "music": return "Music/MusicFilterGrid.qml";
197 default: return "Generic/GenericFilterGrid.qml";
200 case "carousel": return "Generic/GenericCarousel.qml";
202 switch (contentType) {
203 case "apps": return "Apps/RunningApplicationsGrid.qml";
204 default: return "Generic/GenericFilterGrid.qml";
207 default: return "Generic/GenericFilterGrid.qml";
215 bottomMargin: -bottomOverflow
217 sourceItem: categoryView
221 topGapPx: (1 - gap) * positionPx
222 topOpacity: (1 - gap * 1.2)
223 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
224 bottomOverflow: units.gu(20)
225 bottomOpacity: 1 - (gap * 0.8)
227 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
228 property real gap: previewLoader.open ? 1.0 : 0.0
233 easing.type: Easing.InOutQuad
235 if (!previewLoader.open && !running) {
236 previewLoader.onScreen = false
244 target: scopeView.scope
246 previewLoader.previewData = preview
247 previewLoader.open = true
251 PreviewDelegateMapper {
252 id: previewDelegateMapper
256 ignoreUnknownSignals: true
257 target: previewLoader.valid ? previewLoader.item : null
259 previewLoader.open = false
264 objectName: "previewLoader"
266 property var previewData
267 height: effect.bottomGapPx - effect.topGapPx
270 topMargin: effect.topGapPx
274 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
276 property bool open: false
277 property bool onScreen: false
278 property bool valid: item !== null
287 item.previewData = Qt.binding(function() { return previewLoader.previewData })
291 // TODO: Move as InverseMouseArea to DashPreview
293 enabled: previewLoader.onScreen
296 topMargin: effect.bottomGapPx
299 previewLoader.open = false;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list