on xenial help sign in
Fix fetching data from scopes in the custom scope pages. Fixes: https://bugs.launchpad.net/bugs/1199322.
1165c23Michał Sawicz
Dash/DashApps.qml+10−8
@@ -81,17 +81,19 @@ ScopeView {
81 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
81 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
82
82
83 // FIXME this should not be needed, the backend should handle all that itself
83 // FIXME this should not be needed, the backend should handle all that itself
84− SortFilterProxyModel {
84+ property var installedModel: null
85− id: installedFilter
85+
86− dynamicSortFilter: true
86+ Repeater {
87− filterRole: 2 // this is the category id for each result
87+ model: scopeView.scope.categories
88− filterRegExp: /^3$/ // only proxy items that are category 3 - Installed
88+
89− model: dashContent.scopes.get("applications.scope").results
89+ delegate: Item {
90+ Component.onCompleted: if (index == 3) scopeView.installedModel = Qt.binding(function() { return model.results; });
91+ }
90 }
92 }
91
93
92 property var categoryModels: {
94 property var categoryModels: {
93 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
95 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
94− "InstalledApplicationsModel": installedFilter,
96+ "InstalledApplicationsModel": installedModel,
95 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
97 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
96 }
98 }
97
99
@@ -134,7 +136,7 @@ ScopeView {
134 shell.activateApplication(data);
136 shell.activateApplication(data);
135 }
137 }
136
138
137− item.model = categoryModels[modelName]
139+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
138 item.clicked.connect(activateApplication);
140 item.clicked.connect(activateApplication);
139
141
140 }
142 }
Dash/DashHome.qml+20−31
@@ -52,42 +52,33 @@ ScopeView {
52 FrequentlyUsedAppsModel { id: appsModel }
52 FrequentlyUsedAppsModel { id: appsModel }
53
53
54 // FIXME this should be handled by the backends by populating the global search model
54 // FIXME this should be handled by the backends by populating the global search model
55− SortFilterProxyModel {
55+ property var musicModel: null
56− id: favouritesFilter
56+ property var videosModel: null
57− dynamicSortFilter: true
58− filterRole: 2
59− filterRegExp: /^0$/
60− }
61
57
62− SortFilterProxyModel {
58+ Repeater {
63− id: recentFilter
59+ id: musicRepeater
64− dynamicSortFilter: true
65− filterRole: 2
66− filterRegExp: /^2$/
67− }
68
60
69− SortFilterProxyModel {
61+ delegate: Item {
70− id: musicFilter
62+ Component.onCompleted: if (index == 1) musicModel = Qt.binding(function() { return model.results; });
71− dynamicSortFilter: true
63+ }
72− filterRole: 2
73− filterRegExp: /^1$/
74 }
64 }
75
65
76− SortFilterProxyModel {
66+ Repeater {
77− id: videosFilter
67+ id: videosRepeater
78− dynamicSortFilter: true
68+
79− filterRole: 2
69+ delegate: Item {
80− filterRegExp: /^3$/
70+ Component.onCompleted: if (index == 3) videosModel = Qt.binding(function() { return model.results; });
71+ }
81 }
72 }
82
73
83 Component.onCompleted: {
74 Component.onCompleted: {
84 var scope = dashContent.scopes.get("mockmusicmaster.scope")
75 var scope = dashContent.scopes.get("mockmusicmaster.scope")
85 if (scope) {
76 if (scope) {
86− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
77+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
87 }
78 }
88 scope = dashContent.scopes.get("mockvideosmaster.scope")
79 scope = dashContent.scopes.get("mockvideosmaster.scope")
89 if (scope) {
80 if (scope) {
90− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
81+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
91 }
82 }
92 }
83 }
93
84
@@ -95,19 +86,17 @@ ScopeView {
95 target: dashContent
86 target: dashContent
96 onScopeLoaded: switch (scopeId) {
87 onScopeLoaded: switch (scopeId) {
97 case "mockmusicmaster.scope":
88 case "mockmusicmaster.scope":
98− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
89+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
99 break;
90 break;
100 case "mockvideosmaster.scope":
91 case "mockvideosmaster.scope":
101− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
92+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
102 break;
93 break;
103 }
94 }
104 }
95 }
105
96
106 property var categoryModels: {"AppsModel": appsModel,
97 property var categoryModels: {"AppsModel": appsModel,
107− "FavouriteModel": favouritesFilter,
108− "RecentModel": recentFilter,
109− "MusicModel": musicFilter,
98+ "MusicModel": musicModel,
110− "VideosModel": videosFilter,
99+ "VideosModel": videosModel,
111 }
100 }
112
101
113 ScopeListView {
102 ScopeListView {
@@ -127,7 +116,7 @@ ScopeView {
127 anchors { top: parent.top; left: parent.left; right: parent.right }
116 anchors { top: parent.top; left: parent.left; right: parent.right }
128 source: component
117 source: component
129 onLoaded: {
118 onLoaded: {
130− item.model = categoryModels[modelName]
119+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
131
120
132 //FIXME: workaround for lack of previews for videos in Home scope.
121 //FIXME: workaround for lack of previews for videos in Home scope.
133 //Need to connect to the clicked() signal here and act upon it here instead.
122 //Need to connect to the clicked() signal here and act upon it here instead.