~ahayzen/music-app/remix-add-card-view

« back to all changes in this revision

Viewing changes to common/SongsPage.qml

* Remove expander, reorder, swipedelete code
* Use ListItemWithActions from other apps
* Implement actions for add to playlist, add to queue, edit playlist, delete playlist
* Implement reordering. Fixes: https://bugs.launchpad.net/bugs/1311800, https://bugs.launchpad.net/bugs/1338042.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import Ubuntu.Thumbnailer 0.1
25
25
import QtQuick.LocalStorage 2.0
26
26
import "../meta-database.js" as Library
27
 
import "ExpanderItems"
 
27
import "../playlists.js" as Playlists
 
28
import "ListItemActions"
28
29
 
29
30
MusicPage {
30
31
    id: songStackPage
55
56
        }
56
57
        delegate: albumTracksDelegate
57
58
        model: isAlbum ? songsModel : albumTracksModel.model
 
59
        objectName: "songspage-listview"
58
60
        width: parent.width
59
61
        header: ListItem.Standard {
60
62
            id: albumInfo
210
212
        Component {
211
213
            id: albumTracksDelegate
212
214
 
213
 
            ListItem.Standard {
 
215
            ListItemWithActions {
214
216
                id: track
 
217
                color: "transparent"
215
218
                objectName: "songspage-track"
216
219
                iconFrame: false
217
220
                progression: false
218
221
                height: styleMusic.common.itemHeight
219
222
 
220
 
                MouseArea {
221
 
                    anchors.fill: parent
222
 
                    onDoubleClicked: {
223
 
                    }
224
 
                    onClicked: {
225
 
                        if (focus == false) {
226
 
                            focus = true
227
 
                        }
228
 
 
229
 
                        trackClicked(albumtrackslist.model, index)  // play track
230
 
 
231
 
                        if (isAlbum && songStackPage.line1 !== "Genre") {
232
 
                            Library.addRecent(songStackPage.line2, songStackPage.line1, songStackPage.covers[0], songStackPage.line2, "album")
233
 
                            mainView.hasRecent = true
234
 
                            recentModel.filterRecent()
235
 
                        } else if (songStackPage.line1 === "Playlist") {
236
 
                            Library.addRecent(songStackPage.line2, "Playlist", songStackPage.covers[0], songStackPage.line2, "playlist")
237
 
                            mainView.hasRecent = true
238
 
                            recentModel.filterRecent()
 
223
                leftSideAction: songStackPage.line1 === "Playlist"
 
224
                                ? playlistRemoveAction.item : null
 
225
                reorderable: songStackPage.line1 === "Playlist"
 
226
                rightSideActions: [
 
227
                    AddToQueue {
 
228
 
 
229
                    },
 
230
                    AddToPlaylist {
 
231
 
 
232
                    }
 
233
                ]
 
234
                triggerActionOnMouseRelease: true
 
235
 
 
236
                onItemClicked: {
 
237
                    trackClicked(albumtrackslist.model, index)  // play track
 
238
 
 
239
                    if (isAlbum && songStackPage.line1 !== "Genre") {
 
240
                        Library.addRecent(songStackPage.line2, songStackPage.line1, songStackPage.covers[0], songStackPage.line2, "album")
 
241
                        mainView.hasRecent = true
 
242
                        recentModel.filterRecent()
 
243
                    } else if (songStackPage.line1 === "Playlist") {
 
244
                        Library.addRecent(songStackPage.line2, "Playlist", songStackPage.covers[0], songStackPage.line2, "playlist")
 
245
                        mainView.hasRecent = true
 
246
                        recentModel.filterRecent()
 
247
                    }
 
248
                }
 
249
                onReorder: {
 
250
                    console.debug("Move: ", from, to);
 
251
 
 
252
                    Playlists.move(songStackPage.line2, from, to)
 
253
 
 
254
                    albumTracksModel.filterPlaylistTracks(songStackPage.line2)
 
255
                }
 
256
 
 
257
                Loader {
 
258
                    id: playlistRemoveAction
 
259
                    sourceComponent: Remove {
 
260
                        onTriggered: {
 
261
                            Playlists.removeFromPlaylist(songStackPage.line2, model.i)
 
262
 
 
263
                            albumTracksModel.filterPlaylistTracks(songStackPage.line2)
 
264
                            playlistModel.filterPlaylists()
239
265
                        }
240
266
                    }
241
267
                }
268
294
                    }
269
295
                }
270
296
 
271
 
                Expander {
272
 
                    id: expandable
273
 
                    anchors {
274
 
                        fill: parent
275
 
                    }
276
 
                    listItem: track
277
 
                    model: isAlbum ? albumtrackslist.model.get(index, albumTracksModel.model.RoleModelData) : albumtrackslist.model.get(index)
278
 
                    row: Row {
279
 
                        AddToPlaylist {
280
 
 
281
 
                        }
282
 
                        AddToQueue {
283
 
 
284
 
                        }
285
 
                    }
286
 
                }
287
 
 
288
297
                Component.onCompleted: {
289
298
                    if (model.date !== undefined)
290
299
                    {