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 #include "Utils/Playlist/PlaylistFwd.h"
27 #include "Utils/Playlist/PlaylistMode.h"
28 #include "Utils/Pimpl.h"
29 
30 #include <QObject>
31 
32 namespace Playlist
33 {
38  class Playlist :
39  public QObject,
40  public DBInterface,
41  protected StopBehavior
42  {
43  Q_OBJECT
44  PIMPL(Playlist)
45 
46  friend class Handler;
47 
48  signals:
49  void sigItemsChanged(int idx);
50  void sigCurrentTrackChanged(int idx);
51  void sigStopped();
52  void sigFindTrack(TrackID trackId);
53  void sigBusyChanged(bool b);
54  void sigCurrentScannedFileChanged(const QString& currentFile);
55 
56  public:
57  explicit Playlist(int idx, const QString& name);
58  ~Playlist() override;
59 
60  int createPlaylist(const MetaDataList& tracks);
61  int currentTrackIndex() const;
62  bool currentTrack(MetaData& metadata) const;
63  int index() const;
64  void setIndex(int idx);
65  Mode mode() const;
66  void setMode(const Mode& mode);
67  MilliSeconds runningTime() const;
68  int count() const override;
69 
70  void enableAll();
71 
72  void play();
73  void stop();
74  void fwd();
75  void bwd();
76  void next();
77  bool wakeUp();
78 
79  void setBusy(bool b);
80  bool isBusy() const;
81 
82  void setCurrentScannedFile(const QString& file);
83  void reverse();
84 
85  public:
86  const MetaData& track(int idx) const override;
87  const MetaDataList& tracks() const override;
88 
89  void insertTracks(const MetaDataList& lst, int tgt);
90  void appendTracks(const MetaDataList& lst);
91  void removeTracks(const IndexSet& indexes);
92  void replaceTrack(int idx, const MetaData& track);
93  void clear();
94 
95  IndexSet moveTracks(const IndexSet& indexes, int tgt);
96  IndexSet copyTracks(const IndexSet& indexes, int tgt);
97 
98  void findTrack(int idx);
99 
100  bool changeTrack(int idx);
101 
102  bool wasChanged() const override;
103 
104  public slots:
105  void metadataDeleted();
106  void metadataChanged();
107  void currentMetadataChanged();
108  void durationChanged();
109 
110  private slots:
111  void settingPlaylistModeChanged();
112 
113  private:
114  int calcShuffleTrack();
115  void setCurrentTrack(int idx);
116  void setChanged(bool b) override;
117  };
118 }
119 #endif // PLAYLIST_H
Playlist::Playlist
The Playlist class.
Definition: Playlist.h:42
Playlist::DBInterface
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:37
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
Playlist::StopBehavior
Definition: PlaylistStopBehavior.h:34
Playlist::Handler
Global handler for playlists.
Definition: PlaylistHandler.h:53
MetaData
The MetaData class.
Definition: MetaData.h:47
Playlist::Mode
The Mode class.
Definition: PlaylistMode.h:42
Gui::MimeData::metadata
MetaDataList metadata(const QMimeData *data)
metadata