Sayonara Player
Bookmarks.h
1 /* Bookmarks.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 BOOKMARKS_H
22 #define BOOKMARKS_H
23 
24 #include "Components/PlayManager/PlayState.h"
25 #include "Helper/Pimpl.h"
26 
27 #include <QObject>
28 #include <QList>
29 
30 class Bookmark;
31 class MetaData;
32 
37 class Bookmarks :
38  public QObject
39 {
40  Q_OBJECT
41  PIMPL(Bookmarks)
42 
43 signals:
48  void sig_bookmarks_changed();
49 
54  void sig_prev_changed(const Bookmark& bm);
55 
60  void sig_next_changed(const Bookmark& bm);
61 
62 public:
63 
64  explicit Bookmarks(QObject *parent=nullptr);
65  ~Bookmarks();
66 
72 
73 
74  enum class CreationStatus : quint8
75  {
76  Success,
77  AlreadyThere,
78  NoDBTrack,
79  DBError,
80  OtherError
81  };
82 
87  Bookmarks::CreationStatus create();
88 
94  bool jump_to(int idx);
95 
100  bool jump_next();
101 
106  bool jump_prev();
107 
113  bool remove(int idx);
114 
115 
121  bool set_loop(bool b);
122 
127  MetaData get_cur_track() const;
128 
129 
130  int get_size() const;
131 
132 
133 private slots:
138  void pos_changed_ms(quint64 pos);
139 
144  void track_changed(const MetaData& md);
145 
150  void playstate_changed(PlayState state);
151 
152 
153 private:
154 
158  void init_members();
159 
163  void reload_bookmarks();
164 
168  void sort_bookmarks();
169 };
170 
171 #endif // BOOKMARKS_H
Definition: Bookmark.h:32
QList< Bookmark > get_all_bookmarks() const
fetch all bookmarks for current track
bool jump_prev()
Jump to previous bookmark.
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
bool jump_next()
Jump to next bookmark.
void sig_prev_changed(const Bookmark &bm)
previous bookmark has changed
bool jump_to(int idx)
Jump to specific bookmark.
MetaData get_cur_track() const
get the current played track
bool set_loop(bool b)
tries to set the loop between the current two indices
void sig_next_changed(const Bookmark &bm)
next bookmark has changed
void sig_bookmarks_changed()
emitted when bookmarks have changed
Bookmarks::CreationStatus create()
create a new bookmark for current track and current position
The Bookmarks logic class.
Definition: Bookmarks.h:37
Definition: org_mpris_media_player2_adaptor.h:20
PlayState
The PlayState enum.
Definition: PlayState.h:30