[vlc-devel] [PATCH 08/18] qt: make Role enum of medialib models public

Pierre Lamot pierre at videolabs.io
Wed Sep 23 14:27:42 CEST 2020


  So they can be accessed from C++.
---
 .../gui/qt/medialibrary/mlalbumtrackmodel.cpp | 20 -----------------
 .../gui/qt/medialibrary/mlalbumtrackmodel.hpp | 17 ++++++++++++++
 modules/gui/qt/medialibrary/mlartistmodel.cpp | 12 ----------
 modules/gui/qt/medialibrary/mlartistmodel.hpp | 10 +++++++++
 modules/gui/qt/medialibrary/mlbasemodel.hpp   |  2 ++
 modules/gui/qt/medialibrary/mlgenremodel.cpp  | 12 ----------
 modules/gui/qt/medialibrary/mlgenremodel.hpp  | 12 ++++++++++
 modules/gui/qt/medialibrary/mlvideomodel.cpp  | 22 -------------------
 modules/gui/qt/medialibrary/mlvideomodel.hpp  | 20 +++++++++++++++++
 modules/gui/qt/network/networkdevicemodel.cpp | 14 ------------
 modules/gui/qt/network/networkdevicemodel.hpp | 11 ++++++++++
 modules/gui/qt/network/networkmediamodel.cpp  | 16 --------------
 modules/gui/qt/network/networkmediamodel.hpp  | 12 ++++++++++
 13 files changed, 84 insertions(+), 96 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp b/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
index ed4c63de7a..dc9800dd4c 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
@@ -18,26 +18,6 @@
 
 #include "mlalbumtrackmodel.hpp"
 
