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