Qmmp
playlistmanager.h
1 /***************************************************************************
2  * Copyright (C) 2009-2017 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef PLAYLISTMANAGER_H
21 #define PLAYLISTMANAGER_H
22 
23 #include <QObject>
24 #include "playlistheadermodel.h"
25 #include "playlistmodel.h"
26 
27 class QTimer;
28 class QmmpUiSettings;
29 
33 class PlayListManager : public QObject
34 {
35 Q_OBJECT
36 public:
41  PlayListManager(QObject *parent);
49  static PlayListManager* instance();
53  QList <PlayListModel *> playLists() const;
57  QStringList playListNames() const;
69  int selectedPlayListIndex() const;
73  int currentPlayListIndex() const;
77  int count() const;
81  int indexOf(PlayListModel *model) const;
86  PlayListModel *playListAt(int i) const;
91 
92 signals:
98  void currentPlayListChanged (PlayListModel *current, PlayListModel *previous);
104  void selectedPlayListChanged (PlayListModel *selected, PlayListModel *previous);
108  void playListAdded(int index);
112  void playListRemoved(int index);
116  void playListMoved(int i, int j);
120  void playListsChanged();
121 
122 public slots:
126  void selectPlayList(PlayListModel *model);
130  void selectPlayList(int index);
134  void selectPlayList(const QString &name);
138  void selectNextPlayList();
142  void selectPreviousPlayList();
146  void activatePlayList(PlayListModel *model);
150  void activatePlayList(int index);
154  PlayListModel *createPlayList(const QString &name = QString());
158  void removePlayList(PlayListModel *model);
162  void removePlayList(int index);
166  void move(int i, int j);
170  void clear();
174  void clearSelection();
178  void removeSelected();
182  void removeUnselected();
186  void removeTrack (int i);
190  void removeTrack (PlayListTrack *item);
194  void invertSelection();
198  void selectAll();
202  void showDetails();
206  void add(const QString &path);
210  void add(const QStringList &paths);
214  void randomizeList();
218  void reverseList();
222  void sortSelection(int mode);
226  void sort(int mode);
230  void addToQueue();
234  void removeInvalidTracks();
238  void removeDuplicates();
242  void refresh();
246  void clearQueue();
250  void stopAfterSelected();
251 
252 private slots:
253  void writePlayLists();
254  void onListChanged(int flags);
255 
256 private:
257  void readPlayLists();
258  static PlayListManager* m_instance;
259  QList <PlayListModel *> m_models;
260  PlayListModel *m_current;
261  PlayListModel *m_selected;
262  QTimer *m_timer;
263  PlayListHeaderModel *m_header;
264  QmmpUiSettings *m_ui_settings;
265 };
266 
267 #endif // PLAYLISTMANAGER_H
Helper class that provides access to playlist column configuration.
Definition: playlistheadermodel.h:37
void removeDuplicates()
void selectNextPlayList()
void move(int i, int j)
The PlayListModel class provides a data model for the playlist.
Definition: playlistmodel.h:101
void removeTrack(int i)
void sortSelection(int mode)
void activatePlayList(PlayListModel *model)
void playListsChanged()
PlayListModel * playListAt(int i) const
void randomizeList()
int indexOf(PlayListModel *model) const
PlayListHeaderModel * headerModel()
static PlayListManager * instance()
int selectedPlayListIndex() const
void removePlayList(PlayListModel *model)
void sort(int mode)
void stopAfterSelected()
PlayListManager(QObject *parent)
void clearSelection()
void playListAdded(int index)
int currentPlayListIndex() const
void selectedPlayListChanged(PlayListModel *selected, PlayListModel *previous)
void playListRemoved(int index)
void invertSelection()
void playListMoved(int i, int j)
The PlayListManager class is used to handle multiple playlists.
Definition: playlistmanager.h:33
PlayListModel * selectedPlayList() const
void removeSelected()
void selectPlayList(PlayListModel *model)
void add(const QString &path)
PlayListModel * createPlayList(const QString &name=QString())
The QmmpUiSettings class provides access to global libqmmpui library settings.
Definition: qmmpuisettings.h:35
void selectPreviousPlayList()
int count() const
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:36
PlayListModel * currentPlayList() const
void removeInvalidTracks()
void currentPlayListChanged(PlayListModel *current, PlayListModel *previous)
void removeUnselected()
QStringList playListNames() const
QList< PlayListModel * > playLists() const