[vlc-devel] [PATCH 1/4] qt: medialib: remove properties from model items

Romain Vimont rom1v at videolabs.io
Fri Dec 18 13:53:33 UTC 2020


In list models, items properties are accessed via
QAbstractItemModel::data().

QObjects themselves are not exposed (and must not be exposed) directly,
so the properties are useless.
---
 modules/gui/qt/medialibrary/mlalbum.hpp      | 10 ----------
 modules/gui/qt/medialibrary/mlalbumtrack.hpp | 15 ---------------
 modules/gui/qt/medialibrary/mlartist.hpp     |  7 -------
 modules/gui/qt/medialibrary/mlgenre.cpp      |  3 +--
 modules/gui/qt/medialibrary/mlgenre.hpp      | 11 ++---------
 modules/gui/qt/medialibrary/mlvideo.cpp      |  1 -
 modules/gui/qt/medialibrary/mlvideo.hpp      | 18 ------------------
 7 files changed, 3 insertions(+), 62 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlalbum.hpp b/modules/gui/qt/medialibrary/mlalbum.hpp
index 3050227796..a53ffaaf5a 100644
--- a/modules/gui/qt/medialibrary/mlalbum.hpp
+++ b/modules/gui/qt/medialibrary/mlalbum.hpp
@@ -35,16 +35,6 @@ class MLAlbum : public QObject, public MLItem
 {
     Q_OBJECT
 
-    Q_PROPERTY(MLItemId id READ getId CONSTANT)
-    Q_PROPERTY(QString title READ getTitle CONSTANT)
-    Q_PROPERTY(unsigned int releaseyear READ getReleaseYear CONSTANT)
-    Q_PROPERTY(QString shortsummary READ getShortSummary CONSTANT)
-    Q_PROPERTY(QString cover READ getCover CONSTANT)
-    Q_PROPERTY(QString artist READ getArtist CONSTANT)
-    Q_PROPERTY(unsigned int nbtracks READ getNbTracks CONSTANT)
-    Q_PROPERTY(QString duration READ getDuration CONSTANT)
-    Q_PROPERTY(QString durationShort READ getDuration CONSTANT)
-
 public:
     MLAlbum(vlc_medialibrary_t* _ml, const vlc_ml_album_t *_data, QObject *_parent = nullptr);
 
diff --git a/modules/gui/qt/medialibrary/mlalbumtrack.hpp b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
index 70b0e001f3..709ea266c8 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrack.hpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
@@ -35,17 +35,6 @@ class MLAlbumTrack : public QObject, public MLItem
 {
     Q_OBJECT
 
-    Q_PROPERTY(MLItemId id READ getId CONSTANT)
-    Q_PROPERTY(QString title READ getTitle CONSTANT)
-    Q_PROPERTY(QString album_title READ getAlbumTitle CONSTANT)
-    Q_PROPERTY(QString main_artist READ getArtist CONSTANT)
-    Q_PROPERTY(QString cover READ getCover CONSTANT)
-    Q_PROPERTY(unsigned int track_number READ getTrackNumber CONSTANT)
-    Q_PROPERTY(unsigned int disc_number READ getDiscNumber CONSTANT)
-    Q_PROPERTY(QString duration READ getDuration CONSTANT)
-    Q_PROPERTY(QString durationShort READ getDurationShort CONSTANT)
-    Q_PROPERTY(QString mrl READ getMRL CONSTANT)
-
 public:
     MLAlbumTrack(vlc_medialibrary_t *_ml, const vlc_ml_media_t *_data, QObject *_parent = nullptr);
 
@@ -75,8 +64,4 @@ private:
     QString m_mrl;
 
    ml_unique_ptr<vlc_ml_media_t> m_data;
-
-signals:
-
-public slots:
 };
diff --git a/modules/gui/qt/medialibrary/mlartist.hpp b/modules/gui/qt/medialibrary/mlartist.hpp
index 099b8c208f..f69b6837c6 100644
--- a/modules/gui/qt/medialibrary/mlartist.hpp
+++ b/modules/gui/qt/medialibrary/mlartist.hpp
@@ -38,13 +38,6 @@ class MLArtist : public QObject, public MLItem
 {
     Q_OBJECT
 
-    Q_PROPERTY(MLItemId id READ getId CONSTANT)
-    Q_PROPERTY(QString name READ getName CONSTANT)
-    Q_PROPERTY(QString shortbio READ getShortBio CONSTANT)
-    Q_PROPERTY(QString cover READ getCover CONSTANT)
-    Q_PROPERTY(unsigned int nbalbums READ getNbAlbums CONSTANT)
-    Q_PROPERTY(unsigned int nbtracks READ getNbTracks CONSTANT)
-
 public:
     MLArtist(const vlc_ml_artist_t *_data, QObject *_parent = nullptr);
 
diff --git a/modules/gui/qt/medialibrary/mlgenre.cpp b/modules/gui/qt/medialibrary/mlgenre.cpp
index 316db042a8..9506e9017e 100644
--- a/modules/gui/qt/medialibrary/mlgenre.cpp
+++ b/modules/gui/qt/medialibrary/mlgenre.cpp
@@ -262,11 +262,10 @@ QString MLGenre::getCover() const
     return m_cover;
 }
 
-void MLGenre::setCover(const QString cover)
+void MLGenre::setCover(QString cover)
 {
     m_cover = cover;
     //TODO store in media library
-    emit coverChanged(m_cover);
 }
 
 MLGenre *MLGenre::clone(QObject *parent) const
diff --git a/modules/gui/qt/medialibrary/mlgenre.hpp b/modules/gui/qt/medialibrary/mlgenre.hpp
index 8f47e631cd..01057408b8 100644
--- a/modules/gui/qt/medialibrary/mlgenre.hpp
+++ b/modules/gui/qt/medialibrary/mlgenre.hpp
@@ -37,11 +37,6 @@ class MLGenre : public QObject, public MLItem
 {
     Q_OBJECT
 
-    Q_PROPERTY(MLItemId id READ getId CONSTANT)
-    Q_PROPERTY(QString name READ getName CONSTANT)
-    Q_PROPERTY(unsigned int nbtracks READ getNbTracks CONSTANT)
-    Q_PROPERTY(QString cover READ getCover WRITE setCover NOTIFY coverChanged)
-
 public:
     MLGenre( vlc_medialibrary_t* _ml, const vlc_ml_genre_t *_data, QObject *_parent = nullptr);
     ~MLGenre();
@@ -50,15 +45,13 @@ public:
     unsigned int getNbTracks() const;
     QString getCover() const;
 
+    void setCover(QString cover);
+
     MLGenre* clone(QObject *parent = nullptr) const;
 
 signals:
-    void coverChanged( const QString );
     void askGenerateCover( QPrivateSignal ) const;
 
-public slots:
-    void setCover(const QString cover);
-
 private slots:
     void generateThumbnail();
 
diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index cefb9504d6..e5bc1239f6 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -177,7 +177,6 @@ void MLVideo::onMlEvent( const vlc_ml_event_t* event )
             .p_media->thumbnails[event->media_thumbnail_generated.i_size].psz_mrl;
     m_thumbnail = QString::fromUtf8( thumbnailMrl );
     vlc_ml_event_unregister_from_callback( m_ml, m_ml_event_handle.release() );
-    emit onThumbnailChanged( m_thumbnail );
 }
 
 QString MLVideo::getTitle() const
diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp
index 8041881280..58b1b056f0 100644
--- a/modules/gui/qt/medialibrary/mlvideo.hpp
+++ b/modules/gui/qt/medialibrary/mlvideo.hpp
@@ -83,21 +83,6 @@ class MLVideo : public QObject, public MLItem
 {
     Q_OBJECT
 
-    Q_PROPERTY(MLItemId id READ getId CONSTANT);
-    Q_PROPERTY(QString title READ getTitle CONSTANT);
-    Q_PROPERTY(QString thumbnail READ getThumbnail NOTIFY onThumbnailChanged);
-    Q_PROPERTY(QString duration READ getDuration CONSTANT);
-    Q_PROPERTY(QString durationShort READ getDurationShort CONSTANT);
-    Q_PROPERTY(QString mrl READ getMRL CONSTANT);
-    Q_PROPERTY(QString displayMrl READ getDisplayMRL CONSTANT)
-    Q_PROPERTY(float progress READ getProgress CONSTANT);
-    Q_PROPERTY(unsigned int playCount READ getPlayCount CONSTANT);
-    Q_PROPERTY(QString resolution_name READ getResolutionName CONSTANT);
-    Q_PROPERTY(QString channel READ getChannel CONSTANT);
-    Q_PROPERTY(QString progressTime READ getProgressTime CONSTANT);
-    Q_PROPERTY(QObjectList audioDesc READ getAudioDesc CONSTANT);
-    Q_PROPERTY(QObjectList videoDesc READ getVideoDesc CONSTANT);
-
 public:
     MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data, QObject *parent = nullptr);
 
@@ -117,9 +102,6 @@ public:
 
     MLVideo* clone(QObject* parent = nullptr) const;
 
-signals:
-    void onThumbnailChanged( QString );
-
 private:
     MLVideo(const MLVideo& video, QObject* parent = nullptr);
 
-- 
2.29.2



More information about the vlc-devel mailing list