// SPDX-FileCopyrightText: 2022 Gary Wang // // SPDX-License-Identifier: MIT #pragma once #include class PlaylistManager : public QObject { Q_OBJECT public: Q_PROPERTY(int currentIndex MEMBER m_currentIndex NOTIFY currentIndexChanged) enum PlaylistType { PL_USERPLAYLIST, // Regular playlist, managed by user. PL_SAMEFOLDER // PlaylistManager managed playlist, loaded from files from same folder. }; explicit PlaylistManager(PlaylistType type = PL_USERPLAYLIST, QObject *parent = nullptr); ~PlaylistManager(); void setPlaylistType(PlaylistType type); PlaylistType playlistType() const; QStringList autoLoadFilterSuffix() const; void setAutoLoadFilterSuffix(const QStringList &nameFilters); void clear(); void setPlaylist(const QList & urls); void setCurrentFile(const QString & filePath); void setCurrentIndex(int index); int appendFile(const QString & filePath); void removeFileAt(int index); int indexOf(const QString & filePath); int count() const; std::tuple previousFile() const; std::tuple nextFile() const; std::tuple currentFile() const; std::tuple currentFileUrl() const; static QList convertToUrlList(const QStringList & files); signals: void loaded(int length); void currentIndexChanged(int index); private: QList m_playlist; PlaylistType m_type; QString m_currentDir; int m_currentIndex = -1; QStringList m_autoLoadSuffix = {}; };