[vlc-devel] [PATCH 1/8] qt: medialib: rename MLParentId to MLItemId
Romain Vimont
rom1v at videolabs.io
Thu Dec 3 12:12:05 CET 2020
The item id sometimes represents the id of the "current" item, sometimes
the id of the "parent" item. Therefore, the fact that it is a "parent"
id depends on the context, and is not intrinsic to the type.
This caused confusion when getId() returned a MLParentId, representing
the id of the current item.
Rename to MLItemId to clarify.
---
modules/gui/qt/maininterface/mainui.cpp | 2 +-
modules/gui/qt/medialibrary/medialib.cpp | 12 ++++++------
modules/gui/qt/medialibrary/medialib.hpp | 4 ++--
modules/gui/qt/medialibrary/mlalbum.cpp | 2 +-
modules/gui/qt/medialibrary/mlalbum.hpp | 6 +++---
modules/gui/qt/medialibrary/mlalbumtrack.cpp | 2 +-
modules/gui/qt/medialibrary/mlalbumtrack.hpp | 6 +++---
modules/gui/qt/medialibrary/mlartist.cpp | 2 +-
modules/gui/qt/medialibrary/mlartist.hpp | 6 +++---
modules/gui/qt/medialibrary/mlbasemodel.cpp | 6 +++---
modules/gui/qt/medialibrary/mlbasemodel.hpp | 12 ++++++------
modules/gui/qt/medialibrary/mlgenre.cpp | 2 +-
modules/gui/qt/medialibrary/mlgenre.hpp | 6 +++---
modules/gui/qt/medialibrary/mlqmltypes.hpp | 10 +++++-----
modules/gui/qt/medialibrary/mlrecentsmodel.hpp | 4 ++--
modules/gui/qt/medialibrary/mlurlmodel.cpp | 2 +-
modules/gui/qt/medialibrary/mlurlmodel.hpp | 4 ++--
modules/gui/qt/medialibrary/mlvideo.cpp | 2 +-
modules/gui/qt/medialibrary/mlvideo.hpp | 6 +++---
modules/gui/qt/menus/custom_menus.cpp | 2 +-
20 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index 41a78da1be..816a61851c 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -160,7 +160,7 @@ void MainUI::registerQMLTypes()
if (m_mainInterface->hasMediaLibrary())
{
- qRegisterMetaType<MLParentId>();
+ qRegisterMetaType<MLItemId>();
qmlRegisterType<MLAlbumModel>( "org.videolan.medialib", 0, 1, "MLAlbumModel" );
qmlRegisterType<MLArtistModel>( "org.videolan.medialib", 0, 1, "MLArtistModel" );
qmlRegisterType<MLAlbumTrackModel>( "org.videolan.medialib", 0, 1, "MLAlbumTrackModel" );
diff --git a/modules/gui/qt/medialibrary/medialib.cpp b/modules/gui/qt/medialibrary/medialib.cpp
index cdccf4b1b9..b482b32d59 100644
--- a/modules/gui/qt/medialibrary/medialib.cpp
+++ b/modules/gui/qt/medialibrary/medialib.cpp
@@ -53,7 +53,7 @@ void MediaLib::addToPlaylist(const QUrl& mrl, const QStringList* options)
}
// A specific item has been asked to be added to the playlist
-void MediaLib::addToPlaylist(const MLParentId & itemId, const QStringList* options)
+void MediaLib::addToPlaylist(const MLItemId & itemId, const QStringList* options)
{
//invalid item
if (itemId.id == 0)
@@ -99,9 +99,9 @@ void MediaLib::addToPlaylist(const QVariantList& itemIdList, const QStringList*
auto mrl = varValue.value<QString>();
addToPlaylist(mrl, options);
}
- else if (varValue.canConvert<MLParentId>())
+ else if (varValue.canConvert<MLItemId>())
{
- MLParentId itemId = varValue.value<MLParentId>();
+ MLItemId itemId = varValue.value<MLItemId>();
addToPlaylist(itemId, options);
}
}
@@ -109,7 +109,7 @@ void MediaLib::addToPlaylist(const QVariantList& itemIdList, const QStringList*
// A specific item has been asked to be played,
// so it's added to the playlist and played
-void MediaLib::addAndPlay(const MLParentId & itemId, const QStringList* options )
+void MediaLib::addAndPlay(const MLItemId & itemId, const QStringList* options )
{
if (itemId.id == 0)
return;
@@ -173,9 +173,9 @@ void MediaLib::addAndPlay(const QVariantList& itemIdList, const QStringList* opt
else
addToPlaylist(mrl, options);
}
- else if (varValue.canConvert<MLParentId>())
+ else if (varValue.canConvert<MLItemId>())
{
- MLParentId itemId = varValue.value<MLParentId>();
+ MLItemId itemId = varValue.value<MLItemId>();
if (b_start)
addAndPlay(itemId, options);
else
diff --git a/modules/gui/qt/medialibrary/medialib.hpp b/modules/gui/qt/medialibrary/medialib.hpp
index 2274c359cd..e48aae5783 100644
--- a/modules/gui/qt/medialibrary/medialib.hpp
+++ b/modules/gui/qt/medialibrary/medialib.hpp
@@ -47,12 +47,12 @@ class MediaLib : public QObject
public:
MediaLib(intf_thread_t* _intf, QObject* _parent = nullptr );
- Q_INVOKABLE void addToPlaylist(const MLParentId &itemId, const QStringList* options = nullptr);
+ Q_INVOKABLE void addToPlaylist(const MLItemId &itemId, const QStringList* options = nullptr);
Q_INVOKABLE void addToPlaylist(const QString& mrl, const QStringList* options = nullptr);
Q_INVOKABLE void addToPlaylist(const QUrl& mrl, const QStringList* options = nullptr);
Q_INVOKABLE void addToPlaylist(const QVariantList& itemIdList, const QStringList* options = nullptr);
- Q_INVOKABLE void addAndPlay(const MLParentId &itemId, const QStringList* options = nullptr);
+ Q_INVOKABLE void addAndPlay(const MLItemId &itemId, const QStringList* options = nullptr);
Q_INVOKABLE void addAndPlay(const QString& mrl, const QStringList* options = nullptr);
Q_INVOKABLE void addAndPlay(const QUrl& mrl, const QStringList* options = nullptr);
Q_INVOKABLE void addAndPlay(const QVariantList&itemIdList, const QStringList* options = nullptr);
diff --git a/modules/gui/qt/medialibrary/mlalbum.cpp b/modules/gui/qt/medialibrary/mlalbum.cpp
index 5fa09b5ba0..6f3b5f053c 100644
--- a/modules/gui/qt/medialibrary/mlalbum.cpp
+++ b/modules/gui/qt/medialibrary/mlalbum.cpp
@@ -70,7 +70,7 @@ MLAlbum::MLAlbum(const MLAlbum& _album, QObject *_parent)
{
}
-MLParentId MLAlbum::getId() const
+MLItemId MLAlbum::getId() const
{
return m_id;
}
diff --git a/modules/gui/qt/medialibrary/mlalbum.hpp b/modules/gui/qt/medialibrary/mlalbum.hpp
index 95ca6088a5..525834a91c 100644
--- a/modules/gui/qt/medialibrary/mlalbum.hpp
+++ b/modules/gui/qt/medialibrary/mlalbum.hpp
@@ -35,7 +35,7 @@ class MLAlbum : public QObject
{
Q_OBJECT
- Q_PROPERTY(MLParentId id READ getId CONSTANT)
+ 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)
@@ -48,7 +48,7 @@ class MLAlbum : public QObject
public:
MLAlbum(vlc_medialibrary_t* _ml, const vlc_ml_album_t *_data, QObject *_parent = nullptr);
- MLParentId getId() const;
+ MLItemId getId() const;
QString getTitle() const;
unsigned int getReleaseYear() const;
QString getShortSummary() const;
@@ -70,7 +70,7 @@ private:
vlc_medialibrary_t* m_ml;
- MLParentId m_id;
+ MLItemId m_id;
QString m_title;
unsigned int m_releaseYear;
QString m_shortSummary;
diff --git a/modules/gui/qt/medialibrary/mlalbumtrack.cpp b/modules/gui/qt/medialibrary/mlalbumtrack.cpp
index fb9a22625b..4d13479150 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrack.cpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrack.cpp
@@ -97,7 +97,7 @@ MLAlbumTrack::MLAlbumTrack(const MLAlbumTrack &albumtrack, QObject *_parent)
{
}
-MLParentId MLAlbumTrack::getId() const
+MLItemId MLAlbumTrack::getId() const
{
return m_id;
}
diff --git a/modules/gui/qt/medialibrary/mlalbumtrack.hpp b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
index c9abbed671..19b40619a6 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrack.hpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
@@ -35,7 +35,7 @@ class MLAlbumTrack : public QObject
{
Q_OBJECT
- Q_PROPERTY(MLParentId id READ getId CONSTANT)
+ 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)
@@ -49,7 +49,7 @@ class MLAlbumTrack : public QObject
public:
MLAlbumTrack(vlc_medialibrary_t *_ml, const vlc_ml_media_t *_data, QObject *_parent = nullptr);
- MLParentId getId() const;
+ MLItemId getId() const;
QString getTitle() const;
QString getAlbumTitle() const;
QString getArtist() const;
@@ -65,7 +65,7 @@ public:
private:
MLAlbumTrack(const MLAlbumTrack& albumtrack, QObject *_parent = nullptr);
- MLParentId m_id;
+ MLItemId m_id;
QString m_title;
QString m_albumTitle;
QString m_artist;
diff --git a/modules/gui/qt/medialibrary/mlartist.cpp b/modules/gui/qt/medialibrary/mlartist.cpp
index e96c7b6993..e66a323a98 100644
--- a/modules/gui/qt/medialibrary/mlartist.cpp
+++ b/modules/gui/qt/medialibrary/mlartist.cpp
@@ -43,7 +43,7 @@ MLArtist::MLArtist(const MLArtist &artist, QObject *_parent)
}
-MLParentId MLArtist::getId() const
+MLItemId MLArtist::getId() const
{
return m_id;
}
diff --git a/modules/gui/qt/medialibrary/mlartist.hpp b/modules/gui/qt/medialibrary/mlartist.hpp
index f9a9e5a31b..355196f69a 100644
--- a/modules/gui/qt/medialibrary/mlartist.hpp
+++ b/modules/gui/qt/medialibrary/mlartist.hpp
@@ -38,7 +38,7 @@ class MLArtist : public QObject
{
Q_OBJECT
- Q_PROPERTY(MLParentId id READ getId CONSTANT)
+ 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)
@@ -48,7 +48,7 @@ class MLArtist : public QObject
public:
MLArtist(const vlc_ml_artist_t *_data, QObject *_parent = nullptr);
- MLParentId getId() const;
+ MLItemId getId() const;
QString getName() const;
QString getShortBio() const;
QString getCover() const;
@@ -64,7 +64,7 @@ public:
private:
MLArtist(const MLArtist &artist, QObject *_parent = nullptr);
- MLParentId m_id;
+ MLItemId m_id;
QString m_name;
QString m_shortBio;
QString m_cover;
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.cpp b/modules/gui/qt/medialibrary/mlbasemodel.cpp
index 65dc1939e1..63fb227c9b 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.cpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.cpp
@@ -117,12 +117,12 @@ void MLBaseModel::onVlcMlEvent(void* data, const vlc_ml_event_t* event)
});
}
-MLParentId MLBaseModel::parentId() const
+MLItemId MLBaseModel::parentId() const
{
return m_parent;
}
-void MLBaseModel::setParentId(MLParentId parentId)
+void MLBaseModel::setParentId(MLItemId parentId)
{
beginResetModel();
m_parent = parentId;
@@ -134,7 +134,7 @@ void MLBaseModel::setParentId(MLParentId parentId)
void MLBaseModel::unsetParentId()
{
beginResetModel();
- m_parent = MLParentId();
+ m_parent = MLItemId();
clear();
endResetModel();
emit parentIdChanged();
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp b/modules/gui/qt/medialibrary/mlbasemodel.hpp
index ba0d0b950a..22c71a2500 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -47,7 +47,7 @@ public:
Q_INVOKABLE void sortByColumn(QByteArray name, Qt::SortOrder order);
- Q_PROPERTY( MLParentId parentId READ parentId WRITE setParentId NOTIFY parentIdChanged RESET unsetParentId )
+ Q_PROPERTY( MLItemId parentId READ parentId WRITE setParentId NOTIFY parentIdChanged RESET unsetParentId )
Q_PROPERTY( MediaLib* ml READ ml WRITE setMl )
Q_PROPERTY( QString searchPattern READ searchPattern WRITE setSearchPattern )
@@ -90,8 +90,8 @@ protected:
}
public:
- MLParentId parentId() const;
- void setParentId(MLParentId parentId);
+ MLItemId parentId() const;
+ void setParentId(MLItemId parentId);
void unsetParentId();
MediaLib* ml() const;
@@ -111,7 +111,7 @@ public:
protected:
virtual void onVlcMlEvent( const MLEvent &event );
- MLParentId m_parent;
+ MLItemId m_parent;
vlc_medialibrary_t* m_ml;
MediaLib* m_mediaLib;
@@ -301,7 +301,7 @@ protected:
/* Data loader for the cache */
struct BaseLoader : public ListCacheLoader<std::unique_ptr<T>>
{
- BaseLoader(vlc_medialibrary_t *ml, MLParentId parent, QString searchPattern,
+ BaseLoader(vlc_medialibrary_t *ml, MLItemId parent, QString searchPattern,
vlc_ml_sorting_criteria_t sort, bool sort_desc)
: m_ml(ml)
, m_parent(parent)
@@ -323,7 +323,7 @@ protected:
protected:
vlc_medialibrary_t *m_ml;
- MLParentId m_parent;
+ MLItemId m_parent;
QString m_searchPattern;
vlc_ml_sorting_criteria_t m_sort;
bool m_sort_desc;
diff --git a/modules/gui/qt/medialibrary/mlgenre.cpp b/modules/gui/qt/medialibrary/mlgenre.cpp
index fcdc1651f8..66fe0184a9 100644
--- a/modules/gui/qt/medialibrary/mlgenre.cpp
+++ b/modules/gui/qt/medialibrary/mlgenre.cpp
@@ -242,7 +242,7 @@ MLGenre::~MLGenre()
}
}
-MLParentId MLGenre::getId() const
+MLItemId MLGenre::getId() const
{
return m_id;
}
diff --git a/modules/gui/qt/medialibrary/mlgenre.hpp b/modules/gui/qt/medialibrary/mlgenre.hpp
index 66b5773be4..8eebe7c1f6 100644
--- a/modules/gui/qt/medialibrary/mlgenre.hpp
+++ b/modules/gui/qt/medialibrary/mlgenre.hpp
@@ -37,7 +37,7 @@ class MLGenre : public QObject
{
Q_OBJECT
- Q_PROPERTY(MLParentId id READ getId CONSTANT)
+ 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)
@@ -46,7 +46,7 @@ public:
MLGenre( vlc_medialibrary_t* _ml, const vlc_ml_genre_t *_data, QObject *_parent = nullptr);
~MLGenre();
- MLParentId getId() const;
+ MLItemId getId() const;
QString getName() const;
unsigned int getNbTracks() const;
QString getCover() const;
@@ -68,7 +68,7 @@ private:
vlc_medialibrary_t* m_ml;
- MLParentId m_id;
+ MLItemId m_id;
QString m_name;
QString m_cover;
QRunnable* m_coverTask = nullptr;
diff --git a/modules/gui/qt/medialibrary/mlqmltypes.hpp b/modules/gui/qt/medialibrary/mlqmltypes.hpp
index 7e963521b8..af92ba34a1 100644
--- a/modules/gui/qt/medialibrary/mlqmltypes.hpp
+++ b/modules/gui/qt/medialibrary/mlqmltypes.hpp
@@ -27,13 +27,13 @@
#include <vlc_common.h>
#include <vlc_media_library.h>
-class MLParentId
+class MLItemId
{
Q_GADGET
public:
- MLParentId() : id(0), type( VLC_ML_PARENT_UNKNOWN ) {}
- MLParentId( int64_t i, vlc_ml_parent_type t ) : id( i ), type( t ) {}
- bool operator!=( const MLParentId& lhs )
+ MLItemId() : id(0), type( VLC_ML_PARENT_UNKNOWN ) {}
+ MLItemId( int64_t i, vlc_ml_parent_type t ) : id( i ), type( t ) {}
+ bool operator!=( const MLItemId& lhs )
{
return id != lhs.id || type != lhs.type;
}
@@ -56,6 +56,6 @@ public:
}
};
-Q_DECLARE_METATYPE(MLParentId)
+Q_DECLARE_METATYPE(MLItemId)
#endif // MLQMLTYPES_HPP
diff --git a/modules/gui/qt/medialibrary/mlrecentsmodel.hpp b/modules/gui/qt/medialibrary/mlrecentsmodel.hpp
index b58ebea042..d551c7700a 100644
--- a/modules/gui/qt/medialibrary/mlrecentsmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlrecentsmodel.hpp
@@ -40,12 +40,12 @@ public:
inline QUrl getUrl() const { return m_url; }
inline QDateTime getLastPlayedDate() const { return m_lastPlayedDate; }
- inline MLParentId getId() const { return m_id; }
+ inline MLItemId getId() const { return m_id; }
MLRecentMedia *clone() const;
private:
- MLParentId m_id;
+ MLItemId m_id;
QUrl m_url;
QDateTime m_lastPlayedDate;
};
diff --git a/modules/gui/qt/medialibrary/mlurlmodel.cpp b/modules/gui/qt/medialibrary/mlurlmodel.cpp
index 662842ffa6..dc199ed657 100644
--- a/modules/gui/qt/medialibrary/mlurlmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlurlmodel.cpp
@@ -66,7 +66,7 @@ void MLUrlModel::addAndPlay( const QString &url )
}
if (!s)
return;
- MLParentId itemId( s->i_id, VLC_ML_PARENT_UNKNOWN );
+ MLItemId itemId( s->i_id, VLC_ML_PARENT_UNKNOWN );
m_mediaLib->addAndPlay(itemId);
emit resetRequested();
});
diff --git a/modules/gui/qt/medialibrary/mlurlmodel.hpp b/modules/gui/qt/medialibrary/mlurlmodel.hpp
index b647d49234..ac9e3202ae 100644
--- a/modules/gui/qt/medialibrary/mlurlmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlurlmodel.hpp
@@ -38,12 +38,12 @@ public:
QString getUrl() const;
QString getLastPlayedDate() const;
- MLParentId getId() const { return m_id; }
+ MLItemId getId() const { return m_id; }
MLUrl *clone() const;
private:
- MLParentId m_id;
+ MLItemId m_id;
QString m_url;
QString m_lastPlayedDate;
};
diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index 8a03d9411f..a13bafd907 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -180,7 +180,7 @@ void MLVideo::onMlEvent( const vlc_ml_event_t* event )
emit onThumbnailChanged( m_thumbnail );
}
-MLParentId MLVideo::getId() const
+MLItemId MLVideo::getId() const
{
return m_id;
}
diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp
index 8a20aab038..545ffe7614 100644
--- a/modules/gui/qt/medialibrary/mlvideo.hpp
+++ b/modules/gui/qt/medialibrary/mlvideo.hpp
@@ -83,7 +83,7 @@ class MLVideo : public QObject
{
Q_OBJECT
- Q_PROPERTY(MLParentId id READ getId CONSTANT);
+ 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);
@@ -101,7 +101,7 @@ class MLVideo : public QObject
public:
MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data, QObject *parent = nullptr);
- MLParentId getId() const;
+ MLItemId getId() const;
QString getTitle() const;
QString getThumbnail();
QString getDuration() const;
@@ -129,7 +129,7 @@ private:
vlc_medialibrary_t* m_ml;
- MLParentId m_id;
+ MLItemId m_id;
QString m_title;
QString m_thumbnail;
int64_t m_duration;
diff --git a/modules/gui/qt/menus/custom_menus.cpp b/modules/gui/qt/menus/custom_menus.cpp
index d8fc4c1980..fdf4024695 100644
--- a/modules/gui/qt/menus/custom_menus.cpp
+++ b/modules/gui/qt/menus/custom_menus.cpp
@@ -361,7 +361,7 @@ void RecentMenu::onRowInserted(const QModelIndex&, int first, int last)
insertAction(m_separator , choiceAction);
connect(choiceAction, &QAction::triggered, [this, i](){
QModelIndex dataIndex = m_model->index(i);
- MLParentId id = m_model->data(dataIndex, MLRecentsModel::RECENT_MEDIA_ID).value<MLParentId>();
+ MLItemId id = m_model->data(dataIndex, MLRecentsModel::RECENT_MEDIA_ID).value<MLItemId>();
m_ml->addAndPlay(id);
});
setEnabled(true);
--
2.29.2
More information about the vlc-devel
mailing list