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
21import "../Components/ListItems"
27 // FIXME: a way to aggregate these models would be ideal
28 property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
29 property var sideStageApplicationModel: shell.applicationManager.sideStageApplications
31 onMovementStarted: categoryView.showHeader()
32 onPositionedAtBeginning: {
34 categoryView.positionAtBeginning()
39 pageHeader.resetSearch();
43 target: scopeView.scope
44 property: "searchQuery"
45 value: pageHeader.searchQuery
50 onSearchClicked: if (isCurrent) {
51 pageHeader.triggerSearch()
52 categoryView.showHeader()
58 // specifies app categories, type of delegate and model used in each category
59 ListElement { category: "Running apps"; component: "RunningApplicationsGrid"; modelName: "RunningApplicationsModel" }
60 ListElement { category: "Frequently used"; component: "ApplicationsFilterGrid"; modelName: "FrequentlyUsedAppsModel" }
61 ListElement { category: "Installed"; component: "ApplicationsFilterGrid"; modelName: "InstalledApplicationsModel" }
62 ListElement { category: "Available for download"; component: "ApplicationsFilterGrid"; modelName: "AppsAvailableForDownloadModel" }
63 function getCategory(category1) {
64 if (category1 === "Running apps") {
65 return i18n.tr("Running apps");
67 if (category1 === "Frequently used") {
68 return i18n.tr("Frequently used");
70 if (category1 === "Installed") {
71 return i18n.tr("Installed");
73 if (category1 === "Available for download") {
74 return i18n.tr("Available for download");
80 FrequentlyUsedAppsModel { id: frequentlyUsedAppsModel }
81 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
83 // FIXME this should not be needed, the backend should handle all that itself
84 SortFilterProxyModel {
86 dynamicSortFilter: true
87 filterRole: 2 // this is the category id for each result
88 filterRegExp: /^3$/ // only proxy items that are category 3 - Installed
89 model: dashContent.scopes.get("applications.scope").results
92 property var categoryModels: {
93 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
94 "InstalledApplicationsModel": installedFilter,
95 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
98 /* Workaround for bug: https://bugreports.qt-project.org/browse/QTBUG-28403
99 When using Loader to load external QML file in the list deelgate, the ListView has
100 a bug where it can position the delegate content to overlap the section header
101 of the ListView - a workaround is to use sourceComponent of Loader instead */
102 Component { id: runningApplicationsGrid; RunningApplicationsGrid { clip: true } }
104 id: applicationsFilterGrid;
105 ApplicationsFilterGrid {
106 onClicked: shell.activateApplication(data)
110 property var componentModels: {
111 "RunningApplicationsGrid": runningApplicationsGrid,
112 "ApplicationsFilterGrid": applicationsFilterGrid,
118 model: SortFilterProxyModel {
119 model: categoryListModel
120 filterRole: 0 // 0 == modelName
121 // FIXME: need to use invertMatch here, otherwise the filter won't update correctly
122 // if filterRegExp is set before invertMatch. Bug in SortFilterProxyModel?
123 filterRegExp: invertMatch ? ((mainStageApplicationsModel.count === 0
124 && sideStageApplicationModel.count === 0) ? RegExp("RunningApplicationsModel") : RegExp("")) :
125 RegExp("InstalledApplicationsModel")
126 invertMatch: pageHeader.searchQuery.length == 0
129 onAtYEndChanged: if (atYEnd) endReached()
130 onMovingChanged: if (moving && atYEnd) endReached()
134 highlightWhenPressed: false
142 sourceComponent: componentModels[component]
144 if (modelName == "RunningApplicationsModel") {
145 item.firstModel = mainStageApplicationsModel
146 item.secondModel = sideStageApplicationModel
147 item.canEnableTerminationMode =
148 Qt.binding(function() { return isCurrent; })
150 item.model = categoryModels[modelName]
155 ListView.onRemove: SequentialAnimation {
157 target: container; property: "ListView.delayRemove"; value: true
160 target: container; property: "height"; to: 0;
161 duration: 250; easing.type: Easing.InOutQuad
164 target: container; property: "ListView.delayRemove"; value: false
169 sectionProperty: "category"
170 sectionDelegate: Header {
171 width: categoryView.width
172 text: categoryListModel.getCategory(section)
174 pageHeader: PageHeader {
176 width: categoryView.width
177 text: i18n.tr("Apps")
178 searchEntryEnabled: true
179 searchHistory: scopeView.searchHistory
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