on xenial help sign in
Dash renderer signals: No need to pass the model up and down
aec7f63Albert Astals
Components/Carousel.qml+4−6
@@ -54,15 +54,13 @@ Item {
54
54
55 /// Emitted when the user clicked on an item
55 /// Emitted when the user clicked on an item
56 /// @param index is the index of the clicked item
56 /// @param index is the index of the clicked item
57− /// @param model is the model of all the items in the carousel
58 /// @param itemY is y of the clicked delegate
57 /// @param itemY is y of the clicked delegate
59− signal clicked(int index, var model, real itemY)
58+ signal clicked(int index, real itemY)
60
59
61 /// Emitted when the user pressed and held on an item
60 /// Emitted when the user pressed and held on an item
62 /// @param index is the index of the held item
61 /// @param index is the index of the held item
63− /// @param model is the model of all the items in the carousel
64 /// @param itemY is y of the held delegate
62 /// @param itemY is y of the held delegate
65− signal pressAndHold(int index, var model, real itemY)
63+ signal pressAndHold(int index, real itemY)
66
64
67 implicitHeight: listView.tileHeight * selectedItemScaleFactor
65 implicitHeight: listView.tileHeight * selectedItemScaleFactor
68
66
@@ -163,7 +161,7 @@ Item {
163 /* We're clicking the selected item and
161 /* We're clicking the selected item and
164 we're in the neighbourhood of radius 1 pixel from it.
162 we're in the neighbourhood of radius 1 pixel from it.
165 Let's emit the clicked signal. */
163 Let's emit the clicked signal. */
166− carousel.clicked(index, listView.model, delegateItem.y)
164+ carousel.clicked(index, delegateItem.y)
167 return
165 return
168 }
166 }
169
167
@@ -187,7 +185,7 @@ Item {
187 /* We're pressAndHold the selected item and
185 /* We're pressAndHold the selected item and
188 we're in the neighbourhood of radius 1 pixel from it.
186 we're in the neighbourhood of radius 1 pixel from it.
189 Let's emit the pressAndHold signal. */
187 Let's emit the pressAndHold signal. */
190− carousel.pressAndHold(index, listView.model, delegateItem.y);
188+ carousel.pressAndHold(index, delegateItem.y);
191 return;
189 return;
192 }
190 }
193
191
Dash/Apps/ApplicationsFilterGrid.qml+4−4
@@ -28,8 +28,8 @@ FilterGrid {
28 delegateHeight: units.gu(9.5)
28 delegateHeight: units.gu(9.5)
29 verticalSpacing: units.gu(2)
29 verticalSpacing: units.gu(2)
30
30
31− signal clicked(int index, var model, real itemY)
31+ signal clicked(int index, real itemY)
32− signal pressAndHold(int index, var model, real itemY)
32+ signal pressAndHold(int index, real itemY)
33
33
34 delegate: Tile {
34 delegate: Tile {
35 id: tile
35 id: tile
@@ -54,11 +54,11 @@ FilterGrid {
54 source: icon
54 source: icon
55
55
56 onClicked: {
56 onClicked: {
57− filtergrid.clicked(index, filtergrid.model, tile.y)
57+ filtergrid.clicked(index, tile.y)
58 }
58 }
59
59
60 onPressAndHold: {
60 onPressAndHold: {
61− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
61+ filtergrid.pressAndHold(index, tile.y)
62 }
62 }
63 }
63 }
64}
64}
Dash/Apps/DashPluginFilterGrid.qml+2−2
@@ -37,11 +37,11 @@ GenericFilterGrid {
37 }
37 }
38
38
39 onClicked: {
39 onClicked: {
40− filtergrid.clicked(index, filtergrid.model, tile.y)
40+ filtergrid.clicked(index, tile.y)
41 }
41 }
42
42
43 onPressAndHold: {
43 onPressAndHold: {
44− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
44+ filtergrid.pressAndHold(index, tile.y)
45 }
45 }
46 }
46 }
47}
47}
Dash/Generic/GenericFilterGrid.qml+4−4
@@ -28,8 +28,8 @@ FilterGrid {
28 property int iconWidth: units.gu(8)
28 property int iconWidth: units.gu(8)
29 property int iconHeight: units.gu(7.5)
29 property int iconHeight: units.gu(7.5)
30
30
31− signal clicked(int index, var model, real itemY)
31+ signal clicked(int index, real itemY)
32− signal pressAndHold(int index, var model, real itemY)
32+ signal pressAndHold(int index, real itemY)
33
33
34 delegate: Tile {
34 delegate: Tile {
35 id: tile
35 id: tile
@@ -42,11 +42,11 @@ FilterGrid {
42 source: model.icon
42 source: model.icon
43
43
44 onClicked: {
44 onClicked: {
45− filtergrid.clicked(index, filtergrid.model, tile.y)
45+ filtergrid.clicked(index, tile.y)
46 }
46 }
47
47
48 onPressAndHold: {
48 onPressAndHold: {
49− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
49+ filtergrid.pressAndHold(index, tile.y)
50 }
50 }
51 }
51 }
52}
52}
Dash/Generic/WeatherFilterGrid.qml+2−2
@@ -37,11 +37,11 @@ GenericFilterGrid {
37 style: FlatTileStyle {}
37 style: FlatTileStyle {}
38
38
39 onClicked: {
39 onClicked: {
40− filtergrid.clicked(index, filtergrid.model, tile.y)
40+ filtergrid.clicked(index, tile.y)
41 }
41 }
42
42
43 onPressAndHold: {
43 onPressAndHold: {
44− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
44+ filtergrid.pressAndHold(index, tile.y)
45 }
45 }
46 }
46 }
47}
47}
Dash/GenericScopeView.qml+4−4
@@ -133,11 +133,11 @@ ScopeView {
133 effect.positionPx = mapToItem(categoryView, 0, itemY).y
133 effect.positionPx = mapToItem(categoryView, 0, itemY).y
134 previewListView.categoryId = categoryId
134 previewListView.categoryId = categoryId
135 previewListView.categoryDelegate = rendererLoader.item
135 previewListView.categoryDelegate = rendererLoader.item
136− previewListView.model = model;
136+ previewListView.model = target.model;
137 previewListView.init = true;
137 previewListView.init = true;
138 previewListView.currentIndex = index;
138 previewListView.currentIndex = index;
139
139
140− var item = model.get(index);
140+ var item = target.model.get(index);
141
141
142 if ((scopeView.scope.id == "applications.scope" && categoryId == "installed")
142 if ((scopeView.scope.id == "applications.scope" && categoryId == "installed")
143 || (scopeView.scope.id == "home.scope" && categoryId == "applications.scope")) {
143 || (scopeView.scope.id == "home.scope" && categoryId == "applications.scope")) {
@@ -154,12 +154,12 @@ ScopeView {
154 effect.positionPx = mapToItem(categoryView, 0, itemY).y
154 effect.positionPx = mapToItem(categoryView, 0, itemY).y
155 previewListView.categoryId = categoryId
155 previewListView.categoryId = categoryId
156 previewListView.categoryDelegate = rendererLoader.item
156 previewListView.categoryDelegate = rendererLoader.item
157− previewListView.model = model;
157+ previewListView.model = target.model;
158 previewListView.init = true;
158 previewListView.init = true;
159 previewListView.currentIndex = index;
159 previewListView.currentIndex = index;
160 previewListView.open = true
160 previewListView.open = true
161
161
162− var item = model.get(index)
162+ var item = target.model.get(index)
163 scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title,
163 scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title,
164 item.comment, item.dndUri, item.metadata)
164 item.comment, item.dndUri, item.metadata)
165 }
165 }
Dash/Music/MusicFilterGrid.qml+2−2
@@ -44,11 +44,11 @@ GenericFilterGrid {
44 }
44 }
45
45
46 onClicked: {
46 onClicked: {
47− filtergrid.clicked(index, filtergrid.model, tile.y)
47+ filtergrid.clicked(index, tile.y)
48 }
48 }
49
49
50 onPressAndHold: {
50 onPressAndHold: {
51− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
51+ filtergrid.pressAndHold(index, tile.y)
52 }
52 }
53 }
53 }
54}
54}
Dash/Video/VideoFilterGrid.qml+2−2
@@ -42,11 +42,11 @@ GenericFilterGrid {
42 style: VideoTileStyle {}
42 style: VideoTileStyle {}
43
43
44 onClicked: {
44 onClicked: {
45− filtergrid.clicked(index, filtergrid.model, tile.y)
45+ filtergrid.clicked(index, tile.y)
46 }
46 }
47
47
48 onPressAndHold: {
48 onPressAndHold: {
49− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
49+ filtergrid.pressAndHold(index, tile.y)
50 }
50 }
51 }
51 }
52}
52}