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