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