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
28 pageHeader.resetSearch();
29 previewLoader.open = false;
32 onMovementStarted: categoryView.showHeader()
34 onPositionedAtBeginning: categoryView.positionAtBeginning()
37 target: scopeView.scope
38 property: "searchQuery"
39 value: pageHeader.searchQuery
44 property: "searchQuery"
45 value: scopeView.scope.searchQuery
50 onSearchClicked: if (isCurrent) {
51 pageHeader.triggerSearch()
52 categoryView.showHeader()
57 target: scopeView.scope
58 onShowDash: previewLoader.open = false;
59 onHideDash: previewLoader.open = false;
64 objectName: "categoryListView"
66 model: scopeView.categories
67 forceNoClip: previewLoader.onScreen
69 onAtYEndChanged: if (atYEnd) endReached()
70 onMovingChanged: if (moving && atYEnd) endReached()
72 property string expandedCategoryId: ""
74 delegate: ListItems.Base {
75 highlightWhenPressed: false
77 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
78 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
79 readonly property string category: categoryId
89 source: getRenderer(model.renderer, model.contentType, model.rendererHint)
92 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
93 item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
94 scopeView.enableHeightBehaviorOnNextCreation = false;
96 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
97 // TODO: the running apps grid doesn't support standard scope results model yet
98 item.firstModel = Qt.binding(function() { return results.firstModel })
99 item.secondModel = Qt.binding(function() { return results.secondModel })
101 item.model = Qt.binding(function() { return results })
103 item.objectName = Qt.binding(function() { return categoryId })
104 if (item.expandable) {
105 var shouldFilter = categoryId != categoryView.expandedCategoryId;
106 if (shouldFilter != item.filter) {
107 item.filter = shouldFilter;
112 Component.onDestruction: {
113 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
114 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
119 target: rendererLoader.item
121 effect.positionPx = mapToItem(categoryView, 0, itemY).y
122 scopeView.scope.activate(delegateItem.model.uri,
123 delegateItem.model.icon,
124 delegateItem.model.category,
126 delegateItem.model.mimetype,
127 delegateItem.model.title,
128 delegateItem.model.comment,
129 delegateItem.model.dndUri,
130 delegateItem.model.metadata)
133 effect.positionPx = mapToItem(categoryView, 0, itemY).y
134 scopeView.scope.preview( delegateItem.model.uri,
135 delegateItem.model.icon,
136 delegateItem.model.category,
138 delegateItem.model.mimetype,
139 delegateItem.model.title,
140 delegateItem.model.comment,
141 delegateItem.model.dndUri,
142 delegateItem.model.metadata)
147 onExpandedCategoryIdChanged: {
148 var item = rendererLoader.item;
149 if (item.expandable) {
150 var shouldFilter = categoryId != categoryView.expandedCategoryId;
151 if (shouldFilter != item.filter) {
152 // If the filter animation will be seen start it, otherwise, just flip the switch
153 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
154 var growingVisible = !shouldFilter && y + height < categoryView.height;
155 if (shrinkingVisible || growingVisible) {
156 item.startFilterAnimation(shouldFilter)
158 item.filter = shouldFilter;
161 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
170 sectionProperty: "name"
171 sectionDelegate: ListItems.Header {
172 property var delegate: categoryView.item(delegateIndex)
173 width: categoryView.width
176 if (delegate && delegate.expandable)
177 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
181 if (categoryView.expandedCategoryId != delegate.category)
182 categoryView.expandedCategoryId = delegate.category;
184 categoryView.expandedCategoryId = "";
187 pageHeader: PageHeader {
189 objectName: "pageHeader"
190 width: categoryView.width
191 text: scopeView.scope.name
192 searchEntryEnabled: true
193 scope: scopeView.scope
197 function getDefaultRendererId(contentType) {
198 switch (contentType) {
199 default: return "grid";
203 function getRenderer(rendererId, contentType, rendererHint) {
204 if (rendererId == "default") {
205 rendererId = getDefaultRendererId(contentType);
207 switch (rendererId) {
209 switch (contentType) {
210 case "video": return "Generic/GenericFilterGridPotrait.qml";
211 case "music": return "Music/MusicFilterGrid.qml";
213 if (rendererHint == "toggled")
214 return "Apps/DashPluginFilterGrid.qml";
216 return "Generic/GenericFilterGrid.qml";
218 case "weather": return "Generic/WeatherFilterGrid.qml";
219 default: return "Generic/GenericFilterGrid.qml";
223 switch (contentType) {
224 case "music": return "Music/MusicCarousel.qml";
225 default: return "Generic/GenericCarousel.qml";
229 switch (contentType) {
230 case "apps": return "Apps/RunningApplicationsGrid.qml";
231 default: return "Generic/GenericFilterGrid.qml";
234 default: return "Generic/GenericFilterGrid.qml";
242 bottomMargin: -bottomOverflow
244 sourceItem: categoryView
248 topGapPx: (1 - gap) * positionPx
249 topOpacity: (1 - gap * 1.2)
250 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
251 bottomOverflow: units.gu(20)
252 bottomOpacity: 1 - (gap * 0.8)
254 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
255 property real gap: previewLoader.open ? 1.0 : 0.0
260 easing.type: Easing.InOutQuad
262 if (!previewLoader.open && !running) {
263 previewLoader.onScreen = false
271 target: scopeView.scope
273 previewLoader.previewData = preview
274 previewLoader.open = true
278 PreviewDelegateMapper {
279 id: previewDelegateMapper
283 ignoreUnknownSignals: true
284 target: previewLoader.valid ? previewLoader.item : null
286 previewLoader.open = false
291 objectName: "previewLoader"
293 property var previewData
294 height: effect.bottomGapPx - effect.topGapPx
297 topMargin: effect.topGapPx
301 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
303 property bool open: false
304 property bool onScreen: false
305 property bool valid: item !== null
314 item.previewData = Qt.binding(function() { return previewLoader.previewData })
318 // TODO: Move as InverseMouseArea to DashPreview
320 enabled: previewLoader.onScreen
323 topMargin: effect.bottomGapPx
326 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