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 })
100 item.canEnableTerminationMode = Qt.binding(function() { return scopeView.isCurrent })
102 item.model = Qt.binding(function() { return results })
104 item.objectName = Qt.binding(function() { return categoryId })
105 if (item.expandable) {
106 var shouldFilter = categoryId != categoryView.expandedCategoryId;
107 if (shouldFilter != item.filter) {
108 item.filter = shouldFilter;
113 Component.onDestruction: {
114 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
115 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
120 target: rendererLoader.item
122 effect.positionPx = mapToItem(categoryView, 0, itemY).y
123 scopeView.scope.activate(delegateItem.model.uri,
124 delegateItem.model.icon,
125 delegateItem.model.category,
127 delegateItem.model.mimetype,
128 delegateItem.model.title,
129 delegateItem.model.comment,
130 delegateItem.model.dndUri,
131 delegateItem.model.metadata)
134 effect.positionPx = mapToItem(categoryView, 0, itemY).y
135 scopeView.scope.preview( delegateItem.model.uri,
136 delegateItem.model.icon,
137 delegateItem.model.category,
139 delegateItem.model.mimetype,
140 delegateItem.model.title,
141 delegateItem.model.comment,
142 delegateItem.model.dndUri,
143 delegateItem.model.metadata)
148 onExpandedCategoryIdChanged: {
149 var item = rendererLoader.item;
150 if (item.expandable) {
151 var shouldFilter = categoryId != categoryView.expandedCategoryId;
152 if (shouldFilter != item.filter) {
153 // If the filter animation will be seen start it, otherwise, just flip the switch
154 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
155 var growingVisible = !shouldFilter && y + height < categoryView.height;
156 if (shrinkingVisible || growingVisible) {
157 item.startFilterAnimation(shouldFilter)
159 item.filter = shouldFilter;
162 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
171 sectionProperty: "name"
172 sectionDelegate: ListItems.Header {
173 property var delegate: categoryView.item(delegateIndex)
174 width: categoryView.width
177 if (delegate && delegate.expandable)
178 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
182 if (categoryView.expandedCategoryId != delegate.category)
183 categoryView.expandedCategoryId = delegate.category;
185 categoryView.expandedCategoryId = "";
188 pageHeader: PageHeader {
190 objectName: "pageHeader"
191 width: categoryView.width
192 text: scopeView.scope.name
193 searchEntryEnabled: true
194 scope: scopeView.scope
198 function getDefaultRendererId(contentType) {
199 switch (contentType) {
200 default: return "grid";
204 function getRenderer(rendererId, contentType, rendererHint) {
205 if (rendererId == "default") {
206 rendererId = getDefaultRendererId(contentType);
208 switch (rendererId) {
210 switch (contentType) {
211 case "video": return "Generic/GenericFilterGridPotrait.qml";
212 case "music": return "Music/MusicFilterGrid.qml";
213 default: return "Generic/GenericFilterGrid.qml";
217 switch (contentType) {
218 case "music": return "Music/MusicCarousel.qml";
219 default: return "Generic/GenericCarousel.qml";
223 switch (contentType) {
224 case "apps": return "Apps/RunningApplicationsGrid.qml";
225 default: return "Generic/GenericFilterGrid.qml";
228 default: return "Generic/GenericFilterGrid.qml";
236 bottomMargin: -bottomOverflow
238 sourceItem: categoryView
242 topGapPx: (1 - gap) * positionPx
243 topOpacity: (1 - gap * 1.2)
244 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
245 bottomOverflow: units.gu(20)
246 bottomOpacity: 1 - (gap * 0.8)
248 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
249 property real gap: previewLoader.open ? 1.0 : 0.0
254 easing.type: Easing.InOutQuad
256 if (!previewLoader.open && !running) {
257 previewLoader.onScreen = false
265 target: scopeView.scope
267 previewLoader.previewData = preview
268 previewLoader.open = true
272 PreviewDelegateMapper {
273 id: previewDelegateMapper
277 ignoreUnknownSignals: true
278 target: previewLoader.valid ? previewLoader.item : null
280 previewLoader.open = false
285 objectName: "previewLoader"
287 property var previewData
288 height: effect.bottomGapPx - effect.topGapPx
291 topMargin: effect.topGapPx
295 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
297 property bool open: false
298 property bool onScreen: false
299 property bool valid: item !== null
308 item.previewData = Qt.binding(function() { return previewLoader.previewData })
312 // TODO: Move as InverseMouseArea to DashPreview
314 enabled: previewLoader.onScreen
317 topMargin: effect.bottomGapPx
320 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