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

« back to all changes in this revision

Viewing changes to app/ui/Queue.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:
 
1
/*
 
2
 * Copyright 2016 Podbird Team
 
3
 *
 
4
 * This file is part of Podbird.
 
5
 *
 
6
 * Podbird is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * Podbird is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import Ubuntu.Components 1.3
 
21
import "../podcasts.js" as Podcasts
 
22
import "../components"
 
23
 
 
24
Item {
 
25
    id: queuePage
 
26
 
 
27
    ListView {
 
28
        id: queueList
 
29
 
 
30
        anchors.fill: parent
 
31
        model: player.playlist
 
32
 
 
33
        delegate: ListItem {
 
34
            id: listItem
 
35
 
 
36
            height: layout.height
 
37
            divider.visible: false
 
38
 
 
39
            ListItemLayout {
 
40
                id: layout
 
41
 
 
42
                // Grab the metaData for the current index using its unique source url
 
43
                property var metaModel: player.metaForSource(model.source)
 
44
 
 
45
                Image {
 
46
                    id: imgFrame
 
47
                    width: units.gu(6)
 
48
                    height: width
 
49
                    source: Qt.resolvedUrl(layout.metaModel.image)
 
50
                    sourceSize.height: width
 
51
                    sourceSize.width: width
 
52
                    SlotsLayout.position: SlotsLayout.First
 
53
                }
 
54
 
 
55
                title.text: layout.metaModel.name
 
56
                // #FIXME: Change this 2 to prevent title eliding when UITK is updated to rev > 1800
 
57
                title.maximumLineCount: 1
 
58
                title.color: player.playlist.currentIndex === index ? podbird.appTheme.focusText
 
59
                                                                    : podbird.appTheme.baseText
 
60
 
 
61
                subtitle.text: layout.metaModel.artist
 
62
                subtitle.color: podbird.appTheme.baseSubText
 
63
            }
 
64
 
 
65
            leadingActions: ListItemActions {
 
66
                actions: [
 
67
                    Action {
 
68
                        iconName: "delete"
 
69
                        onTriggered: {
 
70
                            player.playlist.removeItem(index)
 
71
                            var source = model.source
 
72
                            source = source.toString()
 
73
                            Podcasts.removeItemFromQueue(source)
 
74
                        }
 
75
                    }
 
76
                ]
 
77
            }
 
78
 
 
79
            onClicked: {
 
80
                if (player.playlist.currentIndex === index) {
 
81
                    player.toggle()
 
82
                } else {
 
83
                    player.playlist.currentIndex = index
 
84
                }
 
85
            }
 
86
        }
 
87
    }
 
88
}