[vlc-commits] qt: add SortKey-Title map list for playlist
Fatih Uzunoglu
git at videolan.org
Tue Jan 12 13:20:18 UTC 2021
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Jan 8 00:36:21 2021 +0300| [ac62c3e6cf21d8c40f6fc9353a996e1b0b4b4664] | committer: Pierre Lamot
qt: add SortKey-Title map list for playlist
This patch enables getting a list of sorting keys with titles as a valid model so that there won't be redefinition on the QML side.
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac62c3e6cf21d8c40f6fc9353a996e1b0b4b4664
---
modules/gui/qt/playlist/playlist_controller.cpp | 8 ++++++++
modules/gui/qt/playlist/playlist_controller.hpp | 6 ++++++
modules/gui/qt/playlist/playlist_controller_p.hpp | 25 +++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/modules/gui/qt/playlist/playlist_controller.cpp b/modules/gui/qt/playlist/playlist_controller.cpp
index ab2a81d0d8..671d98df2e 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 d285eded3d..27e37c1082 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 4fd22c974e..8ecc26a6ba 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
More information about the vlc-commits
mailing list