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