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
)
24 , m_id ( _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;
40 m_duration
= QString("%1:%2")
41 .arg(min
, 2, 10, QChar('0'))
42 .arg(sec
, 2, 10, QChar('0'));
44 m_duration
= QString("%1:%2:%3")
45 .arg(hour
, 2, 10, QChar('0'))
46 .arg(min
, 2, 10, QChar('0'))
47 .arg(sec
, 2, 10, QChar('0'));
50 //private ctor for cloning
51 MLAlbum::MLAlbum(const MLAlbum
& _album
, QObject
*_parent
)
53 , m_ml ( _album
.m_ml
)
54 , m_id ( _album
.m_id
)
55 , m_title ( _album
.m_title
)
56 , m_releaseYear ( _album
.m_releaseYear
)
57 , m_shortSummary( _album
.m_shortSummary
)
58 , m_cover ( _album
.m_cover
)
59 , m_mainArtist ( _album
.m_mainArtist
)
60 , m_nbTracks ( _album
.m_nbTracks
)
61 , m_duration ( _album
.m_duration
)
65 MLParentId
MLAlbum::getId() const
70 QString
MLAlbum::getTitle() const
75 unsigned int MLAlbum::getReleaseYear() const
80 QString
MLAlbum::getShortSummary() const
82 return m_shortSummary
;
85 QString
MLAlbum::getCover() const
91 QString
MLAlbum::getArtist() const
96 unsigned int MLAlbum::getNbTracks() const
101 QString
MLAlbum::getDuration() const
106 MLAlbum
*MLAlbum::clone(QObject
*parent
) const
108 return new MLAlbum(*this, parent
);
111 QString
MLAlbum::getPresName() const
116 QString
MLAlbum::getPresImage() const
121 QString
MLAlbum::getPresInfo() const
123 return m_shortSummary
;