Sayonara Player
AbstractPlaylist.h
1 /* Playlist.h */
2 
3 /* Copyright (C) 2011-2017 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 "Helper/typedefs.h"
26 #include "Helper/Playlist/PlaylistFwd.h"
27 #include "Helper/Playlist/PlaylistMode.h"
28 #include "Helper/Settings/SayonaraClass.h"
29 #include "Helper/Pimpl.h"
30 
31 #include <QString>
32 
33 class QStringList;
34 namespace SP
35 {
36  template<typename T>
37  class Set;
38 }
39 
40 class MetaDataList;
41 class MetaData;
47  public PlaylistDBInterface,
48  protected SayonaraClass
49 {
50  Q_OBJECT
51 
52  friend class PlaylistHandler;
53 
54 signals:
55  void sig_data_changed(int idx);
56 
57 private:
58  PIMPL(AbstractPlaylist)
59 
60 protected:
61  bool _is_storable;
62  int _playlist_idx;
63 
64  Playlist::Mode _playlist_mode;
65 
66  virtual void play()=0;
67  virtual void pause()=0;
68  virtual void stop()=0;
69  virtual void fwd()=0;
70  virtual void bwd()=0;
71  virtual void next()=0;
72 
73  virtual int create_playlist(const MetaDataList& v_md)=0;
74  virtual void replace_track(int idx, const MetaData& metadata);
75 
76  MetaDataList& metadata();
77  MetaData& metadata(int idx);
78 
79 
80 public:
81  explicit AbstractPlaylist(int idx, const QString& name=QString());
82  virtual ~AbstractPlaylist();
83 
84  QStringList toStringList() const;
85 
86  IdxList find_tracks(int id) const;
87  IdxList find_tracks(const QString& filepath) const;
88  int get_cur_track_idx() const;
89  bool get_cur_track(MetaData& metadata) const;
90  int get_idx() const;
91  void set_idx(int idx);
92  void set_playlist_mode(const Playlist::Mode& mode);
93  quint64 get_running_time() const;
94 
95  virtual Playlist::Type get_type() const = 0;
96 
97 
98  // from PlaylistDBInterface
99  virtual bool is_empty() const override;
100  virtual int get_count() const override;
101  virtual const MetaDataList& get_playlist() const override;
102 
103  virtual void set_changed(bool b) override;
104  virtual bool was_changed() const override;
105  virtual bool is_storable() const override;
106 
107 
108  const MetaData& operator[](int idx) const;
109  const MetaData& at_const_ref(int idx) const;
110 
111  virtual void clear();
112 
113  virtual void move_tracks(const SP::Set<int>& indexes, int tgt);
114 
115  virtual void copy_tracks(const SP::Set<int>& indexes, int tgt);
116 
117  virtual void delete_tracks(const SP::Set<int>& indexes);
118 
119  virtual void insert_track(const MetaData& metadata, int tgt);
120  virtual void insert_tracks(const MetaDataList& lst, int tgt);
121 
122  virtual void append_tracks(const MetaDataList& lst);
123 
124  virtual bool change_track(int idx)=0;
125 
126  virtual void metadata_deleted(const MetaDataList& v_md_deleted)=0;
127  virtual void metadata_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new)=0;
128  virtual void metadata_changed_single(const MetaData& metadata)=0;
129 
130 
131 private slots:
132  void _sl_playlist_mode_changed();
133 };
134 
135 #endif // PLAYLIST_H
The Mode class.
Definition: PlaylistMode.h:31
The MetaDataList class.
Definition: AbstractPlaylist.h:34
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class.
Definition: MetaData.h:55
void insert_tracks(const MetaDataList &v_md, int idx, int pl_idx)
insert tracks into a playlist at a given index
Definition: MetaDataList.h:39
Set namespace defines the setting: Which key and which type.
Definition: SettingKey.h:200
int create_playlist(const MetaDataList &v_md, const QString &name=QString(), bool temporary=true, Playlist::Type type=Playlist::Type::Std)
create a new playlist
The Playlist class.
Definition: AbstractPlaylist.h:46
void change_track(int track_idx, int pl_idx)
change the track in a given playlist
Global handler for playlists.
Definition: PlaylistHandler.h:57
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:33
void append_tracks(const MetaDataList &v_md, int pl_idx)
append tracks at a given playlist index
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:37