1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "mediaplayertrack.h"
10
11#include <QVariant>
12
13namespace BluezQt
14{
15class MediaPlayerTrackPrivate
16{
17public:
18 bool m_valid;
19 QString m_title;
20 QString m_artist;
21 QString m_album;
22 QString m_genre;
23 quint32 m_numberOfTracks;
24 quint32 m_trackNumber;
25 quint32 m_duration;
26};
27
28MediaPlayerTrack::MediaPlayerTrack()
29 : d(new MediaPlayerTrackPrivate)
30{
31 d->m_valid = false;
32 d->m_numberOfTracks = 0;
33 d->m_trackNumber = 0;
34 d->m_duration = 0;
35}
36
37MediaPlayerTrack::MediaPlayerTrack(const QVariantMap &properties)
38 : d(new MediaPlayerTrackPrivate)
39{
40 d->m_valid = !properties.isEmpty();
41 d->m_title = properties.value(QStringLiteral("Title")).toString();
42 d->m_artist = properties.value(QStringLiteral("Artist")).toString();
43 d->m_album = properties.value(QStringLiteral("Album")).toString();
44 d->m_genre = properties.value(QStringLiteral("Genre")).toString();
45 d->m_numberOfTracks = properties.value(QStringLiteral("NumberOfTracks")).toUInt();
46 d->m_trackNumber = properties.value(QStringLiteral("TrackNumber")).toUInt();
47 d->m_duration = properties.value(QStringLiteral("Duration")).toUInt();
48}
49
50MediaPlayerTrack::~MediaPlayerTrack()
51{
52}
53
54MediaPlayerTrack::MediaPlayerTrack(const MediaPlayerTrack &other)
55 : d(other.d)
56{
57}
58
59MediaPlayerTrack &MediaPlayerTrack::operator=(const MediaPlayerTrack &other)
60{
61 if (d != other.d) {
62 d = other.d;
63 }
64 return *this;
65}
66
67bool MediaPlayerTrack::isValid() const
68{
69 return d->m_valid;
70}
71
72QString MediaPlayerTrack::title() const
73{
74 return d->m_title;
75}
76
77QString MediaPlayerTrack::artist() const
78{
79 return d->m_artist;
80}
81
82QString MediaPlayerTrack::album() const
83{
84 return d->m_album;
85}
86
87QString MediaPlayerTrack::genre() const
88{
89 return d->m_genre;
90}
91
92quint32 MediaPlayerTrack::numberOfTracks() const
93{
94 return d->m_numberOfTracks;
95}
96
97quint32 MediaPlayerTrack::trackNumber() const
98{
99 return d->m_trackNumber;
100}
101
102quint32 MediaPlayerTrack::duration() const
103{
104 return d->m_duration;
105}
106
107} // namespace BluezQt
108

source code of bluez-qt/src/mediaplayertrack.cpp