git.iko.soy/maciek134/podphoenix
on main help sign in
Store download related data that needs to persist across app reboots in that download's custom metadata (rev 154)
commite38c2ca05b70e49f337a5fadec9734353c0d83cb authorMichael Sheldon <michael.sheldon@canonical.com> dateSat 3 Dec 2016, 22:30 (10 years ago) parentb3a50db
2 files changed+5−5
app/podbird.qml+3−3 app/ui/EpisodesTab.qml+2−2
app/podbird.qml+3−3
@@ -43,7 +43,6 @@ MainView {
4343 : "Ubuntu.Components.Themes.Ambiance"
4444
4545 Component.onDestruction: {
46− console.log("[LOG]: Download cancelled");
4746 var db = Podcasts.init()
4847 db.transaction(function (tx) {
4948 tx.executeSql('UPDATE Episode SET queued=0 WHERE queued=1');
@@ -167,6 +166,7 @@ MainView {
167166 metadata: Metadata {
168167 showInIndicator: true
169168 title: singleDownloadObject.title
169+ custom: {"guid": singleDownloadObject.guid, "image" : singleDownloadObject.image}
170170 }
171171 }
172172 }
@@ -179,7 +179,7 @@ MainView {
179179 DownloadManager {
180180 id: downloader
181181
182− property string downloadingGuid: downloads.length > 0 ? downloads[0].guid : "NULL"
182+ property string downloadingGuid: downloads.length > 0 ? downloads[0].metadata.custom.guid : "NULL"
183183 property int progress: downloads.length > 0 ? downloads[0].progress : 0
184184
185185 cleanDownloads: true
@@ -187,7 +187,7 @@ MainView {
187187 var db = Podcasts.init();
188188 var finalLocation = fileManager.saveDownload(path);
189189 db.transaction(function (tx) {
190− tx.executeSql("UPDATE Episode SET downloadedfile=?, queued=0 WHERE guid=?", [finalLocation, download.guid]);
190+ tx.executeSql("UPDATE Episode SET downloadedfile=?, queued=0 WHERE guid=?", [finalLocation, download.metadata.custom.guid]);
191191 });
192192 }
193193
app/ui/EpisodesTab.qml+2−2
@@ -468,7 +468,7 @@ Tab {
468468 Image {
469469 height: width
470470 width: units.gu(6)
471− source: modelData.image !== undefined ? modelData.image : Qt.resolvedUrl("../graphics/podbird.png")
471+ source: modelData.metadata.custom.image !== undefined ? modelData.metadata.custom.image : Qt.resolvedUrl("../graphics/podbird.png")
472472 SlotsLayout.position: SlotsLayout.Leading
473473 sourceSize { width: width; height: height }
474474 }
@@ -477,7 +477,7 @@ Tab {
477477 spacing: units.gu(0.5)
478478
479479 Label {
480− text: modelData.title
480+ text: modelData.metadata.title
481481 width: parent.width
482482 elide: Text.ElideRight
483483 }