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
179 scope: scopeView.scope
183 function getDefaultRendererId(contentType) {
184 switch (contentType) {
185 default: return "grid";
189 function getRenderer(rendererId, contentType) {
190 if (rendererId == "default") {
191 rendererId = getDefaultRendererId(contentType);
193 switch (rendererId) {
195 switch (contentType) {
196 case "video": return "Generic/GenericFilterGridPotrait.qml";
197 case "music": return "Music/MusicFilterGrid.qml";
198 default: return "Generic/GenericFilterGrid.qml";
201 case "carousel": return "Generic/GenericCarousel.qml";
203 switch (contentType) {
204 case "apps": return "Apps/RunningApplicationsGrid.qml";
205 default: return "Generic/GenericFilterGrid.qml";
208 default: return "Generic/GenericFilterGrid.qml";
216 bottomMargin: -bottomOverflow
218 sourceItem: categoryView
222 topGapPx: (1 - gap) * positionPx
223 topOpacity: (1 - gap * 1.2)
224 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
225 bottomOverflow: units.gu(20)
226 bottomOpacity: 1 - (gap * 0.8)
228 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
229 property real gap: previewLoader.open ? 1.0 : 0.0
234 easing.type: Easing.InOutQuad
236 if (!previewLoader.open && !running) {
237 previewLoader.onScreen = false
245 target: scopeView.scope
247 previewLoader.previewData = preview
248 previewLoader.open = true
252 PreviewDelegateMapper {
253 id: previewDelegateMapper
257 ignoreUnknownSignals: true
258 target: previewLoader.valid ? previewLoader.item : null
260 previewLoader.open = false
265 objectName: "previewLoader"
267 property var previewData
268 height: effect.bottomGapPx - effect.topGapPx
271 topMargin: effect.topGapPx
275 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
277 property bool open: false
278 property bool onScreen: false
279 property bool valid: item !== null
288 item.previewData = Qt.binding(function() { return previewLoader.previewData })
292 // TODO: Move as InverseMouseArea to DashPreview
294 enabled: previewLoader.onScreen
297 topMargin: effect.bottomGapPx
300 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