Sayonara Player
Loading...
Searching...
No Matches
PlaylistHandler.h
1/* Playlist.h */
2
3/* Copyright (C) 2011-2024 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 SAYONARA_PLAYLISTHANDLER_H
30#define SAYONARA_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 LocalPathPlaylistCreator;
48 class Loader;
49 class Handler :
50 public QObject,
51 public PlaylistCreator,
52 public PlaylistAccessor
53 {
54 Q_OBJECT
55 PIMPL(Handler)
56
57 public:
58 Handler(PlayManager* playManager, const std::shared_ptr<::Playlist::Loader>& playlistLoader);
59 ~Handler() override;
60
61 void shutdown();
62
63 [[nodiscard]] int count() const override;
64
65 PlaylistPtr playlist(int playlistIndex) override;
66 PlaylistPtr playlistById(int playlistId) override;
67
68 [[nodiscard]] int activeIndex() const override;
69 PlaylistPtr activePlaylist() override;
70
71 [[nodiscard]] int currentIndex() const override;
72 void setCurrentIndex(int playlistIndex) override;
73
74 [[nodiscard]] QString requestNewPlaylistName(const QString& prefix = QString()) const override;
75
76 int
77 createPlaylist(const MetaDataList& tracks, const QString& name = QString(), bool temporary = true,
78 bool isLocked = false) override;
79
80 int createPlaylist(const QStringList& paths, const QString& name = QString(), bool temporary = true,
81 LocalPathPlaylistCreator* playlistFromPathCreator = nullptr) override;
82
83 int createPlaylist(const CustomPlaylist& playlist) override;
84 int createCommandLinePlaylist(const QStringList& pathList,
85 LocalPathPlaylistCreator* playlistFromPathCreator) override;
86
87 int createEmptyPlaylist(bool override = false) override;
88
89 public slots: // NOLINT(readability-redundant-access-specifiers)
90 void closePlaylist(int playlistIndex);
91
92 private:
93 int addNewPlaylist(const QString& name, bool editable);
94 [[nodiscard]] int exists(const QString& name) const;
95
96 private slots: // NOLINT(readability-redundant-access-specifiers)
97 void trackChanged(int oldIndex, int newIndex);
98 void previous();
99 void next();
100 void wakeUp();
101 void playstateChanged(PlayState state);
102 void wwwTrackFinished(const MetaData& track);
103 void playlistRenamed(int id, const QString& oldNamde, const QString& newName);
104 void playlistDeleted(int id);
105
106 signals:
107 void sigNewPlaylistAdded(int playlistIndex);
108 void sigPlaylistNameChanged(int playlistIndex);
109 void sigCurrentPlaylistChanged(int playlistIndex);
110 void sigActivePlaylistChanged(int playlistIndex);
111 void sigTrackDeletionRequested(const MetaDataList& tracks, Library::TrackDeletionMode deletion_mode);
112 void sigPlaylistClosed(int playlistIndex);
113 };
114}
115
116#endif /* SAYONARA_PLAYLISTHANDLER_H */
Definition CustomPlaylist.h:30
Definition MetaDataList.h:34
The MetaData class.
Definition MetaData.h:47
Definition PlayManager.h:34
Definition PlaylistInterface.h:40
Definition PlaylistInterface.h:57
Definition PlaylistHandler.h:53
Definition LocalPathPlaylistCreator.h:35