Sayonara Player
Bookmarks.h
1 /* Bookmarks.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 #ifndef BOOKMARKS_H
24 #define BOOKMARKS_H
25 
26 #include "Bookmark.h"
27 
28 #include "Components/PlayManager/PlayManager.h"
29 
30 #include <QPair>
31 #include <QList>
32 
33 class DatabaseConnector;
38 class Bookmarks : public QObject
39 {
40  Q_OBJECT
41 
42 signals:
47  void sig_bookmarks_changed(const QList<Bookmark>& bookmarks);
48 
53  void sig_prev_changed(const Bookmark& bm);
54 
59  void sig_next_changed(const Bookmark& bm);
60 
61 public:
62  Bookmarks(QObject *parent=nullptr);
63  virtual ~Bookmarks();
64 
70 
71 
76  bool save();
77 
83  bool jump_to(int idx);
84 
89  bool jump_next();
90 
95  bool jump_prev();
96 
102  bool remove(int idx);
103 
104 
109  bool remove_all();
110 
116  bool set_loop(bool b);
117 
122  MetaData get_cur_track() const;
123 
124 
125  int get_size() const;
126 
127 
128 
129 private slots:
134  void pos_changed_ms(quint64 pos);
135 
140  void track_changed(const MetaData& md);
141 
146  void playstate_changed(PlayManager::PlayState state);
147 
148 
149 private:
150  DatabaseConnector* _db=nullptr;
151  PlayManager* _play_manager=nullptr;
152 
153  QList<Bookmark> _bookmarks;
154  MetaData _md;
155 
156  quint32 _cur_time;
157  int _prev_idx;
158  int _next_idx;
159 
160  quint32 _loop_start;
161  quint32 _loop_end;
162 
163 
164 private:
165 
169  void init_members();
170 
174  void reload_bookmarks();
175 
179  void sort_bookmarks();
180 };
181 
182 #endif // BOOKMARKS_H
The Bookmark helper class.
Definition: Bookmark.h:32
QList< Bookmark > get_all_bookmarks() const
fetch all bookmarks for current track
bool jump_prev()
Jump to previous bookmark.
Definition: MetaData.h:49
PlayState
Current Playing state.
Definition: PlayManager.h:91
void sig_bookmarks_changed(const QList< Bookmark > &bookmarks)
emitted when bookmarks have changed
Definition: DatabaseConnector.h:40
bool jump_next()
Jump to next bookmark.
MetaData get_cur_track() const
get the current played track
void sig_prev_changed(const Bookmark &bm)
previous bookmark has changed
Global handler for current playback state (Singleton)
Definition: PlayManager.h:79
bool remove_all()
Remove all bookmarks from database for current track.
bool jump_to(int idx)
Jump to specific bookmark.
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
The Bookmarks logic class.
Definition: Bookmarks.h:38
bool save()
create a new bookmark for current track and current position