Qmmp
playlistmanager.h
1 /***************************************************************************
2  * Copyright (C) 2009-2022 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 <QHash>
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  explicit PlayListManager(QObject *parent);
56  QList <PlayListModel *> playLists() const;
60  QStringList playListNames() 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;
94 
95 signals:
111  void playListAdded(int index);
115  void playListRemoved(int index);
119  void playListMoved(int i, int j);
124 
125 public slots:
133  void selectPlayList(int index);
137  void selectPlayList(const QString &name);
153  void activatePlayList(int index);
161  PlayListModel *createPlayList(const QString &name = QString());
169  void removePlayList(int index);
173  void move(int i, int j);
177  void clear();
193  void removeTrack (int i);
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);
229  void reverseList();
241  void addToQueue();
253  void refresh();
257  void clearQueue();
262 
263 private slots:
264  void writePlayLists();
265  void onListChanged(int flags);
266 
267 private:
268  void readPlayLists();
269 
270  static PlayListManager* m_instance;
271  static const QHash<QString, Qmmp::MetaData> m_metaKeys;
272  static const QHash<QString, Qmmp::TrackProperty> m_propKeys;
273  QList <PlayListModel *> m_models;
274  PlayListModel *m_current = nullptr;
275  PlayListModel *m_selected = nullptr;
276  QTimer *m_timer;
277  PlayListHeaderModel *m_header;
278  QmmpUiSettings *m_ui_settings;
279 };
280 
281 #endif // PLAYLISTMANAGER_H
Helper class that provides access to playlist column configuration.
Definition: playlistheadermodel.h:39
The PlayListManager class is used to handle multiple playlists.
Definition: playlistmanager.h:37
static PlayListManager * instance()
int count() const
void selectPlayList(PlayListModel *model)
void playListAdded(int index)
void removeUnselected()
void removeDuplicates()
void sortSelection(PlayListModel::SortMode mode)
void add(const QString &path)
void playListMoved(int i, int j)
void currentPlayListChanged(PlayListModel *current, PlayListModel *previous)
void sort(PlayListModel::SortMode mode)
void move(int i, int j)
PlayListModel * currentPlayList() const
void activatePlayList(PlayListModel *model)
void selectNextPlayList()
void removeInvalidTracks()
PlayListHeaderModel * headerModel()
PlayListManager(QObject *parent)
void selectPlayList(const QString &name)
QStringList playListNames() const
void randomizeList()
void removePlayList(int index)
void removeTrack(int i)
void add(const QStringList &paths)
void removeTrack(PlayListTrack *item)
int selectedPlayListIndex() const
QList< PlayListModel * > playLists() const
int currentPlayListIndex() const
void playListRemoved(int index)
void selectPlayList(int index)
PlayListModel * playListAt(int i) const
void playListsChanged()
void clearSelection()
void activatePlayList(int index)
PlayListModel * selectedPlayList() const
int indexOf(PlayListModel *model) const
void stopAfterSelected()
void invertSelection()
void selectedPlayListChanged(PlayListModel *selected, PlayListModel *previous)
void add(const QList< PlayListTrack * > &tracks)
PlayListModel * createPlayList(const QString &name=QString())
void activateSelectedPlayList()
void selectPreviousPlayList()
void removeSelected()
void removePlayList(PlayListModel *model)
The PlayListModel class provides a data model for the playlist.
Definition: playlistmodel.h:97
SortMode
Definition: playlistmodel.h:309
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:37
The QmmpUiSettings class provides access to global libqmmpui library settings.
Definition: qmmpuisettings.h:37