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 | |
13 | namespace BluezQt |
14 | { |
15 | class MediaPlayerTrackPrivate |
16 | { |
17 | public: |
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 | |
28 | MediaPlayerTrack::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 | |
37 | MediaPlayerTrack::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 | |
50 | MediaPlayerTrack::~MediaPlayerTrack() |
51 | { |
52 | } |
53 | |
54 | MediaPlayerTrack::MediaPlayerTrack(const MediaPlayerTrack &other) |
55 | : d(other.d) |
56 | { |
57 | } |
58 | |
59 | MediaPlayerTrack &MediaPlayerTrack::operator=(const MediaPlayerTrack &other) |
60 | { |
61 | if (d != other.d) { |
62 | d = other.d; |
63 | } |
64 | return *this; |
65 | } |
66 | |
67 | bool MediaPlayerTrack::isValid() const |
68 | { |
69 | return d->m_valid; |
70 | } |
71 | |
72 | QString MediaPlayerTrack::title() const |
73 | { |
74 | return d->m_title; |
75 | } |
76 | |
77 | QString MediaPlayerTrack::artist() const |
78 | { |
79 | return d->m_artist; |
80 | } |
81 | |
82 | QString MediaPlayerTrack::album() const |
83 | { |
84 | return d->m_album; |
85 | } |
86 | |
87 | QString MediaPlayerTrack::genre() const |
88 | { |
89 | return d->m_genre; |
90 | } |
91 | |
92 | quint32 MediaPlayerTrack::numberOfTracks() const |
93 | { |
94 | return d->m_numberOfTracks; |
95 | } |
96 | |
97 | quint32 MediaPlayerTrack::trackNumber() const |
98 | { |
99 | return d->m_trackNumber; |
100 | } |
101 | |
102 | quint32 MediaPlayerTrack::duration() const |
103 | { |
104 | return d->m_duration; |
105 | } |
106 | |
107 | } // namespace BluezQt |
108 |