[vlc-devel] [PATCH 1/3] qt: mlalbummodel: move roles to class and use Q_ENUM

Alexandre Janniaux ajanni at videolabs.io
Wed Oct 9 19:11:22 CEST 2019


From: Pierre Lamot <pierre at videolabs.io>

... so that roles are exposed to QML.
---
 .../gui/qt/components/mediacenter/mlalbummodel.cpp | 14 --------------
 .../gui/qt/components/mediacenter/mlalbummodel.hpp | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt/components/mediacenter/mlalbummodel.cpp b/modules/gui/qt/components/mediacenter/mlalbummodel.cpp
index 4a585ac7f4f..4b5eca576a6 100644
--- a/modules/gui/qt/components/mediacenter/mlalbummodel.cpp
+++ b/modules/gui/qt/components/mediacenter/mlalbummodel.cpp
@@ -18,20 +18,6 @@
 
 #include "mlalbummodel.hpp"
 
-namespace {
-    enum Roles
-    {
-        ALBUM_ID = Qt::UserRole + 1,
-        ALBUM_TITLE,
-        ALBUM_RELEASE_YEAR,
-        ALBUM_SHORT_SUMMARY,
-        ALBUM_COVER,
-        ALBUM_MAIN_ARTIST,
-        ALBUM_NB_TRACKS,
-        ALBUM_DURATION
-    };
-}
-
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumModel::M_names_to_criteria = {
     {"id", VLC_ML_SORTING_DEFAULT},
     {"title", VLC_ML_SORTING_ALBUM},
diff --git a/modules/gui/qt/components/mediacenter/mlalbummodel.hpp b/modules/gui/qt/components/mediacenter/mlalbummodel.hpp
index ab267e376d9..6899bf4a865 100644
--- a/modules/gui/qt/components/mediacenter/mlalbummodel.hpp
+++ b/modules/gui/qt/components/mediacenter/mlalbummodel.hpp
@@ -32,6 +32,20 @@ class MLAlbumModel : public MLSlidingWindowModel<MLAlbum>
 {
     Q_OBJECT
 
+public:
+    enum Roles
+    {
+        ALBUM_ID = Qt::UserRole + 1,
+        ALBUM_TITLE,
+        ALBUM_RELEASE_YEAR,
+        ALBUM_SHORT_SUMMARY,
+        ALBUM_COVER,
+        ALBUM_MAIN_ARTIST,
+        ALBUM_NB_TRACKS,
+        ALBUM_DURATION
+    };
+    Q_ENUM(Roles)
+
 public:
     explicit MLAlbumModel(QObject *parent = nullptr);
     virtual ~MLAlbumModel() = default;
-- 
2.23.0



More information about the vlc-devel mailing list