on xenial help sign in
Fix fetching data from mock scopes.
commit16aaf3fbfa7ee5051d2ae435efc0d5a9e33bd42c authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 9 Jul 2013, 13:20 (13 years ago) parent42848ee
2 files changed+32−39
Dash/DashApps.qml+11−8 Dash/DashHome.qml+21−31
Dash/DashApps.qml+11−8
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Unity 0.1
1920import Utils 0.1
2021import "../Components"
2122import "../Components/ListItems"
@@ -81,17 +82,19 @@ ScopeView {
8182 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
8283
8384 // 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
85+ property var installedModel: null
86+
87+ Repeater {
88+ model: scopeView.scope.categories
89+
90+ delegate: Item {
91+ Component.onCompleted: if (index == 3) scopeView.installedModel = Qt.binding(function() { return model.results; });
92+ }
9093 }
9194
9295 property var categoryModels: {
9396 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
94− "InstalledApplicationsModel": installedFilter,
97+ "InstalledApplicationsModel": installedModel,
9598 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
9699 }
97100
@@ -134,7 +137,7 @@ ScopeView {
134137 shell.activateApplication(data);
135138 }
136139
137− item.model = categoryModels[modelName]
140+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
138141 item.clicked.connect(activateApplication);
139142
140143 }
Dash/DashHome.qml+21−31
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Unity 0.1
1920import Utils 0.1
2021import "../Components"
2122import "../Components/ListItems"
@@ -52,42 +53,33 @@ ScopeView {
5253 FrequentlyUsedAppsModel { id: appsModel }
5354
5455 // 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− }
56+ property var musicModel: null
57+ property var videosModel: null
6158
62− SortFilterProxyModel {
63− id: recentFilter
64− dynamicSortFilter: true
65− filterRole: 2
66− filterRegExp: /^2$/
67− }
59+ Repeater {
60+ id: musicRepeater
6861
69− SortFilterProxyModel {
70− id: musicFilter
71− dynamicSortFilter: true
72− filterRole: 2
73− filterRegExp: /^1$/
62+ delegate: Item {
63+ Component.onCompleted: if (index == 1) musicModel = Qt.binding(function() { return model.results; });
64+ }
7465 }
7566
76− SortFilterProxyModel {
77− id: videosFilter
78− dynamicSortFilter: true
79− filterRole: 2
80− filterRegExp: /^3$/
67+ Repeater {
68+ id: videosRepeater
69+
70+ delegate: Item {
71+ Component.onCompleted: if (index == 3) videosModel = Qt.binding(function() { return model.results; });
72+ }
8173 }
8274
8375 Component.onCompleted: {
8476 var scope = dashContent.scopes.get("mockmusicmaster.scope")
8577 if (scope) {
86− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
78+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
8779 }
8880 scope = dashContent.scopes.get("mockvideosmaster.scope")
8981 if (scope) {
90− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
82+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
9183 }
9284 }
9385
@@ -95,19 +87,17 @@ ScopeView {
9587 target: dashContent
9688 onScopeLoaded: switch (scopeId) {
9789 case "mockmusicmaster.scope":
98− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
90+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
9991 break;
10092 case "mockvideosmaster.scope":
101− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
93+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
10294 break;
10395 }
10496 }
10597
10698 property var categoryModels: {"AppsModel": appsModel,
107− "FavouriteModel": favouritesFilter,
108− "RecentModel": recentFilter,
109− "MusicModel": musicFilter,
110− "VideosModel": videosFilter,
99+ "MusicModel": musicModel,
100+ "VideosModel": videosModel,
111101 }
112102
113103 ScopeListView {
@@ -127,7 +117,7 @@ ScopeView {
127117 anchors { top: parent.top; left: parent.left; right: parent.right }
128118 source: component
129119 onLoaded: {
130− item.model = categoryModels[modelName]
120+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
131121
132122 //FIXME: workaround for lack of previews for videos in Home scope.
133123 //Need to connect to the clicked() signal here and act upon it here instead.