Music Hub ..
A session-wide music playback service
Loading...
Searching...
No Matches
track_list_implementation.h
Go to the documentation of this file.
1/*
2 * Copyright © 2013-2015 Canonical Ltd.
3 * Copyright © 2022 UBports Foundation.
4 *
5 * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License version 3,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authored by: Thomas Voß <thomas.voss@canonical.com>
20 */
21
22#ifndef LOMIRI_MEDIAHUBSERVICE_TRACK_LIST_IMPLEMENTATION_H
23#define LOMIRI_MEDIAHUBSERVICE_TRACK_LIST_IMPLEMENTATION_H
24
25#include "engine.h"
26#include "track.h"
27
28#include <QObject>
29#include <QScopedPointer>
30#include <QVector>
31
32namespace lomiri
33{
34namespace MediaHubService
35{
36
37namespace TrackList
38{
39 struct Errors
40 {
41 Errors() = delete;
42
43 struct ExceptionBase: public std::runtime_error {
44 ExceptionBase(const QString &msg = {}):
45 std::runtime_error(msg.toStdString()) {}
46 };
47
51
55
59
63
67 };
68
69 typedef QVector<Track::Id> Container;
70 typedef Container::ConstIterator ConstIterator;
71} // namespace TrackList
72
75{
76 Q_OBJECT
77
78public:
80 const QSharedPointer<Engine::MetaDataExtractor> &extractor,
81 QObject *parent = nullptr);
83
86
87 void setShuffle(bool shuffle);
88 bool shuffle() const;
89
90 void setCurrentPosition(uint64_t position);
91
92 bool canEditTracks() const;
93
94 QUrl query_uri_for_track(const Track::Id& id);
96
97 static const Track::Id &afterEmptyTrack();
98 void add_track_with_uri_at(const QUrl &uri, const Track::Id& position, bool make_current);
99 void add_tracks_with_uri_at(const QVector<QUrl> &uris, const Track::Id& position);
100 bool move_track(const Track::Id& id, const Track::Id& to);
101 void remove_track(const Track::Id& id);
102
103 void go_to(const Track::Id& track);
105 void reset();
106 const TrackList::Container &tracks() const;
107
108 bool hasNext() const;
109 bool hasPrevious() const;
110 Track::Id next();
112 const Track::Id& current() const;
113
114Q_SIGNALS:
116 void onGoToTrack(const Track::Id &id);
117 void trackAdded(const Track::Id &id);
118 void tracksAdded(const QVector<QUrl> &tracks);
119 void trackRemoved(const Track::Id &id);
120 void trackMoved(const Track::Id &id,
121 const Track::Id &to);
123 void trackChanged(const Track::Id &id);
124 void trackListReplaced(const QVector<Track::Id> &tracks,
125 const Track::Id &currentTrack);
126
127private:
128 Q_DECLARE_PRIVATE(TrackListImplementation)
129 QScopedPointer<TrackListImplementationPrivate> d_ptr;
130};
131
132}
133}
134
135#endif // LOMIRI_MEDIAHUBSERVICE_TRACK_LIST_IMPLEMENTATION_H
void add_tracks_with_uri_at(const QVector< QUrl > &uris, const Track::Id &position)
Track::MetaData query_meta_data_for_track(const Track::Id &id)
void tracksAdded(const QVector< QUrl > &tracks)
void trackMoved(const Track::Id &id, const Track::Id &to)
void trackListReplaced(const QVector< Track::Id > &tracks, const Track::Id &currentTrack)
TrackListImplementation(const QSharedPointer< Engine::MetaDataExtractor > &extractor, QObject *parent=nullptr)
void add_track_with_uri_at(const QUrl &uri, const Track::Id &position, bool make_current)
bool move_track(const Track::Id &id, const Track::Id &to)