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
25 property bool enableHeightBehaviorOnNextCreation: false
28 pageHeader.resetSearch();
29 previewLoader.open = false;
32 onMovementStarted: categoryView.showHeader()
34 onPositionedAtBeginning: categoryView.positionAtBeginning()
37 target: scopeView.scope
38 property: "searchQuery"
39 value: pageHeader.searchQuery
44 property: "searchQuery"
45 value: scopeView.scope.searchQuery
50 onSearchClicked: if (isCurrent) {
51 pageHeader.triggerSearch()
52 categoryView.showHeader()
57 target: scopeView.scope
58 onShowDash: previewLoader.open = false;
59 onHideDash: previewLoader.open = false;
64 objectName: "categoryListView"
66 model: scopeView.categories
67 forceNoClip: previewLoader.onScreen
69 onAtYEndChanged: if (atYEnd) endReached()
70 onMovingChanged: if (moving && atYEnd) endReached()
72 property string expandedCategoryId: ""
74 delegate: ListItems.Base {
76 highlightWhenPressed: false
78 readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
79 readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
80 readonly property string category: categoryId
90 source: getRenderer(model.renderer, model.contentType, model.rendererHint)
93 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
94 item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
95 scopeView.enableHeightBehaviorOnNextCreation = false;
97 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
98 // TODO: the running apps grid doesn't support standard scope results model yet
99 item.firstModel = Qt.binding(function() { return results.firstModel })
100 item.secondModel = Qt.binding(function() { return results.secondModel })
101 item.canEnableTerminationMode = Qt.binding(function() { return scopeView.isCurrent })
103 item.model = Qt.binding(function() { return results })
105 item.objectName = Qt.binding(function() { return categoryId })
106 if (item.expandable) {
107 var shouldFilter = categoryId != categoryView.expandedCategoryId;
108 if (shouldFilter != item.filter) {
109 item.filter = shouldFilter;
112 updateDelegateCreationRange();
115 Component.onDestruction: {
116 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
117 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
122 target: rendererLoader.item
124 effect.positionPx = mapToItem(categoryView, 0, itemY).y
125 scopeView.scope.activate(delegateItem.model.uri,
126 delegateItem.model.icon,
127 delegateItem.model.category,
129 delegateItem.model.mimetype,
130 delegateItem.model.title,
131 delegateItem.model.comment,
132 delegateItem.model.dndUri,
133 delegateItem.model.metadata)
136 effect.positionPx = mapToItem(categoryView, 0, itemY).y
137 scopeView.scope.preview( delegateItem.model.uri,
138 delegateItem.model.icon,
139 delegateItem.model.category,
141 delegateItem.model.mimetype,
142 delegateItem.model.title,
143 delegateItem.model.comment,
144 delegateItem.model.dndUri,
145 delegateItem.model.metadata)
150 onExpandedCategoryIdChanged: {
151 var item = rendererLoader.item;
152 if (item.expandable) {
153 var shouldFilter = categoryId != categoryView.expandedCategoryId;
154 if (shouldFilter != item.filter) {
155 // If the filter animation will be seen start it, otherwise, just flip the switch
156 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
157 var growingVisible = !shouldFilter && y + height < categoryView.height;
158 if (shrinkingVisible || growingVisible) {
159 item.startFilterAnimation(shouldFilter)
161 item.filter = shouldFilter;
164 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
169 onContentYChanged: rendererLoader.updateDelegateCreationRange();
170 onHeightChanged: rendererLoader.updateDelegateCreationRange();
173 function updateDelegateCreationRange() {
174 // Do not update the range if we are overshooting up or down, since we'll come back
175 // to the stable position and delete/create items without any reason
176 if (categoryView.contentY < categoryView.originY) {
178 } else if (categoryView.contentY + categoryView.height > categoryView.contentHeight) {
182 if (item.hasOwnProperty("delegateCreationBegin")) {
183 if (baseItem.y + baseItem.height <= 0) {
184 // Not visible (item at top of the list)
185 item.delegateCreationBegin = baseItem.height
186 item.delegateCreationEnd = baseItem.height
187 } else if (baseItem.y >= categoryView.height) {
188 // Not visible (item at bottom of the list)
189 item.delegateCreationBegin = 0
190 item.delegateCreationEnd = 0
192 item.delegateCreationBegin = Math.max(-baseItem.y, 0)
193 item.delegateCreationEnd = Math.min(categoryView.height + item.delegateCreationBegin, baseItem.height)
200 sectionProperty: "name"
201 sectionDelegate: ListItems.Header {
202 property var delegate: categoryView.item(delegateIndex)
203 width: categoryView.width
206 if (delegate && delegate.expandable)
207 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
211 if (categoryView.expandedCategoryId != delegate.category)
212 categoryView.expandedCategoryId = delegate.category;
214 categoryView.expandedCategoryId = "";
217 pageHeader: PageHeader {
219 objectName: "pageHeader"
220 width: categoryView.width
221 text: scopeView.scope.name
222 searchEntryEnabled: true
223 scope: scopeView.scope
227 function getDefaultRendererId(contentType) {
228 switch (contentType) {
229 default: return "grid";
233 function getRenderer(rendererId, contentType, rendererHint) {
234 if (rendererId == "default") {
235 rendererId = getDefaultRendererId(contentType);
237 switch (rendererId) {
239 switch (contentType) {
240 case "video": return "Generic/GenericFilterGridPotrait.qml";
241 case "music": return "Music/MusicFilterGrid.qml";
242 default: return "Generic/GenericFilterGrid.qml";
246 switch (contentType) {
247 case "music": return "Music/MusicCarousel.qml";
248 default: return "Generic/GenericCarousel.qml";
252 switch (contentType) {
253 case "apps": return "Apps/RunningApplicationsGrid.qml";
254 default: return "Generic/GenericFilterGrid.qml";
257 default: return "Generic/GenericFilterGrid.qml";
265 bottomMargin: -bottomOverflow
267 sourceItem: categoryView
271 topGapPx: (1 - gap) * positionPx
272 topOpacity: (1 - gap * 1.2)
273 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
274 bottomOverflow: units.gu(20)
275 bottomOpacity: 1 - (gap * 0.8)
277 property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
278 property real gap: previewLoader.open ? 1.0 : 0.0
283 easing.type: Easing.InOutQuad
285 if (!previewLoader.open && !running) {
286 previewLoader.onScreen = false
294 target: scopeView.scope
296 previewLoader.previewData = preview
297 previewLoader.open = true
301 PreviewDelegateMapper {
302 id: previewDelegateMapper
306 ignoreUnknownSignals: true
307 target: previewLoader.valid ? previewLoader.item : null
309 previewLoader.open = false
314 objectName: "previewLoader"
316 property var previewData
317 height: effect.bottomGapPx - effect.topGapPx
320 topMargin: effect.topGapPx
324 source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
326 property bool open: false
327 property bool onScreen: false
328 property bool valid: item !== null
337 item.previewData = Qt.binding(function() { return previewLoader.previewData })
341 // TODO: Move as InverseMouseArea to DashPreview
343 enabled: previewLoader.onScreen
346 topMargin: effect.bottomGapPx
349 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