diff --git a/modules/gui/qt/playlist/playlist_controller.cpp b/modules/gui/qt/playlist/playlist_controller.cpp index ab2a81d0d8ffdd699b33864a552df7a38bb5ebb3..671d98df2e91d6c977d5a48f4ba2ef76529039f2 100644 --- a/modules/gui/qt/playlist/playlist_controller.cpp +++ b/modules/gui/qt/playlist/playlist_controller.cpp @@ -286,6 +286,7 @@ static const struct vlc_playlist_callbacks playlist_callbacks = { PlaylistControllerModelPrivate::PlaylistControllerModelPrivate(PlaylistControllerModel* playlistController) : q_ptr(playlistController) { + fillSortKeyTitleList(); } PlaylistControllerModelPrivate::~PlaylistControllerModelPrivate() @@ -807,6 +808,13 @@ bool PlaylistControllerModel::hasPrev() const return d->m_hasPrev; } +QVariantList PlaylistControllerModel::getSortKeyTitleList() const +{ + Q_D(const PlaylistControllerModel); + + return d->sortKeyTitleList; +} + } // namespace playlist } // namespace vlc diff --git a/modules/gui/qt/playlist/playlist_controller.hpp b/modules/gui/qt/playlist/playlist_controller.hpp index d285eded3d0ee8d07a046765b14c05a690cf46dc..27e37c1082671caf332095a41827e6152f0913ce 100644 --- a/modules/gui/qt/playlist/playlist_controller.hpp +++ b/modules/gui/qt/playlist/playlist_controller.hpp @@ -25,6 +25,8 @@ #include <QObject> #include <QVector> +#include <QVariantList> + #include "media.hpp" #include "playlist_common.hpp" #include "playlist_item.hpp" @@ -71,6 +73,8 @@ public: }; Q_ENUM(SortOrder) + Q_PROPERTY(QVariantList sortKeyTitleList READ getSortKeyTitleList CONSTANT) + Q_PROPERTY(PlaylistPtr playlistPtr READ getPlaylistPtr WRITE setPlaylistPtr NOTIFY playlistPtrChanged) Q_PROPERTY(PlaylistItem currentItem READ getCurrentItem NOTIFY currentItemChanged) @@ -122,6 +126,7 @@ public: PlaylistControllerModel(vlc_playlist_t *playlist, QObject *parent = nullptr); virtual ~PlaylistControllerModel(); + public slots: PlaylistItem getCurrentItem() const; @@ -146,6 +151,7 @@ public slots: void setSortOrder(SortOrder sortOrder); void switchSortOrder(); + QVariantList getSortKeyTitleList() const; PlaylistPtr getPlaylistPtr() const; void setPlaylistPtr(PlaylistPtr id); void setPlaylistPtr(vlc_playlist_t* newPlaylist); diff --git a/modules/gui/qt/playlist/playlist_controller_p.hpp b/modules/gui/qt/playlist/playlist_controller_p.hpp index 4fd22c974e815f264d1c491bd7ddd366d5150dad..8ecc26a6ba74c63ad12f5ad744695556332735a5 100644 --- a/modules/gui/qt/playlist/playlist_controller_p.hpp +++ b/modules/gui/qt/playlist/playlist_controller_p.hpp @@ -20,6 +20,8 @@ #include "playlist_controller.hpp" +#include "qt.hpp" // for qtr() + namespace vlc { namespace playlist { @@ -63,6 +65,29 @@ public: size_t m_count = 0; PlaylistControllerModel::SortKey m_sortKey = PlaylistControllerModel::SORT_KEY_NONE; PlaylistControllerModel::SortOrder m_sortOrder = PlaylistControllerModel::SORT_ORDER_ASC; + + QVariantList sortKeyTitleList; + +private: + inline void fillSortKeyTitleList() + { + auto filler = [this](PlaylistControllerModel::SortKey key, const QString& title) { + QVariantMap map; + map.insert("key", key); + map.insert("title", title); + sortKeyTitleList.push_back(map); + }; + + filler(PlaylistControllerModel::SORT_KEY_DURATION, qtr("Duration")); + filler(PlaylistControllerModel::SORT_KEY_ARTIST, qtr("Artist")); + filler(PlaylistControllerModel::SORT_KEY_ALBUM, qtr("Album")); + filler(PlaylistControllerModel::SORT_KEY_ALBUM_ARTIST, qtr( "Album Artist")); + filler(PlaylistControllerModel::SORT_KEY_GENRE, qtr("Genre")); + filler(PlaylistControllerModel::SORT_KEY_TRACK_NUMBER, qtr( "Track Number")); + filler(PlaylistControllerModel::SORT_KEY_DISC_NUMBER, qtr( "Disc Number")); + filler(PlaylistControllerModel::SORT_KEY_URL, qtr("URL")); + filler(PlaylistControllerModel::SORT_KEY_RATING, qtr("Rating")); + } }; } //namespace playlist