Sayonara Player
Playlist.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 <QObject>
31 
32 namespace Playlist
33 {
38  class Playlist :
39  public QObject,
40  public DBInterface,
41  protected StopBehavior
42  {
43  Q_OBJECT
44  PIMPL(Playlist)
45 
46  friend class Handler;
47 
48  signals:
49  void sig_items_changed(int idx);
50  void sig_current_track_changed(int idx);
51  void sig_stopped();
52  void sig_find_track(TrackID track_id);
53  void sig_busy_changed(bool b);
54  void sig_current_scanned_file_changed(const QString& current_file);
55 
56  public:
57  explicit Playlist(int idx, Type type, const QString& name);
58  ~Playlist() override;
59 
60  int create_playlist(const MetaDataList& v_md);
61  int current_track_index() const;
62  bool current_track(MetaData& metadata) const;
63  int index() const;
64  void set_index(int idx);
65  Mode mode() const;
66  void set_mode(const Mode& mode);
67  MilliSeconds running_time() const;
68  int count() const override;
69 
70  void enable_all();
71 
72  void play();
73  void stop();
74  void fwd();
75  void bwd();
76  void next();
77  bool wake_up();
78 
79  void set_busy(bool b);
80  bool is_busy() const;
81 
82  void set_current_scanned_file(const QString& file);
83 
84  public:
85  MetaData track(int idx) const override;
86  MetaDataList tracks() const override;
87 
88  void insert_tracks(const MetaDataList& lst, int tgt);
89  void append_tracks(const MetaDataList& lst);
90  void remove_tracks(const IndexSet& indexes);
91  void replace_track(int idx, const MetaData& metadata);
92  void clear();
93 
94  IndexSet move_tracks(const IndexSet& indexes, int tgt);
95  IndexSet copy_tracks(const IndexSet& indexes, int tgt);
96 
97  void find_track(int idx);
98 
99  bool change_track(int idx);
100 
101  bool was_changed() const override;
102  bool is_storable() const override;
103 
104  public slots:
105  void metadata_deleted();
106  void metadata_changed();
107  void metadata_changed_single();
108  void duration_changed();
109 
110  private slots:
111  void setting_playlist_mode_changed();
112 
113  private:
114  int calc_shuffle_track();
115  void set_changed(bool b) override;
116  };
117 }
118 #endif // PLAYLIST_H
Playlist::Playlist
The Playlist class.
Definition: Playlist.h:38
Playlist::DBInterface
The PlaylistDBInterface class.
Definition: PlaylistDBInterface.h:36
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Playlist::StopBehavior
Definition: PlaylistStopBehavior.h:33
Playlist::Handler
Global handler for playlists.
Definition: PlaylistHandler.h:51
MetaData
The MetaData class.
Definition: MetaData.h:44
Playlist::Mode
The Mode class.
Definition: PlaylistMode.h:42
Gui::MimeData::metadata
MetaDataList metadata(const QMimeData *data)
metadata