Sayonara Player
Playlist.h
1 /* Playlist.h */
2 
3 /* Copyright (C) 2011-2019 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 sig_items_changed(int idx);
50  void sig_current_track_changed(int idx);
51  void sig_stopped();
52  void sig_find_track(TrackID track_id);
53 
54  public:
55  explicit Playlist(int idx, Type type, const QString& name);
56  ~Playlist();
57 
58  int create_playlist(const MetaDataList& v_md);
59  int current_track_index() const;
60  bool current_track(MetaData& metadata) const;
61  int index() const;
62  void set_index(int idx);
63  Mode mode() const;
64  void set_mode(const Mode& mode);
65  MilliSeconds running_time() const;
66  int count() const override;
67 
68  void enable_all();
69 
70  void play();
71  void stop();
72  void fwd();
73  void bwd();
74  void next();
75  bool wake_up();
76 
77  public:
78  MetaData track(int idx) const override;
79  MetaDataList tracks() const override;
80 
81  void insert_tracks(const MetaDataList& lst, int tgt);
82  void append_tracks(const MetaDataList& lst);
83  void remove_tracks(const IndexSet& indexes);
84  void replace_track(int idx, const MetaData& metadata);
85  void clear();
86 
87  IndexSet move_tracks(const IndexSet& indexes, int tgt);
88  IndexSet copy_tracks(const IndexSet& indexes, int tgt);
89 
90  void find_track(int idx);
91 
92  bool change_track(int idx);
93 
94  bool was_changed() const override;
95  bool is_storable() const override;
96 
97  public slots:
98  void metadata_deleted();
99  void metadata_changed();
100  void metadata_changed_single();
101  void duration_changed();
102 
103  private slots:
104  void setting_playlist_mode_changed();
105 
106  private:
107  int calc_shuffle_track();
108  void set_changed(bool b) override;
109  };
110 }
111 #endif // PLAYLIST_H
The Mode class.
Definition: PlaylistMode.h:42
MetaDataList metadata(const QMimeData *data)
metadata
Global handler for playlists.
Definition: PlaylistHandler.h:51
The MetaData class.
Definition: MetaData.h:44
The MetaDataList class.
Definition: MetaDataList.h:37
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Definition: PlaylistStopBehavior.h:33
The Playlist class.
Definition: Playlist.h:38
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:36