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 "Utils/Playlist/PlaylistFwd.h"
26 #include "Utils/Playlist/PlaylistMode.h"
27 #include "Utils/Settings/SayonaraClass.h"
28 #include "Utils/Pimpl.h"
29 
30 #include <QString>
31 
32 class QStringList;
33 namespace SP
34 {
35  template<typename T>
36  class Set;
37 }
38 
39 class MetaDataList;
40 class MetaData;
41 
42 namespace Playlist
43 {
48  class Base :
49  public DBInterface,
50  public SayonaraClass
51  {
52  Q_OBJECT
53  PIMPL(Base)
54 
55  friend class PlaylistHandler;
56 
57  signals:
58  void sig_data_changed(int idx);
59 
60  public:
61  explicit Base(int idx, const QString& name=QString());
62  virtual ~Base();
63 
64  QStringList toStringList() const;
65 
66  IdxList find_tracks(int id) const;
67  IdxList find_tracks(const QString& filepath) const;
68  int current_track_index() const;
69  bool current_track(MetaData& metadata) const;
70  int index() const;
71  void set_index(int idx);
72  void set_mode(const Playlist::Mode& mode);
73  uint64_t running_time() const;
74  Playlist::Mode mode() const;
75 
76  virtual
77  Playlist::Type type() const = 0;
78 
79 
80  // from PlaylistDBInterface
81  bool is_empty() const override;
82  int count() const override;
83  const MetaDataList& playlist() const override;
84 
85  void set_changed(bool b) override;
86  bool was_changed() const override;
87  bool is_storable() const override;
88 
89  virtual int create_playlist(const MetaDataList& v_md)=0;
90  virtual void replace_track(int idx, const MetaData& metadata);
91 
92  virtual void play()=0;
93  virtual void pause()=0;
94  virtual void stop()=0;
95  virtual void fwd()=0;
96  virtual void bwd()=0;
97  virtual void next()=0;
98  virtual bool wake_up()=0;
99 
100  protected:
101  void set_storable(bool b);
102 
103  public:
104  const MetaData& operator[](int idx) const;
105 
106  MetaData& metadata(int idx);
107  const MetaData& metadata(int idx) const;
108 
109  MetaDataList& metadata();
110  const MetaDataList& metadata() const;
111 
112  virtual void clear();
113 
114  virtual void move_tracks(const IndexSet& indexes, int tgt);
115 
116  virtual void copy_tracks(const IndexSet& indexes, int tgt);
117 
118  virtual void delete_tracks(const IndexSet& indexes);
119 
120  virtual void insert_track(const MetaData& metadata, int tgt);
121  virtual void insert_tracks(const MetaDataList& lst, int tgt);
122 
123  virtual void append_tracks(const MetaDataList& lst);
124 
125  virtual bool change_track(int idx);
126 
127  public slots:
128  virtual void metadata_deleted(const MetaDataList& v_md_deleted)=0;
129  virtual void metadata_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new)=0;
130  virtual void metadata_changed_single(const MetaData& metadata)=0;
131  virtual void duration_changed(uint64_t duration)=0;
132 
133 
134  private slots:
135  void _sl_playlist_mode_changed();
136  };
137 }
138 #endif // PLAYLIST_H
The Mode class.
Definition: PlaylistMode.h:32
The Playlist class.
Definition: AbstractPlaylist.h:48
Definition: AbstractPlaylist.h:33
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class.
Definition: MetaData.h:48
The MetaDataList class.
Definition: MetaDataList.h:38
Set namespace defines the setting: Which key and which type.
Definition: SettingKey.h:216
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:36
Definition: AbstractPlaylist.h:42
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:35