on xenial help sign in
Fix fetching data from scopes in the custom scope pages. Fixes: https://bugs.launchpad.net/bugs/1199322.

Approved by PS Jenkins bot, Michael Zanetti, Michal Hruby.

commit1165c2368f61074982275a10ad5e69a1b83754e2 authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 9 Jul 2013, 23:30 (13 years ago) parentbde28f10f1ebe1
2 files changed+30−39
Dash/DashApps.qml+10−8 Dash/DashHome.qml+20−31
Dash/DashApps.qml+10−8
@@ -81,17 +81,19 @@ ScopeView {
8181 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
8282
8383 // FIXME this should not be needed, the backend should handle all that itself
84− SortFilterProxyModel {
85− id: installedFilter
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
84+ property var installedModel: null
85+
86+ Repeater {
87+ model: scopeView.scope.categories
88+
89+ delegate: Item {
90+ Component.onCompleted: if (index == 3) scopeView.installedModel = Qt.binding(function() { return model.results; });
91+ }
9092 }
9193
9294 property var categoryModels: {
9395 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
94− "InstalledApplicationsModel": installedFilter,
96+ "InstalledApplicationsModel": installedModel,
9597 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
9698 }
9799
@@ -134,7 +136,7 @@ ScopeView {
134136 shell.activateApplication(data);
135137 }
136138
137− item.model = categoryModels[modelName]
139+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
138140 item.clicked.connect(activateApplication);
139141
140142 }
Dash/DashHome.qml+20−31
@@ -52,42 +52,33 @@ ScopeView {
5252 FrequentlyUsedAppsModel { id: appsModel }
5353
5454 // FIXME this should be handled by the backends by populating the global search model
55− SortFilterProxyModel {
56− id: favouritesFilter
57− dynamicSortFilter: true
58− filterRole: 2
59− filterRegExp: /^0$/
60− }
55+ property var musicModel: null
56+ property var videosModel: null
6157
62− SortFilterProxyModel {
63− id: recentFilter
64− dynamicSortFilter: true
65− filterRole: 2
66− filterRegExp: /^2$/
67− }
58+ Repeater {
59+ id: musicRepeater
6860
69− SortFilterProxyModel {
70− id: musicFilter
71− dynamicSortFilter: true
72− filterRole: 2
73− filterRegExp: /^1$/
61+ delegate: Item {
62+ Component.onCompleted: if (index == 1) musicModel = Qt.binding(function() { return model.results; });
63+ }
7464 }
7565
76− SortFilterProxyModel {
77− id: videosFilter
78− dynamicSortFilter: true
79− filterRole: 2
80− filterRegExp: /^3$/
66+ Repeater {
67+ id: videosRepeater
68+
69+ delegate: Item {
70+ Component.onCompleted: if (index == 3) videosModel = Qt.binding(function() { return model.results; });
71+ }
8172 }
8273
8374 Component.onCompleted: {
8475 var scope = dashContent.scopes.get("mockmusicmaster.scope")
8576 if (scope) {
86− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
77+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
8778 }
8879 scope = dashContent.scopes.get("mockvideosmaster.scope")
8980 if (scope) {
90− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
81+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
9182 }
9283 }
9384
@@ -95,19 +86,17 @@ ScopeView {
9586 target: dashContent
9687 onScopeLoaded: switch (scopeId) {
9788 case "mockmusicmaster.scope":
98− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
89+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
9990 break;
10091 case "mockvideosmaster.scope":
101− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
92+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
10293 break;
10394 }
10495 }
10596
10697 property var categoryModels: {"AppsModel": appsModel,
107− "FavouriteModel": favouritesFilter,
108− "RecentModel": recentFilter,
109− "MusicModel": musicFilter,
110− "VideosModel": videosFilter,
98+ "MusicModel": musicModel,
99+ "VideosModel": videosModel,
111100 }
112101
113102 ScopeListView {
@@ -127,7 +116,7 @@ ScopeView {
127116 anchors { top: parent.top; left: parent.left; right: parent.right }
128117 source: component
129118 onLoaded: {
130− item.model = categoryModels[modelName]
119+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
131120
132121 //FIXME: workaround for lack of previews for videos in Home scope.
133122 //Need to connect to the clicked() signal here and act upon it here instead.