Merge lp:~ahayzen/music-app/batch-add into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 810
Merged at revision: 810
Proposed branch: lp:~ahayzen/music-app/batch-add
Merge into: lp:music-app/remix
Diff against target: 119 lines (+39/-10)
5 files modified
MusicTracks.qml (+5/-1)
MusicaddtoPlaylist.qml (+1/-5)
common/SongsPage.qml (+5/-1)
music-app.qml (+10/-3)
playlists.js (+18/-0)
To merge this branch: bzr merge lp:~ahayzen/music-app/batch-add
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+247532@code.launchpad.net

Commit message

* Batch add to playlists and queue to improve responsiveness of the app

Description of the change

* Batch add to playlists and queue to improve responsiveness of the app

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

LGTM! Lightning fast add to queue ftw!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MusicTracks.qml'
--- MusicTracks.qml 2015-01-11 17:04:55 +0000
+++ MusicTracks.qml 2015-01-25 16:46:40 +0000
@@ -96,10 +96,14 @@
96 iconName: "add"96 iconName: "add"
97 text: i18n.tr("Add to queue")97 text: i18n.tr("Add to queue")
98 onTriggered: {98 onTriggered: {
99 var items = []
100
99 for (var i=0; i < tracklist.selectedItems.length; i++) {101 for (var i=0; i < tracklist.selectedItems.length; i++) {
100 trackQueue.append(makeDict(tracklist.model.get(tracklist.selectedItems[i], tracklist.model.RoleModelData)));102 items.push(tracklist.model.get(tracklist.selectedItems[i], tracklist.model.RoleModelData));
101 }103 }
102104
105 trackQueue.appendList(items)
106
103 tracklist.closeSelection()107 tracklist.closeSelection()
104 }108 }
105 }109 }
106110
=== modified file 'MusicaddtoPlaylist.qml'
--- MusicaddtoPlaylist.qml 2015-01-21 00:10:33 +0000
+++ MusicaddtoPlaylist.qml 2015-01-25 16:46:40 +0000
@@ -105,11 +105,7 @@
105 secondaryText: i18n.tr("%1 song", "%1 songs", playlist.count).arg(playlist.count)105 secondaryText: i18n.tr("%1 song", "%1 songs", playlist.count).arg(playlist.count)
106106
107 onClicked: {107 onClicked: {
108 for (var i=0; i < chosenElements.length; i++) {108 Playlists.addToPlaylistList(name, chosenElements)
109 console.debug("Debug: "+chosenElements[i].filename+" added to "+name)
110
111 Playlists.addToPlaylist(name, chosenElements[i])
112 }
113109
114 // Check that the parent parent page is not being refiltered110 // Check that the parent parent page is not being refiltered
115 if (page !== undefined && page.page !== undefined && page.page.title === i18n.tr("Playlists")) {111 if (page !== undefined && page.page !== undefined && page.page.title === i18n.tr("Playlists")) {
116112
=== modified file 'common/SongsPage.qml'
--- common/SongsPage.qml 2015-01-18 16:46:48 +0000
+++ common/SongsPage.qml 2015-01-25 16:46:40 +0000
@@ -191,10 +191,14 @@
191 iconName: "add"191 iconName: "add"
192 text: i18n.tr("Add to queue")192 text: i18n.tr("Add to queue")
193 onTriggered: {193 onTriggered: {
194 var items = []
195
194 for (var i=0; i < albumtrackslist.selectedItems.length; i++) {196 for (var i=0; i < albumtrackslist.selectedItems.length; i++) {
195 trackQueue.append(makeDict(albumtrackslist.model.get(albumtrackslist.selectedItems[i], albumtrackslist.model.RoleModelData)));197 items.push(albumtrackslist.model.get(albumtrackslist.selectedItems[i], albumtrackslist.model.RoleModelData));
196 }198 }
197199
200 trackQueue.appendList(items)
201
198 albumtrackslist.closeSelection()202 albumtrackslist.closeSelection()
199 }203 }
200 },204 },
201205
=== modified file 'music-app.qml'
--- music-app.qml 2015-01-23 13:22:29 +0000
+++ music-app.qml 2015-01-25 16:46:40 +0000
@@ -624,12 +624,10 @@
624624
625 for (var i=0; i < model.rowCount; i++) {625 for (var i=0; i < model.rowCount; i++) {
626 items.push(model.get(i, model.RoleModelData))626 items.push(model.get(i, model.RoleModelData))
627
628 trackQueue.model.append(items[i]);
629 }627 }
630628
631 // Add model to queue storage629 // Add model to queue storage
632 Library.addQueueList(items);630 trackQueue.appendList(items)
633 }631 }
634632
635 // Converts an duration in ms to a formated string ("minutes:seconds")633 // Converts an duration in ms to a formated string ("minutes:seconds")
@@ -889,6 +887,15 @@
889 Library.addQueueItem(listElement.filename)887 Library.addQueueItem(listElement.filename)
890 }888 }
891889
890 function appendList(items)
891 {
892 for (var i=0; i < items.length; i++) {
893 model.append(makeDict(items[i]))
894 }
895
896 Library.addQueueList(items)
897 }
898
892 function clear()899 function clear()
893 {900 {
894 model.clear()901 model.clear()
895902
=== modified file 'playlists.js'
--- playlists.js 2015-01-18 16:46:48 +0000
+++ playlists.js 2015-01-25 16:46:40 +0000
@@ -173,6 +173,24 @@
173 return rs173 return rs
174}174}
175175
176// Method to add multiple tracks to a playlist in 1 transaction
177function addToPlaylistList(playlist, items, tx)
178{
179 if (tx === undefined) {
180 var db = getPlaylistDatabase()
181
182 db.transaction(function (tx) {
183 addToPlaylistList(playlist, items, tx)
184 });
185 }
186 else {
187 for (var i=0; i < items.length; i++) {
188 addToPlaylist(playlist, items[i], tx)
189 console.debug("Debug: " + items[i].filename + " added to " + playlist)
190 }
191 }
192}
193
176function getPlaylists() {194function getPlaylists() {
177 // returns playlists with count and 4 covers195 // returns playlists with count and 4 covers
178 var db = getPlaylistDatabase()196 var db = getPlaylistDatabase()

Subscribers

People subscribed via source and target branches