File indexing completed on 2024-12-01 12:29:50

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #include "mediaplayertrack.h"
0010 
0011 #include <QVariant>
0012 
0013 namespace BluezQt
0014 {
0015 class MediaPlayerTrackPrivate
0016 {
0017 public:
0018     bool m_valid;
0019     QString m_title;
0020     QString m_artist;
0021     QString m_album;
0022     QString m_genre;
0023     quint32 m_numberOfTracks;
0024     quint32 m_trackNumber;
0025     quint32 m_duration;
0026 };
0027 
0028 MediaPlayerTrack::MediaPlayerTrack()
0029     : d(new MediaPlayerTrackPrivate)
0030 {
0031     d->m_valid = false;
0032     d->m_numberOfTracks = 0;
0033     d->m_trackNumber = 0;
0034     d->m_duration = 0;
0035 }
0036 
0037 MediaPlayerTrack::MediaPlayerTrack(const QVariantMap &properties)
0038     : d(new MediaPlayerTrackPrivate)
0039 {
0040     d->m_valid = !properties.isEmpty();
0041     d->m_title = properties.value(QStringLiteral("Title")).toString();
0042     d->m_artist = properties.value(QStringLiteral("Artist")).toString();
0043     d->m_album = properties.value(QStringLiteral("Album")).toString();
0044     d->m_genre = properties.value(QStringLiteral("Genre")).toString();
0045     d->m_numberOfTracks = properties.value(QStringLiteral("NumberOfTracks")).toUInt();
0046     d->m_trackNumber = properties.value(QStringLiteral("TrackNumber")).toUInt();
0047     d->m_duration = properties.value(QStringLiteral("Duration")).toUInt();
0048 }
0049 
0050 MediaPlayerTrack::~MediaPlayerTrack()
0051 {
0052 }
0053 
0054 MediaPlayerTrack::MediaPlayerTrack(const MediaPlayerTrack &other)
0055     : d(other.d)
0056 {
0057 }
0058 
0059 MediaPlayerTrack &MediaPlayerTrack::operator=(const MediaPlayerTrack &other)
0060 {
0061     if (d != other.d) {
0062         d = other.d;
0063     }
0064     return *this;
0065 }
0066 
0067 bool MediaPlayerTrack::isValid() const
0068 {
0069     return d->m_valid;
0070 }
0071 
0072 QString MediaPlayerTrack::title() const
0073 {
0074     return d->m_title;
0075 }
0076 
0077 QString MediaPlayerTrack::artist() const
0078 {
0079     return d->m_artist;
0080 }
0081 
0082 QString MediaPlayerTrack::album() const
0083 {
0084     return d->m_album;
0085 }
0086 
0087 QString MediaPlayerTrack::genre() const
0088 {
0089     return d->m_genre;
0090 }
0091 
0092 quint32 MediaPlayerTrack::numberOfTracks() const
0093 {
0094     return d->m_numberOfTracks;
0095 }
0096 
0097 quint32 MediaPlayerTrack::trackNumber() const
0098 {
0099     return d->m_trackNumber;
0100 }
0101 
0102 quint32 MediaPlayerTrack::duration() const
0103 {
0104     return d->m_duration;
0105 }
0106 
0107 } // namespace BluezQt