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#include "PlaylistInterface.h"
34
35#include "Utils/Pimpl.h"
36#include "Utils/Playlist/PlaylistFwd.h"
37#include "Utils/Library/LibraryNamespaces.h"
38
39#include <QObject>
40
41class CustomPlaylist;
42class PlayManager;
43
44namespace Util
45{
46 class FileSystem;
47}
48
49namespace Playlist
50{
51 class LocalPathPlaylistCreator;
52 class Loader;
53 class Handler :
54 public QObject,
55 public Creator,
56 public Accessor
57 {
58 Q_OBJECT
59 PIMPL(Handler)
60
61 public:
62 Handler(PlayManager* playManager, const std::shared_ptr<Loader>& playlistLoader,
63 const std::shared_ptr<Util::FileSystem>& fileSystem);
64 ~Handler() override;
65
66 void shutdown();
67
68 [[nodiscard]] int count() const override;
69
70 PlaylistPtr playlist(int playlistIndex) override;
71 PlaylistPtr playlistById(int playlistId) override;
72
73 [[nodiscard]] int activeIndex() const override;
74
75 [[nodiscard]] int currentIndex() const override;
76 void setCurrentIndex(int playlistIndex) override;
77
78 [[nodiscard]] QString requestNewPlaylistName(const QString& prefix = QString()) const override;
79
80 int
81 createPlaylist(const MetaDataList& tracks, const QString& name = QString(), bool temporary = true,
82 bool isLocked = false) override;
83
84 int createPlaylist(const QStringList& paths, const QString& name = QString(), bool temporary = true,
85 LocalPathPlaylistCreator* playlistFromPathCreator = nullptr) override;
86
87 int createPlaylist(const CustomPlaylist& playlist) override;
88 int createCommandLinePlaylist(const QStringList& pathList,
89 LocalPathPlaylistCreator* playlistFromPathCreator) override;
90
91 int createEmptyPlaylist(bool override = false) override;
92
93 public slots: // NOLINT(readability-redundant-access-specifiers)
94 void closePlaylist(int playlistIndex);
95
96 private:
97 int addNewPlaylist(const QString& name, bool editable, bool overwriteLocked);
98 [[nodiscard]] int exists(const QString& name) const;
99
100 private slots: // NOLINT(readability-redundant-access-specifiers)
101 void trackChanged(int oldIndex, int newIndex);
102 void previous();
103 void next();
104 void wakeUp();
105 void playstateChanged(PlayState state);
106 void wwwTrackFinished(const MetaData& track);
107 void playlistRenamed(int id, const QString& oldNamde, const QString& newName);
108 void playlistDeleted(int id);
109
110 signals:
111 void sigNewPlaylistAdded(int playlistIndex);
112 void sigPlaylistNameChanged(int playlistIndex);
113 void sigCurrentPlaylistChanged(int playlistIndex);
114 void sigActivePlaylistChanged(int playlistIndex);
115 void sigTrackDeletionRequested(const MetaDataList& tracks, Library::TrackDeletionMode deletion_mode);
116 void sigPlaylistClosed(int playlistIndex);
117 };
118}
119
120#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:43
Definition: PlaylistInterface.h:59
Definition: PlaylistHandler.h:57
Definition: LocalPathPlaylistCreator.h:36
Helper functions.
Definition: MetaTypeRegistry.h:25