1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
19 #include "mlalbum.hpp"
21 MLAlbum::MLAlbum(vlc_medialibrary_t
* _ml
, const vlc_ml_album_t
*_data
, QObject
*_parent
)
23 , MLItem ( MLItemId( _data
->i_id
, VLC_ML_PARENT_ALBUM
) )
25 , m_title ( QString::fromUtf8( _data
->psz_title
) )
26 , m_releaseYear ( _data
->i_year
)
27 , m_shortSummary( QString::fromUtf8( _data
->psz_summary
) )
28 , m_cover ( QString::fromUtf8( _data
->thumbnails
[VLC_ML_THUMBNAIL_SMALL
].psz_mrl
) )
29 , m_mainArtist ( QString::fromUtf8( _data
->psz_artist
) )
30 , m_nbTracks ( _data
->i_nb_tracks
)
35 int t_sec
= _data
->i_duration
/ 1000;
37 int min
= (t_sec
/ 60) % 60;
38 int hour
= t_sec
/ 3600;
41 m_duration
= QString("%1:%2")
42 .arg(min
, 2, 10, QChar('0'))
43 .arg(sec
, 2, 10, QChar('0'));
44 m_durationShort
= m_duration
;
48 m_duration
= QString("%1:%2:%3")
49 .arg(hour
, 2, 10, QChar('0'))
50 .arg(min
, 2, 10, QChar('0'))
51 .arg(sec
, 2, 10, QChar('0'));
52 m_durationShort
= QString("%1h%2")
54 .arg(min
, 2, 10, QChar('0'));
58 //private ctor for cloning
59 MLAlbum::MLAlbum(const MLAlbum
& _album
, QObject
*_parent
)
61 , MLItem ( _album
.getId() )
62 , m_ml ( _album
.m_ml
)
63 , m_title ( _album
.m_title
)
64 , m_releaseYear ( _album
.m_releaseYear
)
65 , m_shortSummary( _album
.m_shortSummary
)
66 , m_cover ( _album
.m_cover
)
67 , m_mainArtist ( _album
.m_mainArtist
)
68 , m_nbTracks ( _album
.m_nbTracks
)
69 , m_duration ( _album
.m_duration
)
73 QString
MLAlbum::getTitle() const
78 unsigned int MLAlbum::getReleaseYear() const
83 QString
MLAlbum::getShortSummary() const
85 return m_shortSummary
;
88 QString
MLAlbum::getCover() const
94 QString
MLAlbum::getArtist() const
99 unsigned int MLAlbum::getNbTracks() const
104 QString
MLAlbum::getDuration() const
109 QString
MLAlbum::getDurationShort() const
111 return m_durationShort
;
114 MLAlbum
*MLAlbum::clone(QObject
*parent
) const
116 return new MLAlbum(*this, parent
);
119 QString
MLAlbum::getPresName() const
124 QString
MLAlbum::getPresImage() const
129 QString
MLAlbum::getPresInfo() const
131 return m_shortSummary
;