BluezQt

mediaplayertrack.cpp
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2015 David Rosca <[email protected]>
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 
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 
51 {
52 }
53 
55  : d(other.d)
56 {
57 }
58 
60 {
61  if (d != other.d) {
62  d = other.d;
63  }
64  return *this;
65 }
66 
68 {
69  return d->m_valid;
70 }
71 
73 {
74  return d->m_title;
75 }
76 
78 {
79  return d->m_artist;
80 }
81 
83 {
84  return d->m_album;
85 }
86 
88 {
89  return d->m_genre;
90 }
91 
93 {
94  return d->m_numberOfTracks;
95 }
96 
98 {
99  return d->m_trackNumber;
100 }
101 
103 {
104  return d->m_duration;
105 }
106 
107 } // namespace BluezQt
quint32 numberOfTracks() const
Returns a total number of tracks.
QString title() const
Returns a title of the track.
quint32 duration() const
Returns a duration of the track.
virtual ~MediaPlayerTrack()
Destroys a MediaPlayerTrack object.
MediaPlayerTrack & operator=(const MediaPlayerTrack &other)
Copy assignment operator.
QString genre() const
Returns a genre of the track.
QString album() const
Returns an album of the track.
quint32 trackNumber() const
Returns a track number of the track.
MediaPlayerTrack()
Creates a new invalid MediaPlayerTrack object.
QString artist() const
Returns an artist of the track.
bool isValid() const
Returns whether the track is valid.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.