Music Hub  ..
A session-wide music playback service
track.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2021-2022 UBports Foundation.
3  *
4  * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LOMIRI_MEDIAHUB_TRACK_H
20 #define LOMIRI_MEDIAHUB_TRACK_H
21 
22 #include "global.h"
23 
24 #include <QSharedData>
25 #include <QSharedDataPointer>
26 #include <QUrl>
27 #include <QVariantMap>
28 
29 namespace lomiri {
30 namespace MediaHub {
31 
32 class Track;
33 
34 class TrackData: public QSharedData
35 {
36 public:
37  TrackData(const QUrl &uri): m_uri(uri) {}
38 
39 private:
40  friend class Track;
41  QUrl m_uri;
42 };
43 
45 {
46 public:
47  struct MetaData: public QVariantMap
48  {
49  public:
50  using QVariantMap::QVariantMap;
51  MetaData(const QVariantMap &map = {}): QVariantMap(map) {}
52  static constexpr const char* TrackArtlUrlKey = "mpris:artUrl";
53  static constexpr const char* TrackLengthKey = "mpris:length";
54  static constexpr const char* TrackIdKey = "mpris:trackid";
55  };
56 
57  Track(const QUrl &uri = QUrl()): d(new TrackData(uri)) {}
58 
59  QUrl uri() const { return d->m_uri; }
60 
61 private:
62  QSharedDataPointer<TrackData> d;
63 };
64 
65 } // namespace MediaHub
66 } // namespace lomiri
67 
68 Q_DECLARE_METATYPE(lomiri::MediaHub::Track::MetaData)
69 
70 #endif // LOMIRI_MEDIAHUB_TRACK_H
global.h
lomiri::MediaHub::Track::MetaData
Definition: track.h:47
MH_EXPORT
#define MH_EXPORT
Definition: global.h:27
lomiri::MediaHub::TrackData
Definition: track.h:34
lomiri::MediaHub::Track::uri
QUrl uri() const
Definition: track.h:59
lomiri::MediaHub::Track
Definition: track.h:44
lomiri::MediaHub::Track::MetaData::MetaData
MetaData(const QVariantMap &map={})
Definition: track.h:51
lomiri::MediaHub::TrackData::TrackData
TrackData(const QUrl &uri)
Definition: track.h:37
lomiri
Definition: dbus_utils.h:24
QSharedData
lomiri::MediaHub::Track::Track
Track(const QUrl &uri=QUrl())
Definition: track.h:57