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
1=== modified file 'MusicTracks.qml'
2--- MusicTracks.qml 2015-01-11 17:04:55 +0000
3+++ MusicTracks.qml 2015-01-25 16:46:40 +0000
4@@ -96,10 +96,14 @@
5 iconName: "add"
6 text: i18n.tr("Add to queue")
7 onTriggered: {
8+ var items = []
9+
10 for (var i=0; i < tracklist.selectedItems.length; i++) {
11- trackQueue.append(makeDict(tracklist.model.get(tracklist.selectedItems[i], tracklist.model.RoleModelData)));
12+ items.push(tracklist.model.get(tracklist.selectedItems[i], tracklist.model.RoleModelData));
13 }
14
15+ trackQueue.appendList(items)
16+
17 tracklist.closeSelection()
18 }
19 }
20
21=== modified file 'MusicaddtoPlaylist.qml'
22--- MusicaddtoPlaylist.qml 2015-01-21 00:10:33 +0000
23+++ MusicaddtoPlaylist.qml 2015-01-25 16:46:40 +0000
24@@ -105,11 +105,7 @@
25 secondaryText: i18n.tr("%1 song", "%1 songs", playlist.count).arg(playlist.count)
26
27 onClicked: {
28- for (var i=0; i < chosenElements.length; i++) {
29- console.debug("Debug: "+chosenElements[i].filename+" added to "+name)
30-
31- Playlists.addToPlaylist(name, chosenElements[i])
32- }
33+ Playlists.addToPlaylistList(name, chosenElements)
34
35 // Check that the parent parent page is not being refiltered
36 if (page !== undefined && page.page !== undefined && page.page.title === i18n.tr("Playlists")) {
37
38=== modified file 'common/SongsPage.qml'
39--- common/SongsPage.qml 2015-01-18 16:46:48 +0000
40+++ common/SongsPage.qml 2015-01-25 16:46:40 +0000
41@@ -191,10 +191,14 @@
42 iconName: "add"
43 text: i18n.tr("Add to queue")
44 onTriggered: {
45+ var items = []
46+
47 for (var i=0; i < albumtrackslist.selectedItems.length; i++) {
48- trackQueue.append(makeDict(albumtrackslist.model.get(albumtrackslist.selectedItems[i], albumtrackslist.model.RoleModelData)));
49+ items.push(albumtrackslist.model.get(albumtrackslist.selectedItems[i], albumtrackslist.model.RoleModelData));
50 }
51
52+ trackQueue.appendList(items)
53+
54 albumtrackslist.closeSelection()
55 }
56 },
57
58=== modified file 'music-app.qml'
59--- music-app.qml 2015-01-23 13:22:29 +0000
60+++ music-app.qml 2015-01-25 16:46:40 +0000
61@@ -624,12 +624,10 @@
62
63 for (var i=0; i < model.rowCount; i++) {
64 items.push(model.get(i, model.RoleModelData))
65-
66- trackQueue.model.append(items[i]);
67 }
68
69 // Add model to queue storage
70- Library.addQueueList(items);
71+ trackQueue.appendList(items)
72 }
73
74 // Converts an duration in ms to a formated string ("minutes:seconds")
75@@ -889,6 +887,15 @@
76 Library.addQueueItem(listElement.filename)
77 }
78
79+ function appendList(items)
80+ {
81+ for (var i=0; i < items.length; i++) {
82+ model.append(makeDict(items[i]))
83+ }
84+
85+ Library.addQueueList(items)
86+ }
87+
88 function clear()
89 {
90 model.clear()
91
92=== modified file 'playlists.js'
93--- playlists.js 2015-01-18 16:46:48 +0000
94+++ playlists.js 2015-01-25 16:46:40 +0000
95@@ -173,6 +173,24 @@
96 return rs
97 }
98
99+// Method to add multiple tracks to a playlist in 1 transaction
100+function addToPlaylistList(playlist, items, tx)
101+{
102+ if (tx === undefined) {
103+ var db = getPlaylistDatabase()
104+
105+ db.transaction(function (tx) {
106+ addToPlaylistList(playlist, items, tx)
107+ });
108+ }
109+ else {
110+ for (var i=0; i < items.length; i++) {
111+ addToPlaylist(playlist, items[i], tx)
112+ console.debug("Debug: " + items[i].filename + " added to " + playlist)
113+ }
114+ }
115+}
116+
117 function getPlaylists() {
118 // returns playlists with count and 4 covers
119 var db = getPlaylistDatabase()

Subscribers

People subscribed via source and target branches