Sayonara Player
Loading...
Searching...
No Matches
Playlist.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#ifndef SAYONARA_COMPONENTS_PLAYLIST
22#define SAYONARA_COMPONENTS_PLAYLIST
23
24#include "PlaylistDBInterface.h"
25#include "PlaylistModifiers.h"
26
27#include "Utils/Playlist/PlaylistFwd.h"
28#include "Utils/Playlist/PlaylistMode.h"
29
30#include "Utils/Pimpl.h"
31
32#include <QObject>
33#include <functional>
34#include <optional>
35
36class PlayManager;
37class MetaDataList;
38
39namespace Playlist
40{
41 class Playlist :
42 public QObject,
43 public DBInterface
44 {
45 Q_OBJECT
46 PIMPL(Playlist)
47
48 friend class Handler;
49
50 signals:
51 void sigItemsChanged(int index);
52 void sigTrackChanged(int oldIndex, int newIndex);
53 void sigBusyChanged(bool b);
54 void sigCurrentScannedFileChanged(const QString& currentFile);
55
56 public:
57 explicit Playlist(int playlistIndex, const QString& name, PlayManager* playManager);
58 ~Playlist() override;
59
60 int createPlaylist(const MetaDataList& tracks);
61
62 [[nodiscard]] int currentTrackIndex() const;
63
64 [[nodiscard]] int index() const;
65 void setIndex(int idx);
66
67 [[nodiscard]] Mode mode() const;
68 void setMode(const Mode& mode);
69
70 void play();
71 void stop();
72 void fwd();
73 void bwd();
74 void next();
75 bool wakeUp();
76
77 [[nodiscard]] bool isBusy() const;
78 void setBusy(bool b);
79
80 [[nodiscard]] const MetaDataList& tracks() const override;
81
82 bool changeTrack(int index, MilliSeconds positionMs = 0);
83
84 [[nodiscard]] bool wasChanged() const override;
85 void resetChangedStatus();
86
87 using Modificator = std::function<MetaDataList(MetaDataList)>;
88 void modifyTracks(Modificator&& modificator, Reason reason, Operation operation);
89
90 protected:
91 void setChanged(bool b) override;
92
93 private slots:
94 void metadataChanged();
95 void metadataDeleted();
96 void settingPlaylistModeChanged();
97 void currentMetadataChanged();
98 void durationChanged();
99
100 private:
101 void replaceTrack(int index, const MetaData& track);
102 void setCurrentTrack(int index);
103 };
104}
105
106#endif // SAYONARA_COMPONENTS_PLAYLIST
Definition: MetaDataList.h:34
The MetaData class.
Definition: MetaData.h:47
Definition: PlayManager.h:34
Definition: PlaylistDBInterface.h:35
Definition: PlaylistHandler.h:53
The Mode class.
Definition: PlaylistMode.h:42
Definition: Playlist.h:44