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()
56 model: scopeView.categories
57 forceNoClip: previewLoader.onScreen
59 onAtYEndChanged: if (atYEnd) endReached()
60 onMovingChanged: if (moving && atYEnd) endReached()
62 property int expandedIndex: -1
64 delegate: ListItems.Base {
65 highlightWhenPressed: false
67 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
68 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
78 source: getRenderer(model.renderer, model.contentType)
81 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
82 // TODO: the running apps grid doesn't support standard scope results model yet
83 item.firstModel = Qt.binding(function() { return results.firstModel })
84 item.secondModel = Qt.binding(function() { return results.secondModel })
86 item.model = Qt.binding(function() { return results })
88 item.objectName = Qt.binding(function() { return categoryId })
89 if (item.expandable) {
90 var shouldFilter = index != categoryView.expandedIndex;
91 if (shouldFilter != item.filter) {
92 item.filter = shouldFilter;
98 target: rendererLoader.item
100 effect.positionPx = mapToItem(categoryView, 0, itemY).y
101 scopeView.scope.activate(delegateItem.model.uri,
102 delegateItem.model.icon,
103 delegateItem.model.category,
105 delegateItem.model.mimetype,
106 delegateItem.model.title,
107 delegateItem.model.comment,
108 delegateItem.model.dndUri,
109 delegateItem.model.metadata)
112 effect.positionPx = mapToItem(categoryView, 0, itemY).y
113 scopeView.scope.preview( delegateItem.model.uri,
114 delegateItem.model.icon,
115 delegateItem.model.category,
117 delegateItem.model.mimetype,
118 delegateItem.model.title,
119 delegateItem.model.comment,
120 delegateItem.model.dndUri,
121 delegateItem.model.metadata)
126 onExpandedIndexChanged: {
127 var item = rendererLoader.item;
128 if (item.expandable) {
129 var shouldFilter = index != categoryView.expandedIndex;
130 if (shouldFilter != item.filter) {
131 // If the filter animation will be seen start it, otherwise, just flip the switch
132 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
133 var growingVisible = !shouldFilter && y + height < categoryView.height;
134 if (shrinkingVisible || growingVisible) {
135 item.startFilterAnimation(shouldFilter)
137 item.filter = shouldFilter;
140 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
149 sectionProperty: "name"
150 sectionDelegate: ListItems.Header {
151 property var delegate: categoryView.item(delegateIndex)
152 width: categoryView.width
155 if (delegate && delegate.expandable)
156 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
160 if (categoryView.expandedIndex != delegateIndex)
161 categoryView.expandedIndex = delegateIndex;
163 categoryView.expandedIndex = -1;
166 pageHeader: PageHeader {
168 objectName: "pageHeader"
169 width: categoryView.width
170 text: scopeView.scope.name
171 searchEntryEnabled: true
175 function getDefaultRendererId(contentType) {
176 switch (contentType) {
177 default: return "grid";
181 function getRenderer(rendererId, contentType) {
182 if (rendererId == "default") {
183 rendererId = getDefaultRendererId(contentType);
185 switch (rendererId) {
187 switch (contentType) {
188 case "video": return "Generic/GenericFilterGridPotrait.qml";
189 case "music": return "Music/MusicFilterGrid.qml";
190 default: return "Generic/GenericFilterGrid.qml";
193 case "carousel": return "Generic/GenericCarousel.qml";
195 switch (contentType) {
196 case "apps": return "Apps/RunningApplicationsGrid.qml";
197 default: return "Generic/GenericFilterGrid.qml";
200 default: return "Generic/GenericFilterGrid.qml";
208 bottomMargin: -bottomOverflow
210 sourceItem: categoryView
214 topGapPx: (1 - gap) * positionPx
215 topOpacity: (1 - gap * 1.2)
216 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
217 bottomOverflow: units.gu(20)
218 bottomOpacity: 1 - (gap * 0.8)
220 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
221 property real gap: previewLoader.open ? 1.0 : 0.0
226 easing.type: Easing.InOutQuad
228 if (!previewLoader.open && !running) {
229 previewLoader.onScreen = false
237 target: scopeView.scope
239 previewLoader.previewData = preview
240 previewLoader.open = true
244 PreviewDelegateMapper {
245 id: previewDelegateMapper
249 ignoreUnknownSignals: true
250 target: previewLoader.valid ? previewLoader.item : null
252 previewLoader.open = false
257 objectName: "previewLoader"
259 property var previewData
260 height: effect.bottomGapPx - effect.topGapPx
263 topMargin: effect.topGapPx
267 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
269 property bool open: false
270 property bool onScreen: false
271 property bool valid: item !== null
280 item.previewData = Qt.binding(function() { return previewLoader.previewData })
284 // TODO: Move as InverseMouseArea to DashPreview
286 enabled: previewLoader.onScreen
289 topMargin: effect.bottomGapPx
292 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