Sayonara Player
PlaylistHandler.h
1/* Playlist.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22/*
23 * Playlist.h
24 *
25 * Created on: Apr 6, 2011
26 * Author: Michael Lugmair (Lucio Carreras)
27 */
28
29#ifndef PLAYLISTHANDLER_H_
30#define PLAYLISTHANDLER_H_
31
32#include "PlaylistDBInterface.h"
33
34#include "Interfaces/PlaylistInterface.h"
35
36#include "Utils/Pimpl.h"
37#include "Utils/Playlist/PlaylistFwd.h"
38#include "Utils/Library/LibraryNamespaces.h"
39
40#include <QObject>
41
42class CustomPlaylist;
43class PlayManager;
44
45namespace Playlist
46{
47 class Loader;
52 class Handler :
53 public QObject,
54 public PlaylistCreator,
55 public PlaylistAccessor
56 {
57 Q_OBJECT
58 PIMPL(Handler)
59
60 public:
61 Handler(PlayManager* playManager, std::shared_ptr<::Playlist::Loader> playlistLoader);
62 ~Handler();
63
68 void shutdown();
69
74 int count() const override;
75
81 PlaylistPtr playlist(int playlistIndex) override;
82 PlaylistPtr playlistById(int playlistId) override;
83
84 int activeIndex() const override;
85 PlaylistPtr activePlaylist() override;
86
87 int currentIndex() const override;
88 void setCurrentIndex(int playlistIndex) override;
89
97 QString requestNewPlaylistName(const QString& prefix = QString()) const override;
98
107 int
108 createPlaylist(const MetaDataList& tracks, const QString& name = QString(), bool temporary = true) override;
109
118 int createPlaylist(const QStringList& pathList, const QString& name = QString(),
119 bool temporary = true) override;
120 int createCommandLinePlaylist(const QStringList& pathList) override;
121
127 int createPlaylist(const CustomPlaylist& customPlaylist) override;
128
134 int createEmptyPlaylist(bool override = false) override;
135
136 public slots:
141 void closePlaylist(int playlistIndex);
142
143 private:
144 int addNewPlaylist(const QString& name, bool editable);
145 int exists(const QString& name) const;
146
147 private slots:
148 void trackChanged(int oldIndex, int newIndex);
149 void previous();
150 void next();
151 void wakeUp();
152 void playstateChanged(PlayState state);
153 void wwwTrackFinished(const MetaData& track);
154 void playlistRenamed(int id, const QString& oldNamde, const QString& newName);
155 void playlistDeleted(int id);
156
157 signals:
162 void sigNewPlaylistAdded(int playlistIndex);
163
168 void sigPlaylistNameChanged(int playlistIndex);
169
174 void sigCurrentPlaylistChanged(int playlistIndex);
175 void sigActivePlaylistChanged(int playlistIndex);
176
183
184 void sigPlaylistClosed(int playlistIndex);
185 };
186}
187
188#endif /* PLAYLISTHANDLER_H_ */
Definition: CustomPlaylist.h:30
The MetaDataList class.
Definition: MetaDataList.h:39
The MetaData class.
Definition: MetaData.h:47
Global handler for current playback state (Singleton)
Definition: PlayManager.h:36
Definition: PlaylistInterface.h:39
Definition: PlaylistInterface.h:56
Global handler for playlists.
Definition: PlaylistHandler.h:56
int count() const override
Returns number of playlists.
int createPlaylist(const CustomPlaylist &customPlaylist) override
create a new playlist (overloaded)
QString requestNewPlaylistName(const QString &prefix=QString()) const override
Request a new name for the playlist (usually New %1 is returned). If the prefix differs,...
void sigTrackDeletionRequested(const MetaDataList &tracks, Library::TrackDeletionMode deletion_mode)
emitted when a track deletion was triggered over the Ui
PlaylistPtr playlist(int playlistIndex) override
get specific playlist at given index
int createPlaylist(const MetaDataList &tracks, const QString &name=QString(), bool temporary=true) override
create a new playlist
void sigNewPlaylistAdded(int playlistIndex)
emitted when new playlist has been added
int createEmptyPlaylist(bool override=false) override
create a new empty playlist
void shutdown()
Call this before the program stops. Singletons and Destructors don't work out so well.
int createPlaylist(const QStringList &pathList, const QString &name=QString(), bool temporary=true) override
create a new playlist (overloaded)
void closePlaylist(int playlistIndex)
close playlist
void sigPlaylistNameChanged(int playlistIndex)
emitted when playlist name has changed
void sigCurrentPlaylistChanged(int playlistIndex)
emitted when tracks were added/removed or have changed
TrackDeletionMode
The TrackDeletionMode enum.
Definition: LibraryNamespaces.h:37