Sayonara Player
Playlist.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#ifndef PLAYLIST_H
22#define PLAYLIST_H
23
24#include "PlaylistDBInterface.h"
25#include "PlaylistStopBehavior.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
34class PlayManager;
35
36namespace Playlist
37{
42 class Playlist :
43 public QObject,
44 public DBInterface,
45 protected StopBehavior
46 {
47 Q_OBJECT
48 PIMPL(Playlist)
49
50 friend class Handler;
51
52 signals:
53 void sigFindTrackRequested(const MetaData& track);
54 void sigDeleteFilesRequested(const MetaDataList& tracks);
55
56 void sigItemsChanged(int index);
57 void sigTrackChanged(int oldIndex, int newIndex);
58 void sigStopped();
59 void sigBusyChanged(bool b);
60 void sigCurrentScannedFileChanged(const QString& currentFile);
61
62 public:
63 explicit Playlist(int idx, const QString& name, PlayManager* playManager);
64 virtual ~Playlist() override;
65
66 int createPlaylist(const MetaDataList& tracks);
67
68 virtual int currentTrackIndex() const;
69 bool currentTrack(MetaData& track) const;
70
71 int index() const;
72 void setIndex(int idx);
73
74 Mode mode() const;
75 void setMode(const Mode& mode);
76
77 MilliSeconds runningTime() const;
78 int count() const override;
79
80 void enableAll();
81
82 void play();
83 void stop();
84 void fwd();
85 void bwd();
86 void next();
87 bool wakeUp();
88
89 void setBusy(bool b);
90 bool isBusy() const;
91
92 void reverse();
93
94 const MetaData& track(int index) const override;
95 const MetaDataList& tracks() const override;
96
97 void insertTracks(const MetaDataList& tracks, int targetIndex);
98 void appendTracks(const MetaDataList& tracks);
99 void removeTracks(const IndexSet& indexes);
100 void replaceTrack(int idx, const MetaData& track);
101 void clear();
102
103 IndexSet moveTracks(const IndexSet& index, int targetRow);
104 IndexSet copyTracks(const IndexSet& indexes, int tgt);
105
106 void findTrack(int idx);
107 bool changeTrack(int index, MilliSeconds positionMs=0);
108 bool wasChanged() const override;
109
110 void reloadFromDatabase();
111 void deleteTracks(const IndexSet& indexes);
112
113 public slots:
114 void metadataDeleted();
115 void metadataChanged();
116 void currentMetadataChanged();
117 void durationChanged();
118
119 private slots:
120 void settingPlaylistModeChanged();
121
122 private:
123 int calcShuffleTrack();
124 void setCurrentTrack(int index);
125 void setChanged(bool b) override;
126 };
127}
128#endif // PLAYLIST_H
The MetaDataList class.
Definition: MetaDataList.h:37
The MetaData class.
Definition: MetaData.h:47
Global handler for current playback state (Singleton)
Definition: PlayManager.h:36
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:37
Global handler for playlists.
Definition: PlaylistHandler.h:56
The Mode class.
Definition: PlaylistMode.h:42
The Playlist class.
Definition: Playlist.h:46
Definition: PlaylistStopBehavior.h:34
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37