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 property alias previewShown: previewLoader.onScreen
27 pageHeader.resetSearch();
30 onMovementStarted: categoryView.showHeader()
33 target: scopeView.scope
34 property: "searchQuery"
35 value: pageHeader.searchQuery
40 onSearchClicked: if (isCurrent) {
41 pageHeader.triggerSearch()
42 categoryView.showHeader()
49 model: scopeView.categories
50 forceNoClip: previewLoader.onScreen
52 onAtYEndChanged: if (atYEnd) endReached()
53 onMovingChanged: if (moving && atYEnd) endReached()
55 property int expandedIndex: -1
57 delegate: ListItems.Base {
58 highlightWhenPressed: false
60 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
61 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
71 source: getRenderer(model.renderer, model.contentType)
74 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
75 // TODO: the running apps grid doesn't support standard scope results model yet
76 item.firstModel = Qt.binding(function() { return results.firstModel })
77 item.secondModel = Qt.binding(function() { return results.secondModel })
79 item.model = Qt.binding(function() { return results })
81 item.objectName = Qt.binding(function() { return categoryId })
82 if (item.expandable) {
83 var shouldFilter = index != categoryView.expandedIndex;
84 if (shouldFilter != item.filter) {
85 item.filter = shouldFilter;
91 target: rendererLoader.item
93 effect.positionPx = mapToItem(categoryView, 0, itemY).y
94 scopeView.scope.activate(delegateItem.model.uri,
95 delegateItem.model.icon,
96 delegateItem.model.category,
98 delegateItem.model.mimetype,
99 delegateItem.model.title,
100 delegateItem.model.comment,
101 delegateItem.model.dndUri,
102 delegateItem.model.metadata)
105 effect.positionPx = mapToItem(categoryView, 0, itemY).y
106 scopeView.scope.preview( delegateItem.model.uri,
107 delegateItem.model.icon,
108 delegateItem.model.category,
110 delegateItem.model.mimetype,
111 delegateItem.model.title,
112 delegateItem.model.comment,
113 delegateItem.model.dndUri,
114 delegateItem.model.metadata)
119 onExpandedIndexChanged: {
120 var item = rendererLoader.item;
121 if (item.expandable) {
122 var shouldFilter = index != categoryView.expandedIndex;
123 if (shouldFilter != item.filter) {
124 // If the filter animation will be seen start it, otherwise, just flip the switch
125 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
126 var growingVisible = !shouldFilter && y + height < categoryView.height;
127 if (shrinkingVisible || growingVisible) {
128 item.startFilterAnimation(shouldFilter)
130 item.filter = shouldFilter;
133 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
142 sectionProperty: "name"
143 sectionDelegate: ListItems.Header {
144 property var delegate: categoryView.item(delegateIndex)
145 width: categoryView.width
148 if (delegate && delegate.expandable)
149 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
153 if (categoryView.expandedIndex != delegateIndex)
154 categoryView.expandedIndex = delegateIndex;
156 categoryView.expandedIndex = -1;
159 pageHeader: PageHeader {
161 objectName: "pageHeader"
162 width: categoryView.width
163 text: scopeView.scope.name
164 searchEntryEnabled: true
168 function getDefaultRendererId(contentType) {
169 switch (contentType) {
170 default: return "grid";
174 function getRenderer(rendererId, contentType) {
175 if (rendererId == "default") {
176 rendererId = getDefaultRendererId(contentType);
178 switch (rendererId) {
180 switch (contentType) {
181 case "video": return "Generic/GenericFilterGridPotrait.qml";
182 default: return "Generic/GenericFilterGrid.qml";
185 case "carousel": return "Generic/GenericCarousel.qml";
187 switch (contentType) {
188 case "apps": return "Apps/RunningApplicationsGrid.qml";
189 default: return "Generic/GenericFilterGrid.qml";
192 default: return "Generic/GenericFilterGrid.qml";
200 bottomMargin: -bottomOverflow
202 sourceItem: categoryView
206 topGapPx: (1 - gap) * positionPx
207 topOpacity: (1 - gap * 1.2)
208 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
209 bottomOverflow: units.gu(20)
210 bottomOpacity: 1 - (gap * 0.8)
212 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
213 property real gap: previewLoader.open ? 1.0 : 0.0
218 easing.type: Easing.InOutQuad
220 if (!previewLoader.open && !running) {
221 previewLoader.onScreen = false
229 target: scopeView.scope
231 previewLoader.previewData = preview
232 previewLoader.open = true
236 PreviewDelegateMapper {
237 id: previewDelegateMapper
241 ignoreUnknownSignals: true
242 target: previewLoader.valid ? previewLoader.item : null
244 previewLoader.open = false
250 property var previewData
251 height: effect.bottomGapPx - effect.topGapPx
254 topMargin: effect.topGapPx
258 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
260 property bool open: false
261 property bool onScreen: false
262 property bool valid: item !== null
271 item.previewData = Qt.binding(function() { return previewLoader.previewData })
275 // TODO: Move as InverseMouseArea to DashPreview
277 enabled: previewLoader.onScreen
280 topMargin: effect.bottomGapPx
283 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