-namespace {
-
-enum Role {
-    TRACK_ID = Qt::UserRole + 1,
-    TRACK_TITLE,
-    TRACK_COVER,
-    TRACK_NUMBER,
-    TRACK_DISC_NUMBER,
-    TRACK_DURATION,
-    TRACK_DURATION_SHORT,
-    TRACK_ALBUM,
-    TRACK_ARTIST,
-
-    TRACK_TITLE_FIRST_SYMBOL,
-    TRACK_ALBUM_FIRST_SYMBOL,
-    TRACK_ARTIST_FIRST_SYMBOL,
-};
-
-}
-
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumTrackModel::M_names_to_criteria = {
     {"id", VLC_ML_SORTING_DEFAULT},
     {"title", VLC_ML_SORTING_ALPHA},
diff --git a/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp b/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
index 4314ff229a..30a00ec478 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
@@ -32,6 +32,23 @@ class MLAlbumTrackModel : public MLSlidingWindowModel<MLAlbumTrack>
 {
     Q_OBJECT
 
+public:
+    enum Roles {
+        TRACK_ID = Qt::UserRole + 1,
+        TRACK_TITLE,
+        TRACK_COVER,
+        TRACK_NUMBER,
+        TRACK_DISC_NUMBER,
+        TRACK_DURATION,
+        TRACK_DURATION_SHORT,
+        TRACK_ALBUM,
+        TRACK_ARTIST,
+
+        TRACK_TITLE_FIRST_SYMBOL,
+        TRACK_ALBUM_FIRST_SYMBOL,
+        TRACK_ARTIST_FIRST_SYMBOL,
+    };
+
 public:
     explicit MLAlbumTrackModel(QObject *parent = nullptr);
 
diff --git a/modules/gui/qt/medialibrary/mlartistmodel.cpp b/modules/gui/qt/medialibrary/mlartistmodel.cpp
index ec87c17b0c..f3e745c6cd 100644
--- a/modules/gui/qt/medialibrary/mlartistmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlartistmodel.cpp
@@ -18,18 +18,6 @@
 
 #include "mlartistmodel.hpp"
 
-namespace {
-    enum Roles
-    {
-        ARTIST_ID = Qt::UserRole + 1,
-        ARTIST_NAME,
-        ARTIST_SHORT_BIO,
-        ARTIST_COVER,
-        ARTIST_NB_ALBUMS,
-        ARTIST_NB_TRACKS
-    };
-}
-
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLArtistModel::M_names_to_criteria = {
     {"title", VLC_ML_SORTING_ALPHA},
 };
diff --git a/modules/gui/qt/medialibrary/mlartistmodel.hpp b/modules/gui/qt/medialibrary/mlartistmodel.hpp
index 66ca9b35ce..ef92fdf65d 100644
--- a/modules/gui/qt/medialibrary/mlartistmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlartistmodel.hpp
@@ -30,6 +30,16 @@
 class MLArtistModel : public MLSlidingWindowModel<MLArtist>
 {
     Q_OBJECT
+public:
+    enum Roles
+    {
+        ARTIST_ID = Qt::UserRole + 1,
+        ARTIST_NAME,
+        ARTIST_SHORT_BIO,
+        ARTIST_COVER,
+        ARTIST_NB_ALBUMS,
+        ARTIST_NB_TRACKS
+    };
 
 public:
     explicit MLArtistModel(QObject *parent = nullptr);
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp b/modules/gui/qt/medialibrary/mlbasemodel.hpp
index bbedc6c26e..71187c13d1 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -84,6 +84,7 @@ protected:
         return "";
     }
 
+public:
     MLParentId parentId() const;
     void setParentId(MLParentId parentId);
     void unsetParentId();
@@ -102,6 +103,7 @@ protected:
 
     virtual unsigned int getCount() const = 0;
 
+protected:
     virtual void onVlcMlEvent( const vlc_ml_event_t* event );
 
     MLParentId m_parent;
diff --git a/modules/gui/qt/medialibrary/mlgenremodel.cpp b/modules/gui/qt/medialibrary/mlgenremodel.cpp
index a3f9a2dec6..793205a141 100644
--- a/modules/gui/qt/medialibrary/mlgenremodel.cpp
+++ b/modules/gui/qt/medialibrary/mlgenremodel.cpp
@@ -20,18 +20,6 @@
 
 #include "mlartistmodel.hpp"
 
-namespace {
-    enum Roles
-    {
-        GENRE_ID = Qt::UserRole + 1,
-        GENRE_NAME,
-        GENRE_NB_TRACKS,
-        GENRE_ARTISTS,
-        GENRE_TRACKS,
-        GENRE_ALBUMS,
-        GENRE_COVER
-    };
-}
 
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLGenreModel::M_names_to_criteria = {
     {"title", VLC_ML_SORTING_ALPHA}
diff --git a/modules/gui/qt/medialibrary/mlgenremodel.hpp b/modules/gui/qt/medialibrary/mlgenremodel.hpp
index 2b171e5b42..bef6eb140a 100644
--- a/modules/gui/qt/medialibrary/mlgenremodel.hpp
+++ b/modules/gui/qt/medialibrary/mlgenremodel.hpp
@@ -32,6 +32,18 @@ class MLGenreModel : public MLSlidingWindowModel<MLGenre>
 {
     Q_OBJECT
 
+public:
+    enum Roles
+    {
+        GENRE_ID = Qt::UserRole + 1,
+        GENRE_NAME,
+        GENRE_NB_TRACKS,
+        GENRE_ARTISTS,
+        GENRE_TRACKS,
+        GENRE_ALBUMS,
+        GENRE_COVER
+    };
+
 public:
     explicit MLGenreModel(QObject *parent = nullptr);
     virtual ~MLGenreModel() = default;
diff --git a/modules/gui/qt/medialibrary/mlvideomodel.cpp b/modules/gui/qt/medialibrary/mlvideomodel.cpp
index fde7155b3b..fa94dcf871 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.cpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.cpp
@@ -18,28 +18,6 @@
 
 #include "mlvideomodel.hpp"
 
-namespace {
-
-enum Role {
-    VIDEO_ID = Qt::UserRole + 1,
-    VIDEO_TITLE,
-    VIDEO_THUMBNAIL,
-    VIDEO_DURATION,
-    VIDEO_DURATION_SHORT,
-    VIDEO_PROGRESS,
-    VIDEO_PLAYCOUNT,
-    VIDEO_RESOLUTION,
-    VIDEO_CHANNEL,
-    VIDEO_MRL,
-    VIDEO_DISPLAY_MRL,
-    VIDEO_VIDEO_TRACK,
-    VIDEO_AUDIO_TRACK,
-
-    VIDEO_TITLE_FIRST_SYMBOL,
-};
-
-}
-
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLVideoModel::M_names_to_criteria = {
     {"id", VLC_ML_SORTING_DEFAULT},
     {"title", VLC_ML_SORTING_ALPHA},
diff --git a/modules/gui/qt/medialibrary/mlvideomodel.hpp b/modules/gui/qt/medialibrary/mlvideomodel.hpp
index 83cc0ab241..4c85885106 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.hpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.hpp
@@ -35,6 +35,26 @@ class MLVideoModel : public MLSlidingWindowModel<MLVideo>
 {
     Q_OBJECT
 
+public:
+    enum Role {
+        VIDEO_ID = Qt::UserRole + 1,
+        VIDEO_TITLE,
+        VIDEO_THUMBNAIL,
+        VIDEO_DURATION,
+        VIDEO_DURATION_SHORT,
+        VIDEO_PROGRESS,
+        VIDEO_PLAYCOUNT,
+        VIDEO_RESOLUTION,
+        VIDEO_CHANNEL,
+        VIDEO_MRL,
+        VIDEO_DISPLAY_MRL,
+        VIDEO_VIDEO_TRACK,
+        VIDEO_AUDIO_TRACK,
+
+        VIDEO_TITLE_FIRST_SYMBOL,
+    };
+
+
 public:
     explicit MLVideoModel(QObject* parent = nullptr);
     virtual ~MLVideoModel() = default;
diff --git a/modules/gui/qt/network/networkdevicemodel.cpp b/modules/gui/qt/network/networkdevicemodel.cpp
index ff9aa5d97e..103609592e 100644
--- a/modules/gui/qt/network/networkdevicemodel.cpp
+++ b/modules/gui/qt/network/networkdevicemodel.cpp
@@ -22,20 +22,6 @@
 #include "playlist/media.hpp"
 #include "playlist/playlist_controller.hpp"
 
-namespace {
-
-enum Role {
-    NETWORK_NAME = Qt::UserRole + 1,
-    NETWORK_MRL,
-    NETWORK_TYPE,
-    NETWORK_PROTOCOL,
-    NETWORK_SOURCE,
-    NETWORK_TREE,
-    NETWORK_ARTWORK,
-};
-
-}
-
 NetworkDeviceModel::NetworkDeviceModel( QObject* parent )
     : QAbstractListModel( parent )
     , m_ml( nullptr )
diff --git a/modules/gui/qt/network/networkdevicemodel.hpp b/modules/gui/qt/network/networkdevicemodel.hpp
index 166870361f..7bfeae761c 100644
--- a/modules/gui/qt/network/networkdevicemodel.hpp
+++ b/modules/gui/qt/network/networkdevicemodel.hpp
@@ -39,6 +39,17 @@ class NetworkDeviceModel : public QAbstractListModel, public NetworkSourceListen
 {
     Q_OBJECT
 public:
+
+    enum Role {
+        NETWORK_NAME = Qt::UserRole + 1,
+        NETWORK_MRL,
+        NETWORK_TYPE,
+        NETWORK_PROTOCOL,
+        NETWORK_SOURCE,
+        NETWORK_TREE,
+        NETWORK_ARTWORK,
+    };
+
     enum ItemType{
         // qt version of input_item_type_e
         TYPE_UNKNOWN = ITEM_TYPE_UNKNOWN,
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index da145e5758..b8b23dd66d 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -23,22 +23,6 @@
 #include "playlist/media.hpp"
 #include "playlist/playlist_controller.hpp"
 
-namespace {
-
-enum Role {
-    NETWORK_NAME = Qt::UserRole + 1,
-    NETWORK_MRL,
-    NETWORK_INDEXED,
-    NETWORK_CANINDEX,
-    NETWORK_TYPE,
-    NETWORK_PROTOCOL,
-    NETWORK_TREE,
-    NETWORK_SOURCE,
-    NETWORK_ARTWORK,
-};
-
-}
-
 NetworkMediaModel::NetworkMediaModel( QObject* parent )
     : QAbstractListModel( parent )
     , m_preparseSem(1)
diff --git a/modules/gui/qt/network/networkmediamodel.hpp b/modules/gui/qt/network/networkmediamodel.hpp
index ee368c1848..7438f219e6 100644
--- a/modules/gui/qt/network/networkmediamodel.hpp
+++ b/modules/gui/qt/network/networkmediamodel.hpp
@@ -74,6 +74,18 @@ class NetworkMediaModel : public QAbstractListModel, public NetworkSourceListene
     Q_OBJECT
 
 public:
+    enum Role {
+        NETWORK_NAME = Qt::UserRole + 1,
+        NETWORK_MRL,
+        NETWORK_INDEXED,
+        NETWORK_CANINDEX,
+        NETWORK_TYPE,
+        NETWORK_PROTOCOL,
+        NETWORK_TREE,
+        NETWORK_SOURCE,
+        NETWORK_ARTWORK,
+    };
+
     enum ItemType{
         // qt version of input_item_type_e
         TYPE_UNKNOWN = ITEM_TYPE_UNKNOWN,
-- 
2.25.1



More information about the vlc-devel mailing list