2
* Copyright (C) 2013 Andrew Hayzen <ahayzen@gmail.com>
3
* Daniel Holm <d.holmen@gmail.com>
4
* Victor Thompson <victor.thompson@gmail.com>
6
* This program 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.
10
* This program 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.
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/>.
20
import Ubuntu.Components 0.1
21
import Ubuntu.Components.ListItems 0.1
22
import Ubuntu.Components.Popups 0.1
23
import Ubuntu.Components.ListItems 0.1 as ListItem
24
import QtQuick.LocalStorage 2.0
25
import "../meta-database.js" as Library
30
property string line1: ""
31
property string line2: ""
32
property string songtitle: ""
33
property string cover: ""
34
property string length: ""
35
property string file: ""
36
property string year: ""
37
property bool isAlbum: false
38
property alias sheet: sheetComponent
44
anchors.bottomMargin: units.gu(.5)
46
contentsHeight: parent.height
47
contentsWidth: parent.width
53
anchors.top: parent.top
54
anchors.bottom: parent.bottom
55
model: albumTracksModel.model
56
delegate: albumTracksDelegate
57
header: ListItem.Standard {
64
anchors.left: parent.left
65
anchors.top: parent.top
66
anchors.verticalCenter: parent.verticalCenter
67
anchors.margins: units.gu(1)
71
source: cover || "../images/cover_default.png"
76
objectName: "albumsheet-albumartist"
80
anchors.left: albumImage.right
81
anchors.leftMargin: units.gu(1)
82
anchors.top: parent.top
83
anchors.topMargin: units.gu(1.5)
84
anchors.right: parent.right
85
anchors.rightMargin: units.gu(1.5)
86
elide: Text.ElideRight
94
color: styleMusic.common.music
95
anchors.left: albumImage.right
96
anchors.leftMargin: units.gu(1)
97
anchors.top: albumArtist.bottom
98
anchors.topMargin: units.gu(0.8)
99
anchors.right: parent.right
100
anchors.rightMargin: units.gu(1.5)
101
elide: Text.ElideRight
106
wrapMode: Text.NoWrap
109
anchors.left: albumImage.right
110
anchors.leftMargin: units.gu(1)
111
anchors.top: albumLabel.bottom
112
anchors.topMargin: units.gu(2)
113
anchors.right: parent.right
114
anchors.rightMargin: units.gu(1.5)
115
elide: Text.ElideRight
116
text: isAlbum ? i18n.tr(year + " | %1 song", year + " | %1 songs", albumTracksModel.model.count).arg(albumTracksModel.model.count)
117
: i18n.tr("%1 song", "%1 songs", albumTracksModel.model.count).arg(albumTracksModel.model.count)
123
albumtrackslist.currentIndex = albumTracksModel.indexOf(currentFile)
127
id: albumTracksDelegate
131
objectName: "albumsheet-track"
134
height: isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)
141
if (focus == false) {
144
trackClicked(albumTracksModel, index) // play track
146
Library.addRecent(sheetItem.line2, sheetItem.line1, sheetItem.cover, sheetItem.line2, "album")
147
mainView.hasRecent = true
148
recentModel.filterRecent()
149
} else if (sheetItem.line1 == "Playlist") {
150
Library.addRecent(sheetItem.line2, "Playlist", sheetItem.cover, sheetItem.line2, "playlist")
151
mainView.hasRecent = true
152
recentModel.filterRecent()
155
// TODO: This closes the SDK defined sheet
156
// component. It should be able to close
158
PopupUtils.close(sheet)
166
leftMargin: units.gu(2)
168
topMargin: units.gu(1)
170
width: styleMusic.common.albumSize
171
height: styleMusic.common.albumSize
174
source: model.cover !== "" ? model.cover : Qt.resolvedUrl("../images/cover_default_icon.png")
180
wrapMode: Text.NoWrap
185
left: trackCover.right
186
leftMargin: units.gu(2)
188
topMargin: units.gu(1.5)
189
right: expandItem.left
190
rightMargin: units.gu(1.5)
192
elide: Text.ElideRight
198
objectName: "albumsheet-tracktitle"
199
wrapMode: Text.NoWrap
203
left: isAlbum ? parent.left : trackCover.right
204
leftMargin: units.gu(2)
205
top: isAlbum ? parent.top : trackArtist.bottom
206
topMargin: units.gu(1)
207
right: expandItem.left
208
rightMargin: units.gu(1.5)
210
elide: Text.ElideRight
216
wrapMode: Text.NoWrap
221
left: trackCover.right
222
leftMargin: units.gu(2)
223
top: trackTitle.bottom
224
topMargin: units.gu(2)
225
right: expandItem.left
226
rightMargin: units.gu(1.5)
228
elide: Text.ElideRight
234
objectName: "albumsheet-expanditem"
235
anchors.right: parent.right
236
anchors.rightMargin: units.gu(2)
237
source: expandable.visible ? "../images/dropdown-menu-up.svg" : "../images/dropdown-menu.svg"
238
height: styleMusic.common.expandedItem
239
width: styleMusic.common.expandedItem
240
y: parent.y + ((isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)) / 2) - (height / 2)
244
anchors.bottom: parent.bottom
245
anchors.right: parent.right
246
anchors.top: parent.top
247
width: styleMusic.common.expandedItem * 3
249
if(expandable.visible) {
250
customdebug("clicked collapse")
251
expandable.visible = false
252
track.height = isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)
255
customdebug("clicked expand")
256
collapseExpand(-1); // collapse all others
257
expandable.visible = true
258
track.height = isAlbum ? styleMusic.albums.expandedHeight : styleMusic.common.expandedHeight
266
height: styleMusic.albums.expandHeight
271
customdebug("User pressed outside the playlist item and expanded items.")
275
Component.onCompleted: {
276
collapseExpand.connect(onCollapseExpand);
279
function onCollapseExpand(indexCol)
281
if ((indexCol === index || indexCol === -1) && expandable !== undefined && expandable.visible === true)
283
customdebug("auto collapse")
284
expandable.visible = false
285
track.height = isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + unis.gu(2)
289
// background for expander
291
id: expandedBackground
292
anchors.top: parent.top
293
anchors.topMargin: isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)
294
color: styleMusic.common.black
295
height: styleMusic.albums.expandedHeight - styleMusic.albums.itemHeight
303
anchors.top: expandedBackground.top
304
anchors.left: parent.left
305
anchors.leftMargin: styleMusic.albums.expandedLeftMargin
307
height: expandedBackground.height
311
anchors.verticalCenter: parent.verticalCenter
312
color: styleMusic.common.white
314
height: styleMusic.common.expandedItem
315
width: styleMusic.common.expandedItem
318
anchors.left: playlistTrack.right
319
anchors.leftMargin: units.gu(0.5)
320
anchors.verticalCenter: parent.verticalCenter
321
color: styleMusic.common.white
323
width: parent.width - playlistTrack.width - units.gu(1)
324
text: i18n.tr("Add to playlist")
325
wrapMode: Text.WordWrap
331
expandable.visible = false
332
track.height = isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)
333
chosenArtist = artist
340
console.debug("Debug: Add track to playlist")
341
PopupUtils.open(Qt.resolvedUrl("../MusicaddtoPlaylist.qml"), mainView,
343
title: i18n.tr("Select playlist")
351
anchors.top: expandedBackground.top
352
anchors.left: playlistRow.left
353
anchors.leftMargin: units.gu(15)
355
height: expandedBackground.height
359
objectName: "albumsheet-queuetrack"
360
anchors.verticalCenter: parent.verticalCenter
361
source: "../images/queue.png"
362
height: styleMusic.common.expandedItem
363
width: styleMusic.common.expandedItem
366
anchors.left: queueTrack.right
367
anchors.leftMargin: units.gu(0.5)
368
anchors.verticalCenter: parent.verticalCenter
369
color: styleMusic.common.white
371
width: parent.width - queueTrack.width - units.gu(1)
372
text: i18n.tr("Add to queue")
373
wrapMode: Text.WordWrap
379
expandable.visible = false
380
track.height = isAlbum ? styleMusic.albums.itemHeight : styleMusic.common.albumSize + units.gu(2)
381
console.debug("Debug: Add track to queue: " + title)
382
trackQueue.model.append({"title": title, "artist": artist, "file": file, "album": album, "cover": cover, "genre": genre})
390
Component.onCompleted: {
393
sheetItem.file = model.file;
394
sheetItem.year = model.year;