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 onSearchClicked: if (isCurrent) {
42 pageHeader.triggerSearch()
43 categoryView.showHeader()
50 model: scopeView.categories
51 forceNoClip: previewLoader.onScreen
53 onAtYEndChanged: if (atYEnd) endReached()
54 onMovingChanged: if (moving && atYEnd) endReached()
56 property int expandedIndex: -1
58 delegate: ListItems.Base {
59 highlightWhenPressed: false
61 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
62 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
72 source: getRenderer(model.renderer, model.contentType)
75 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
76 // TODO: the running apps grid doesn't support standard scope results model yet
77 item.firstModel = Qt.binding(function() { return results.firstModel })
78 item.secondModel = Qt.binding(function() { return results.secondModel })
80 item.model = Qt.binding(function() { return results })
82 item.objectName = Qt.binding(function() { return categoryId })
83 if (item.expandable) {
84 var shouldFilter = index != categoryView.expandedIndex;
85 if (shouldFilter != item.filter) {
86 item.filter = shouldFilter;
92 target: rendererLoader.item
94 effect.positionPx = mapToItem(categoryView, 0, itemY).y
95 scopeView.scope.activate(delegateItem.model.uri,
96 delegateItem.model.icon,
97 delegateItem.model.category,
99 delegateItem.model.mimetype,
100 delegateItem.model.title,
101 delegateItem.model.comment,
102 delegateItem.model.dndUri,
103 delegateItem.model.metadata)
106 effect.positionPx = mapToItem(categoryView, 0, itemY).y
107 scopeView.scope.preview( delegateItem.model.uri,
108 delegateItem.model.icon,
109 delegateItem.model.category,
111 delegateItem.model.mimetype,
112 delegateItem.model.title,
113 delegateItem.model.comment,
114 delegateItem.model.dndUri,
115 delegateItem.model.metadata)
120 onExpandedIndexChanged: {
121 var item = rendererLoader.item;
122 if (item.expandable) {
123 var shouldFilter = index != categoryView.expandedIndex;
124 if (shouldFilter != item.filter) {
125 // If the filter animation will be seen start it, otherwise, just flip the switch
126 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
127 var growingVisible = !shouldFilter && y + height < categoryView.height;
128 if (shrinkingVisible || growingVisible) {
129 item.startFilterAnimation(shouldFilter)
131 item.filter = shouldFilter;
134 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
143 sectionProperty: "name"
144 sectionDelegate: ListItems.Header {
145 property var delegate: categoryView.item(delegateIndex)
146 width: categoryView.width
149 if (delegate && delegate.expandable)
150 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
154 if (categoryView.expandedIndex != delegateIndex)
155 categoryView.expandedIndex = delegateIndex;
157 categoryView.expandedIndex = -1;
160 pageHeader: PageHeader {
162 objectName: "pageHeader"
163 width: categoryView.width
164 text: scopeView.scope.name
165 searchEntryEnabled: true
169 function getDefaultRendererId(contentType) {
170 switch (contentType) {
171 default: return "grid";
175 function getRenderer(rendererId, contentType) {
176 if (rendererId == "default") {
177 rendererId = getDefaultRendererId(contentType);
179 switch (rendererId) {
181 switch (contentType) {
182 case "video": return "Generic/GenericFilterGridPotrait.qml";
183 case "music": return "Music/MusicFilterGrid.qml";
184 default: return "Generic/GenericFilterGrid.qml";
187 case "carousel": return "Generic/GenericCarousel.qml";
189 switch (contentType) {
190 case "apps": return "Apps/RunningApplicationsGrid.qml";
191 default: return "Generic/GenericFilterGrid.qml";
194 default: return "Generic/GenericFilterGrid.qml";
202 bottomMargin: -bottomOverflow
204 sourceItem: categoryView
208 topGapPx: (1 - gap) * positionPx
209 topOpacity: (1 - gap * 1.2)
210 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
211 bottomOverflow: units.gu(20)
212 bottomOpacity: 1 - (gap * 0.8)
214 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
215 property real gap: previewLoader.open ? 1.0 : 0.0
220 easing.type: Easing.InOutQuad
222 if (!previewLoader.open && !running) {
223 previewLoader.onScreen = false
231 target: scopeView.scope
233 previewLoader.previewData = preview
234 previewLoader.open = true
238 PreviewDelegateMapper {
239 id: previewDelegateMapper
243 ignoreUnknownSignals: true
244 target: previewLoader.valid ? previewLoader.item : null
246 previewLoader.open = false
251 objectName: "previewLoader"
253 property var previewData
254 height: effect.bottomGapPx - effect.topGapPx
257 topMargin: effect.topGapPx
261 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
263 property bool open: false
264 property bool onScreen: false
265 property bool valid: item !== null
274 item.previewData = Qt.binding(function() { return previewLoader.previewData })
278 // TODO: Move as InverseMouseArea to DashPreview
280 enabled: previewLoader.onScreen
283 topMargin: effect.bottomGapPx
286 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