Sayonara Player
Playlist.h
1 /* Playlist.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 #ifndef PLAYLIST_H
24 #define PLAYLIST_H
25 
26 #include "Helper/Playlist/PlaylistMode.h"
27 #include "Helper/Settings/SayonaraClass.h"
28 #include "PlaylistDBInterface.h"
29 
30 #include <QString>
31 #include <QList>
32 #include <memory>
33 
38 class Playlist :
39  public PlaylistDBInterface,
40  protected SayonaraClass
41 {
42 
43  Q_OBJECT
44 
45  friend class PlaylistHandler;
46 
47 signals:
48  void sig_data_changed(int idx);
49 
50 public:
51 
52  enum class Type : quint8
53  {
54  Std=0,
55  Stream
56  };
57 
58 private:
59  bool _playlist_changed;
60 
61 
62 protected:
63 
64  bool _is_storable;
65  int _playlist_idx;
66 
67  MetaDataList _v_md;
68  Type _playlist_type;
69  PlaylistMode _playlist_mode;
70 
71  Playlist(int idx, QString name="");
72  virtual ~Playlist();
73 
74  virtual void play()=0;
75  virtual void pause()=0;
76  virtual void stop()=0;
77  virtual void fwd()=0;
78  virtual void bwd()=0;
79  virtual void next()=0;
80 
81  virtual int create_playlist(const MetaDataList& v_md)=0;
82 
83  virtual void replace_track(int idx, const MetaData& md);
84 
85 public:
86 
87  QStringList toStringList() const;
88 
89  IdxList find_tracks(int id) const;
90  IdxList find_tracks(const QString& filepath) const;
91 
92  Type get_type() const;
93  int get_cur_track_idx() const;
94  bool get_cur_track(MetaData& md) const;
95  int get_idx() const;
96  void set_idx(int idx);
97  PlaylistMode get_playlist_mode() const;
98  void set_playlist_mode(const PlaylistMode& mode);
99  quint64 get_running_time() const;
100 
101 
102  // from PlaylistDBInterface
103  virtual bool is_empty() const override;
104  virtual int get_count() const override;
105  virtual const MetaDataList& get_playlist() const override;
106 
107  virtual void set_changed(bool b) override;
108  virtual bool was_changed() const override;
109  virtual bool is_storable() const override;
110 
111 
112 
113  const MetaData& operator[](int idx) const{
114  return _v_md[idx];
115  }
116 
117  const MetaData& at_const_ref(int idx) const {
118  return _v_md[idx];
119  }
120 
121  MetaData& at_ref(int idx) {
122  return _v_md[idx];
123  }
124 
125 
126  virtual void clear();
127 
128  virtual void move_track(const int idx, int tgt);
129  virtual void move_tracks(const SP::Set<int>& indexes, int tgt);
130 
131  virtual void copy_track(const int idx, int tgt);
132  virtual void copy_tracks(const SP::Set<int>& indexes, int tgt);
133 
134  virtual void delete_track(const int idx);
135  virtual void delete_tracks(const SP::Set<int>& indexes);
136 
137  virtual void insert_track(const MetaData& md, int tgt);
138  virtual void insert_tracks(const MetaDataList& lst, int tgt);
139 
140  virtual void append_track(const MetaData& md);
141  virtual void append_tracks(const MetaDataList& lst);
142 
143  virtual bool change_track(int idx)=0;
144 
145  virtual void metadata_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new)=0;
146  virtual void metadata_changed_single(const MetaData& md)=0;
147 
148 
149 private slots:
150  void _sl_playlist_mode_changed();
151 };
152 
153 
157 typedef std::shared_ptr<Playlist> PlaylistPtr;
158 
162 typedef std::shared_ptr<const Playlist> PlaylistConstPtr;
163 
164 
165 
166 
167 #endif // PLAYLIST_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: MetaData.h:49
Definition: MetaDataList.h:44
Definition: PlaylistMode.h:32
Global handler for playlists.
Definition: PlaylistHandler.h:47
The Playlist class.
Definition: Playlist.h:38
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:34