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
25 property bool enableHeightBehaviorOnNextCreation: false
27 moving: categoryView.moving
30 pageHeader.resetSearch();
31 previewLoader.open = false;
34 onMovementStarted: categoryView.showHeader()
36 onPositionedAtBeginning: categoryView.positionAtBeginning()
39 target: scopeView.scope
40 property: "searchQuery"
41 value: pageHeader.searchQuery
46 property: "searchQuery"
47 value: scopeView.scope.searchQuery
52 onSearchClicked: if (isCurrent) {
53 pageHeader.triggerSearch()
54 categoryView.showHeader()
59 target: scopeView.scope
60 onShowDash: previewLoader.open = false;
61 onHideDash: previewLoader.open = false;
62 onActivated: previewLoader.closePreviewSpinner();
67 objectName: "categoryListView"
69 model: scopeView.categories
70 forceNoClip: previewLoader.onScreen
72 onAtYEndChanged: if (atYEnd) endReached()
73 onMovingChanged: if (moving && atYEnd) endReached()
75 property string expandedCategoryId: ""
77 delegate: ListItems.Base {
79 highlightWhenPressed: false
81 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
82 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
83 readonly property string category: categoryId
93 source: getRenderer(model.renderer, model.contentType, model.rendererHint)
96 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
97 item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
98 scopeView.enableHeightBehaviorOnNextCreation = false;
100 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
101 // TODO: the running apps grid doesn't support standard scope results model yet
102 item.firstModel = Qt.binding(function() { return results.firstModel })
103 item.secondModel = Qt.binding(function() { return results.secondModel })
104 item.canEnableTerminationMode = Qt.binding(function() { return scopeView.isCurrent })
106 item.model = Qt.binding(function() { return results })
108 item.objectName = Qt.binding(function() { return categoryId })
109 if (item.expandable) {
110 var shouldFilter = categoryId != categoryView.expandedCategoryId;
111 if (shouldFilter != item.filter) {
112 item.filter = shouldFilter;
115 updateDelegateCreationRange();
118 Component.onDestruction: {
119 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
120 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
125 target: rendererLoader.item
127 effect.positionPx = mapToItem(categoryView, 0, itemY).y
128 scopeView.scope.activate(delegateItem.model.uri,
129 delegateItem.model.icon,
130 delegateItem.model.category,
132 delegateItem.model.mimetype,
133 delegateItem.model.title,
134 delegateItem.model.comment,
135 delegateItem.model.dndUri,
136 delegateItem.model.metadata)
139 effect.positionPx = mapToItem(categoryView, 0, itemY).y
140 scopeView.scope.preview( delegateItem.model.uri,
141 delegateItem.model.icon,
142 delegateItem.model.category,
144 delegateItem.model.mimetype,
145 delegateItem.model.title,
146 delegateItem.model.comment,
147 delegateItem.model.dndUri,
148 delegateItem.model.metadata)
153 onExpandedCategoryIdChanged: {
154 var item = rendererLoader.item;
155 if (item.expandable) {
156 var shouldFilter = categoryId != categoryView.expandedCategoryId;
157 if (shouldFilter != item.filter) {
158 // If the filter animation will be seen start it, otherwise, just flip the switch
159 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
160 var growingVisible = !shouldFilter && y + height < categoryView.height;
161 if (shrinkingVisible || growingVisible) {
162 item.startFilterAnimation(shouldFilter)
164 item.filter = shouldFilter;
167 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
172 onContentYChanged: rendererLoader.updateDelegateCreationRange();
173 onHeightChanged: rendererLoader.updateDelegateCreationRange();
176 function updateDelegateCreationRange() {
177 // Do not update the range if we are overshooting up or down, since we'll come back
178 // to the stable position and delete/create items without any reason
179 if (categoryView.contentY < categoryView.originY) {
181 } else if (categoryView.contentY + categoryView.height > categoryView.contentHeight) {
185 if (item.hasOwnProperty("delegateCreationBegin")) {
186 if (baseItem.y + baseItem.height <= 0) {
187 // Not visible (item at top of the list)
188 item.delegateCreationBegin = baseItem.height
189 item.delegateCreationEnd = baseItem.height
190 } else if (baseItem.y >= categoryView.height) {
191 // Not visible (item at bottom of the list)
192 item.delegateCreationBegin = 0
193 item.delegateCreationEnd = 0
195 item.delegateCreationBegin = Math.max(-baseItem.y, 0)
196 item.delegateCreationEnd = Math.min(categoryView.height + item.delegateCreationBegin, baseItem.height)
203 sectionProperty: "name"
204 sectionDelegate: ListItems.Header {
205 property var delegate: categoryView.item(delegateIndex)
206 width: categoryView.width
209 if (delegate && delegate.expandable)
210 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
214 if (categoryView.expandedCategoryId != delegate.category)
215 categoryView.expandedCategoryId = delegate.category;
217 categoryView.expandedCategoryId = "";
220 pageHeader: PageHeader {
222 objectName: "pageHeader"
223 width: categoryView.width
224 text: scopeView.scope.name
225 searchEntryEnabled: true
226 scope: scopeView.scope
230 function getDefaultRendererId(contentType) {
231 switch (contentType) {
232 default: return "grid";
236 function getRenderer(rendererId, contentType, rendererHint) {
237 if (rendererId == "default") {
238 rendererId = getDefaultRendererId(contentType);
240 switch (rendererId) {
242 switch (contentType) {
243 case "video": return "Video/VideoFilterGrid.qml";
244 case "music": return "Music/MusicFilterGrid.qml";
246 if (rendererHint == "toggled")
247 return "Apps/DashPluginFilterGrid.qml";
249 return "Generic/GenericFilterGrid.qml";
251 case "weather": return "Generic/WeatherFilterGrid.qml";
252 default: return "Generic/GenericFilterGrid.qml";
256 switch (contentType) {
257 case "music": return "Music/MusicCarousel.qml";
258 default: return "Generic/GenericCarousel.qml";
262 switch (contentType) {
263 case "apps": return "Apps/RunningApplicationsGrid.qml";
264 default: return "Generic/GenericFilterGrid.qml";
267 default: return "Generic/GenericFilterGrid.qml";
275 bottomMargin: -bottomOverflow
277 sourceItem: categoryView
281 topGapPx: (1 - gap) * positionPx
282 topOpacity: (1 - gap * 1.2)
283 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
284 bottomOverflow: units.gu(20)
285 bottomOpacity: 1 - (gap * 0.8)
287 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
288 property real gap: previewLoader.open ? 1.0 : 0.0
293 easing.type: Easing.InOutQuad
295 if (!previewLoader.open && !running) {
296 previewLoader.onScreen = false
304 target: scopeView.scope
306 previewLoader.previewData = preview
307 previewLoader.open = true
311 PreviewDelegateMapper {
312 id: previewDelegateMapper
316 ignoreUnknownSignals: true
317 target: previewLoader.valid ? previewLoader.item : null
319 previewLoader.open = false
324 objectName: "previewLoader"
326 property var previewData
327 height: effect.bottomGapPx - effect.topGapPx
330 topMargin: effect.topGapPx
334 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
336 property bool open: false
337 property bool onScreen: false
338 property bool valid: item !== null
347 item.previewData = Qt.binding(function() { return previewLoader.previewData })
350 function closePreviewSpinner() {
352 item.showProcessingAction = false;
357 // TODO: Move as InverseMouseArea to DashPreview
359 enabled: previewLoader.onScreen
362 topMargin: effect.bottomGapPx
365 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