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