Qmmp
playlistmanager.h
1 /***************************************************************************
2  * Copyright (C) 2009-2020 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 <QMap>
25 #include <qmmp/qmmp.h>
26 #include "playlistheadermodel.h"
27 #include "playlistmodel.h"
28 #include "qmmpui_export.h"
29 
30 class QTimer;
31 class QmmpUiSettings;
32 
36 class QMMPUI_EXPORT PlayListManager : public QObject
37 {
38 Q_OBJECT
39 public:
44  PlayListManager(QObject *parent);
48  ~PlayListManager();
52  static PlayListManager* instance();
56  QList <PlayListModel *> playLists() const;
60  QStringList playListNames() const;
64  PlayListModel *selectedPlayList() const;
68  PlayListModel *currentPlayList() const;
72  int selectedPlayListIndex() const;
76  int currentPlayListIndex() const;
80  int count() const;
84  int indexOf(PlayListModel *model) const;
89  PlayListModel *playListAt(int i) const;
93  PlayListHeaderModel *headerModel();
94 
95 signals:
101  void currentPlayListChanged (PlayListModel *current, PlayListModel *previous);
107  void selectedPlayListChanged (PlayListModel *selected, PlayListModel *previous);
111  void playListAdded(int index);
115  void playListRemoved(int index);
119  void playListMoved(int i, int j);
123  void playListsChanged();
124 
125 public slots:
129  void selectPlayList(PlayListModel *model);
133  void selectPlayList(int index);
137  void selectPlayList(const QString &name);
141  void selectNextPlayList();
145  void selectPreviousPlayList();
149  void activatePlayList(PlayListModel *model);
153  void activatePlayList(int index);
157  void activateSelectedPlayList();
161  PlayListModel *createPlayList(const QString &name = QString());
165  void removePlayList(PlayListModel *model);
169  void removePlayList(int index);
173  void move(int i, int j);
177  void clear();
181  void clearSelection();
185  void removeSelected();
189  void removeUnselected();
193  void removeTrack (int i);
197  void removeTrack (PlayListTrack *item);
201  void invertSelection();
205  void selectAll();
209  void showDetails();
213  void add(const QList<PlayListTrack *> &tracks);
217  void add(const QString &path);
221  void add(const QStringList &paths);
225  void randomizeList();
229  void reverseList();
233  void sortSelection(PlayListModel::SortMode mode);
237  void sort(PlayListModel::SortMode mode);
241  void addToQueue();
245  void removeInvalidTracks();
249  void removeDuplicates();
253  void refresh();
257  void clearQueue();
261  void stopAfterSelected();
262 
263 private slots:
264  void writePlayLists();
265  void onListChanged(int flags);
266 
267 private:
268  void readPlayLists();
269  static PlayListManager* m_instance;
270  QList <PlayListModel *> m_models;
271  PlayListModel *m_current;
272  PlayListModel *m_selected;
273  QTimer *m_timer;
274  PlayListHeaderModel *m_header;
275  QmmpUiSettings *m_ui_settings;
276  QMap<QString, Qmmp::TrackProperty> m_propKeys;
277  QMap<QString, Qmmp::MetaData> m_metaKeys;
278 };
279 
280 #endif // PLAYLISTMANAGER_H
Helper class that provides access to playlist column configuration.
Definition: playlistheadermodel.h:38
The PlayListModel class provides a data model for the playlist.
Definition: playlistmodel.h:103
The PlayListManager class is used to handle multiple playlists.
Definition: playlistmanager.h:36
The QmmpUiSettings class provides access to global libqmmpui library settings.
Definition: qmmpuisettings.h:36
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:36
SortMode
Definition: playlistmodel.h:319