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
21import "../Components/IconUtil.js" as IconUtil
25 property alias previewShown: previewLoader.onScreen
28 pageHeader.resetSearch();
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 = results.firstModel
78 item.secondModel = results.secondModel
82 item.objectName = 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 default: return "Generic/GenericFilterGrid.qml";
186 case "carousel": return "Generic/GenericCarousel.qml";
188 switch (contentType) {
189 case "apps": return "Apps/RunningApplicationsGrid.qml";
190 default: return "Generic/GenericFilterGrid.qml";
193 default: return "Generic/GenericFilterGrid.qml";
201 bottomMargin: -bottomOverflow
203 sourceItem: categoryView
207 topGapPx: (1 - gap) * positionPx
208 topOpacity: (1 - gap * 1.2)
209 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
210 bottomOverflow: units.gu(20)
211 bottomOpacity: 1 - (gap * 0.8)
213 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
214 property real gap: previewLoader.open ? 1.0 : 0.0
219 easing.type: Easing.InOutQuad
221 if (!previewLoader.open && !running) {
222 previewLoader.onScreen = false
230 target: scopeView.scope
232 previewLoader.previewData = preview
233 previewLoader.open = true
237 PreviewDelegateMapper {
238 id: previewDelegateMapper
242 ignoreUnknownSignals: true
243 target: previewLoader.valid ? previewLoader.item : null
245 previewLoader.open = false
251 property var previewData
252 height: effect.bottomGapPx - effect.topGapPx
255 topMargin: effect.topGapPx
259 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
261 property bool open: false
262 property bool onScreen: false
263 property bool valid: item !== null
272 item.previewData = Qt.binding(function() { return previewLoader.previewData })
276 // TODO: Move as InverseMouseArea to DashPreview
278 enabled: previewLoader.onScreen
281 topMargin: effect.bottomGapPx
284 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