~nik90/podbird/devel-branch-sync-4

« back to all changes in this revision

Viewing changes to app/ui/EpisodesPage.qml

  • Committer: Michael Sheldon
  • Author(s): Nekhelesh Ramananthan
  • Date: 2016-03-28 23:19:36 UTC
  • mfrom: (149.2.8 devel-branch-sync-2)
  • Revision ID: michael.sheldon@canonical.com-20160328231936-g9fydaeiwkx7vgk3
Add queue support. Use DownloadManager to handle download queues and unfinished downloads when app is closed. Switch to new GridView. Add multi-select for Episodes tab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
 
19
19
import QtQuick 2.4
20
 
import QtMultimedia 5.4
 
20
import QtMultimedia 5.6
21
21
import Ubuntu.Components 1.3
22
22
import QtQuick.LocalStorage 2.0
23
 
import Ubuntu.DownloadManager 0.1
 
23
import Ubuntu.DownloadManager 1.2
24
24
import Ubuntu.Components.Popups 1.3
25
25
import "../podcasts.js" as Podcasts
26
26
import "../components"
442
442
                id: listItemLayout
443
443
 
444
444
                title.text: model.name !== undefined ? model.name.trim() : "Undefined"
445
 
                title.color: currentGuid === model.guid || downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
446
 
                                                                                                     : podbird.appTheme.baseText
 
445
                title.color: downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
 
446
                                                                       : podbird.appTheme.baseText
447
447
                // #FIXME: Change this 2 to prevent title eliding when UITK is updated to rev > 1800
448
448
                title.maximumLineCount: 1
449
449
 
505
505
                                    tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [model.guid]);
506
506
                                });
507
507
                                episodeModel.setProperty(model.index, "queued", 1)
508
 
                                downloader.addDownload(model.guid, model.audiourl);
 
508
                                if (model.audiourl) {
 
509
                                    podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
 
510
                                } else {
 
511
                                    console.log("[ERROR]: Invalid download url: " + model.audiourl)
 
512
                                }
509
513
                            }
510
514
                        }
511
515
                    },
512
516
 
513
517
                    Action {
 
518
                        iconName: "add-to-playlist"
 
519
                        onTriggered: {
 
520
                            var url = model.downloadedfile ? "file://" + model.downloadedfile : model.audiourl
 
521
                            player.addEpisodeToQueue(model.guid, model.image, model.name, model.artist, url)
 
522
                        }
 
523
                    },
 
524
 
 
525
                    Action {
514
526
                        iconName: model.favourited ? "unlike" : "like"
515
527
                        onTriggered: {
516
528
                            var db = Podcasts.init();
536
548
 
537
549
            onClicked: {
538
550
                Haptics.play()
539
 
                var db = Podcasts.init();
540
 
                db.transaction(function (tx) {
541
 
                    if (currentGuid !== model.guid) {
542
 
                        currentGuid = "";
543
 
                        currentUrl = model.downloadedfile ? model.downloadedfile : model.audiourl;
544
 
                        var rs = tx.executeSql("SELECT position FROM Episode WHERE guid=?", [model.guid]);
545
 
                        playerLoader.item.play();
546
 
                        playerLoader.item.seek(rs.rows.item(0).position);
547
 
                        currentName = model.name;
548
 
                        currentArtist = model.artist;
549
 
                        currentImage = model.image;
550
 
                        currentGuid = model.guid;
551
 
                    }
552
 
                });
 
551
                if (currentGuid !== model.guid) {
 
552
                    currentUrl = model.downloadedfile ? "file://" + model.downloadedfile : model.audiourl;
 
553
                    player.playEpisode(model.guid, model.image, model.name, model.artist, currentUrl)
 
554
                }
553
555
            }
554
556
        }
555
557