on xenial help sign in
No need to pass the model up and down

Whoever is listening to the signal has access to the item that emits the signal and has the model right there accessible if needs it

commit28d3c57b2cfac6882c0a347a53467c69ed994d02 authorAlbert Astals <albert.astals@canonical.com> dateMon 11 Nov 2013, 12:44 (13 years ago) parentc3793e5
8 files changed+24−26
Components/Carousel.qml+4−6 Dash/Apps/ApplicationsFilterGrid.qml+4−4 Dash/Apps/DashPluginFilterGrid.qml+2−2 Dash/Generic/GenericFilterGrid.qml+4−4 Dash/Generic/WeatherFilterGrid.qml+2−2 Dash/GenericScopeView.qml+4−4 Dash/Music/MusicFilterGrid.qml+2−2 Dash/Video/VideoFilterGrid.qml+2−2
Components/Carousel.qml+4−6
@@ -54,15 +54,13 @@ Item {
5454
5555 /// Emitted when the user clicked on an item
5656 /// @param index is the index of the clicked item
57− /// @param model is the model of all the items in the carousel
5857 /// @param itemY is y of the clicked delegate
59− signal clicked(int index, var model, real itemY)
58+ signal clicked(int index, real itemY)
6059
6160 /// Emitted when the user pressed and held on an item
6261 /// @param index is the index of the held item
63− /// @param model is the model of all the items in the carousel
6462 /// @param itemY is y of the held delegate
65− signal pressAndHold(int index, var model, real itemY)
63+ signal pressAndHold(int index, real itemY)
6664
6765 implicitHeight: listView.tileHeight * selectedItemScaleFactor
6866
@@ -163,7 +161,7 @@ Item {
163161 /* We're clicking the selected item and
164162 we're in the neighbourhood of radius 1 pixel from it.
165163 Let's emit the clicked signal. */
166− carousel.clicked(index, listView.model, delegateItem.y)
164+ carousel.clicked(index, delegateItem.y)
167165 return
168166 }
169167
@@ -187,7 +185,7 @@ Item {
187185 /* We're pressAndHold the selected item and
188186 we're in the neighbourhood of radius 1 pixel from it.
189187 Let's emit the pressAndHold signal. */
190− carousel.pressAndHold(index, listView.model, delegateItem.y);
188+ carousel.pressAndHold(index, delegateItem.y);
191189 return;
192190 }
193191
Dash/Apps/ApplicationsFilterGrid.qml+4−4
@@ -28,8 +28,8 @@ FilterGrid {
2828 delegateHeight: units.gu(9.5)
2929 verticalSpacing: units.gu(2)
3030
31− signal clicked(int index, var model, real itemY)
32− signal pressAndHold(int index, var model, real itemY)
31+ signal clicked(int index, real itemY)
32+ signal pressAndHold(int index, real itemY)
3333
3434 delegate: Tile {
3535 id: tile
@@ -54,11 +54,11 @@ FilterGrid {
5454 source: icon
5555
5656 onClicked: {
57− filtergrid.clicked(index, filtergrid.model, tile.y)
57+ filtergrid.clicked(index, tile.y)
5858 }
5959
6060 onPressAndHold: {
61− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
61+ filtergrid.pressAndHold(index, tile.y)
6262 }
6363 }
6464}
Dash/Apps/DashPluginFilterGrid.qml+2−2
@@ -37,11 +37,11 @@ GenericFilterGrid {
3737 }
3838
3939 onClicked: {
40− filtergrid.clicked(index, filtergrid.model, tile.y)
40+ filtergrid.clicked(index, tile.y)
4141 }
4242
4343 onPressAndHold: {
44− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
44+ filtergrid.pressAndHold(index, tile.y)
4545 }
4646 }
4747}
Dash/Generic/GenericFilterGrid.qml+4−4
@@ -28,8 +28,8 @@ FilterGrid {
2828 property int iconWidth: units.gu(8)
2929 property int iconHeight: units.gu(7.5)
3030
31− signal clicked(int index, var model, real itemY)
32− signal pressAndHold(int index, var model, real itemY)
31+ signal clicked(int index, real itemY)
32+ signal pressAndHold(int index, real itemY)
3333
3434 delegate: Tile {
3535 id: tile
@@ -42,11 +42,11 @@ FilterGrid {
4242 source: model.icon
4343
4444 onClicked: {
45− filtergrid.clicked(index, filtergrid.model, tile.y)
45+ filtergrid.clicked(index, tile.y)
4646 }
4747
4848 onPressAndHold: {
49− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
49+ filtergrid.pressAndHold(index, tile.y)
5050 }
5151 }
5252}
Dash/Generic/WeatherFilterGrid.qml+2−2
@@ -37,11 +37,11 @@ GenericFilterGrid {
3737 style: FlatTileStyle {}
3838
3939 onClicked: {
40− filtergrid.clicked(index, filtergrid.model, tile.y)
40+ filtergrid.clicked(index, tile.y)
4141 }
4242
4343 onPressAndHold: {
44− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
44+ filtergrid.pressAndHold(index, tile.y)
4545 }
4646 }
4747}
Dash/GenericScopeView.qml+4−4
@@ -133,11 +133,11 @@ ScopeView {
133133 effect.positionPx = mapToItem(categoryView, 0, itemY).y
134134 previewListView.categoryId = categoryId
135135 previewListView.categoryDelegate = rendererLoader.item
136− previewListView.model = model;
136+ previewListView.model = target.model;
137137 previewListView.init = true;
138138 previewListView.currentIndex = index;
139139
140− var item = model.get(index);
140+ var item = target.model.get(index);
141141
142142 if ((scopeView.scope.id == "applications.scope" && categoryId == "installed")
143143 || (scopeView.scope.id == "home.scope" && categoryId == "applications.scope")) {
@@ -154,12 +154,12 @@ ScopeView {
154154 effect.positionPx = mapToItem(categoryView, 0, itemY).y
155155 previewListView.categoryId = categoryId
156156 previewListView.categoryDelegate = rendererLoader.item
157− previewListView.model = model;
157+ previewListView.model = target.model;
158158 previewListView.init = true;
159159 previewListView.currentIndex = index;
160160 previewListView.open = true
161161
162− var item = model.get(index)
162+ var item = target.model.get(index)
163163 scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title,
164164 item.comment, item.dndUri, item.metadata)
165165 }
Dash/Music/MusicFilterGrid.qml+2−2
@@ -44,11 +44,11 @@ GenericFilterGrid {
4444 }
4545
4646 onClicked: {
47− filtergrid.clicked(index, filtergrid.model, tile.y)
47+ filtergrid.clicked(index, tile.y)
4848 }
4949
5050 onPressAndHold: {
51− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
51+ filtergrid.pressAndHold(index, tile.y)
5252 }
5353 }
5454}
Dash/Video/VideoFilterGrid.qml+2−2
@@ -42,11 +42,11 @@ GenericFilterGrid {
4242 style: VideoTileStyle {}
4343
4444 onClicked: {
45− filtergrid.clicked(index, filtergrid.model, tile.y)
45+ filtergrid.clicked(index, tile.y)
4646 }
4747
4848 onPressAndHold: {
49− filtergrid.pressAndHold(index, filtergrid.model, tile.y)
49+ filtergrid.pressAndHold(index, tile.y)
5050 }
5151 }
5252}