[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: clean: Migrated 'getFirstSymbol()'
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Aug 11 04:56:29 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
573e3cad by Ash V at 2024-08-11T04:41:10+00:00
qt: clean: Migrated 'getFirstSymbol()'
Migrated the 'getFirstSymbol()' trivial member function
of the MLBaseModel to mlhelper.
- - - - -
d2c79f0a by Ash V at 2024-08-11T04:41:10+00:00
qt: clean: Removed redundant member functions
Removed the redundant 'roleToCriteria()' and 'criteriaToName()'
member functions from the MLBaseModel and its subclasses.
- - - - -
60bcaecb by Ash V at 2024-08-11T04:41:10+00:00
qt: clean: Removed 'M_names_to_criteria' QHash
The 'M_names_to_criteria' (or 'criterias') QHash as a static data member
was useful when the 2 member functions
'nameToCriteria()' and 'criteriaToName()' accessed it.
Now only 'nameToCriteria()' accesses this QHash.
So, it's been moved inside the 'nameToCriteria()' method.
- - - - -
25 changed files:
- modules/gui/qt/medialibrary/mlalbummodel.cpp
- modules/gui/qt/medialibrary/mlalbummodel.hpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
- modules/gui/qt/medialibrary/mlartistmodel.cpp
- modules/gui/qt/medialibrary/mlartistmodel.hpp
- modules/gui/qt/medialibrary/mlbasemodel.cpp
- modules/gui/qt/medialibrary/mlbasemodel.hpp
- modules/gui/qt/medialibrary/mlgenremodel.cpp
- modules/gui/qt/medialibrary/mlgenremodel.hpp
- modules/gui/qt/medialibrary/mlhelper.cpp
- modules/gui/qt/medialibrary/mlhelper.hpp
- modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistlistmodel.hpp
- modules/gui/qt/medialibrary/mlplaylistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistmodel.hpp
- modules/gui/qt/medialibrary/mlrecentsmodel.hpp
- modules/gui/qt/medialibrary/mlurlmodel.cpp
- modules/gui/qt/medialibrary/mlurlmodel.hpp
- modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp
- modules/gui/qt/medialibrary/mlvideofoldersmodel.hpp
- modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp
- modules/gui/qt/medialibrary/mlvideogroupsmodel.hpp
- modules/gui/qt/medialibrary/mlvideomodel.cpp
- modules/gui/qt/medialibrary/mlvideomodel.hpp
Changes:
=====================================
modules/gui/qt/medialibrary/mlalbummodel.cpp
=====================================
@@ -17,18 +17,10 @@
*****************************************************************************/
#include "mlalbummodel.hpp"
+#include "mlhelper.hpp"
#include "util/vlctick.hpp"
-QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumModel::M_names_to_criteria = {
- {"id", VLC_ML_SORTING_DEFAULT},
- {"title", VLC_ML_SORTING_ALPHA},
- {"release_year", VLC_ML_SORTING_RELEASEDATE},
- {"main_artist", VLC_ML_SORTING_ARTIST},
- //{"nb_tracks"},
- {"duration", VLC_ML_SORTING_DURATION}
-};
-
MLAlbumModel::MLAlbumModel(QObject *parent)
: MLBaseModel(parent)
{
@@ -52,12 +44,14 @@ QHash<int, QByteArray> MLAlbumModel::roleNames() const
vlc_ml_sorting_criteria_t MLAlbumModel::nameToCriteria(QByteArray name) const
{
- return M_names_to_criteria.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLAlbumModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-{
- return M_names_to_criteria.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"id", VLC_ML_SORTING_DEFAULT},
+ {"title", VLC_ML_SORTING_ALPHA},
+ {"release_year", VLC_ML_SORTING_RELEASEDATE},
+ {"main_artist", VLC_ML_SORTING_ARTIST},
+ // {"nb_tracks"},
+ {"duration", VLC_ML_SORTING_DURATION},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
void MLAlbumModel::onVlcMlEvent(const MLEvent &event)
@@ -98,23 +92,6 @@ void MLAlbumModel::onVlcMlEvent(const MLEvent &event)
MLBaseModel::onVlcMlEvent( event );
}
-vlc_ml_sorting_criteria_t MLAlbumModel::roleToCriteria(int role) const
-{
- switch (role)
- {
- case ALBUM_TITLE :
- return VLC_ML_SORTING_ALPHA;
- case ALBUM_RELEASE_YEAR :
- return VLC_ML_SORTING_RELEASEDATE;
- case ALBUM_MAIN_ARTIST :
- return VLC_ML_SORTING_ARTIST;
- case ALBUM_DURATION:
- return VLC_ML_SORTING_DURATION;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
QVariant MLAlbumModel::itemRoleData(MLItem *item, const int role) const
{
auto ml_item = static_cast<MLAlbum *>(item);
=====================================
modules/gui/qt/medialibrary/mlalbummodel.hpp
=====================================
@@ -60,13 +60,9 @@ protected:
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private:
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
void onVlcMlEvent( const MLEvent &event ) override;
- static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
-
struct Loader : public MLListCacheLoader::MLOp
{
using MLListCacheLoader::MLOp::MLOp;
=====================================
modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
=====================================
@@ -20,16 +20,6 @@
#include "util/vlctick.hpp"
#include "mlhelper.hpp"
-QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumTrackModel::M_names_to_criteria = {
- {"id", VLC_ML_SORTING_DEFAULT},
- {"title", VLC_ML_SORTING_ALPHA},
- {"album_title", VLC_ML_SORTING_ALBUM},
- {"track_number", VLC_ML_SORTING_TRACKNUMBER},
- {"release_year", VLC_ML_SORTING_RELEASEDATE},
- {"main_artist", VLC_ML_SORTING_ARTIST},
- {"duration", VLC_ML_SORTING_DURATION}
-};
-
MLAlbumTrackModel::MLAlbumTrackModel(QObject *parent)
: MLBaseModel(parent)
{
@@ -93,28 +83,17 @@ QHash<int, QByteArray> MLAlbumTrackModel::roleNames() const
};
}
-vlc_ml_sorting_criteria_t MLAlbumTrackModel::roleToCriteria(int role) const
-{
- switch (role) {
- case TRACK_TITLE :
- return VLC_ML_SORTING_ALPHA;
- case TRACK_NUMBER :
- return VLC_ML_SORTING_TRACKNUMBER;
- case TRACK_DURATION :
- return VLC_ML_SORTING_DURATION;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLAlbumTrackModel::nameToCriteria(QByteArray name) const
{
- return M_names_to_criteria.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLAlbumTrackModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-{
- return M_names_to_criteria.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"id", VLC_ML_SORTING_DEFAULT},
+ {"title", VLC_ML_SORTING_ALPHA},
+ {"album_title", VLC_ML_SORTING_ALBUM},
+ {"track_number", VLC_ML_SORTING_TRACKNUMBER},
+ {"release_year", VLC_ML_SORTING_RELEASEDATE},
+ {"main_artist", VLC_ML_SORTING_ARTIST},
+ {"duration", VLC_ML_SORTING_DURATION},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
void MLAlbumTrackModel::onVlcMlEvent(const MLEvent &event)
=====================================
modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
=====================================
@@ -62,13 +62,9 @@ protected:
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private:
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
void onVlcMlEvent( const MLEvent &event ) override;
- static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
-
struct Loader : public MLListCacheLoader::MLOp
{
using MLListCacheLoader::MLOp::MLOp;
=====================================
modules/gui/qt/medialibrary/mlartistmodel.cpp
=====================================
@@ -18,11 +18,6 @@
#include "mlartistmodel.hpp"
-QHash<QByteArray, vlc_ml_sorting_criteria_t> MLArtistModel::M_names_to_criteria = {
- {"name", VLC_ML_SORTING_ALPHA},
- {"nb_tracks", VLC_ML_SORTING_TRACKNUMBER},
-};
-
MLArtistModel::MLArtistModel(QObject *parent)
: MLBaseModel(parent)
{
@@ -64,25 +59,12 @@ QHash<int, QByteArray> MLArtistModel::roleNames() const
};
}
-vlc_ml_sorting_criteria_t MLArtistModel::roleToCriteria(int role) const
-{
- switch (role)
- {
- case ARTIST_NAME :
- return VLC_ML_SORTING_ALPHA;
- default :
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLArtistModel::nameToCriteria(QByteArray name) const
{
- return M_names_to_criteria.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLArtistModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-{
- return M_names_to_criteria.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"name", VLC_ML_SORTING_ALPHA},
+ {"nb_tracks", VLC_ML_SORTING_TRACKNUMBER},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
void MLArtistModel::onVlcMlEvent(const MLEvent &event)
=====================================
modules/gui/qt/medialibrary/mlartistmodel.hpp
=====================================
@@ -52,13 +52,9 @@ protected:
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private:
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
void onVlcMlEvent(const MLEvent &event) override;
- static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
-
struct Loader : public MLListCacheLoader::MLOp
{
using MLListCacheLoader::MLOp::MLOp;
=====================================
modules/gui/qt/medialibrary/mlbasemodel.cpp
=====================================
@@ -278,14 +278,6 @@ void MLBaseModel::onVlcMlEvent(const MLEvent &event)
}
}
-QString MLBaseModel::getFirstSymbol(QString str)
-{
- QString ret("#");
- if ( str.length() > 0 && str[0].isLetter() )
- ret = str[0].toUpper();
- return ret;
-}
-
void MLBaseModel::onVlcMlEvent(void* data, const vlc_ml_event_t* event)
{
auto self = static_cast<MLBaseModel*>(data);
=====================================
modules/gui/qt/medialibrary/mlbasemodel.hpp
=====================================
@@ -91,14 +91,9 @@ signals:
protected:
virtual std::unique_ptr<MLListCacheLoader> createMLLoader() const = 0;
- virtual vlc_ml_sorting_criteria_t roleToCriteria(int role) const = 0;
- static QString getFirstSymbol(QString str);
- virtual vlc_ml_sorting_criteria_t nameToCriteria(QByteArray) const {
- return VLC_ML_SORTING_DEFAULT;
- }
- virtual QByteArray criteriaToName(vlc_ml_sorting_criteria_t ) const
+ virtual vlc_ml_sorting_criteria_t nameToCriteria(QByteArray /* name */) const
{
- return "";
+ return VLC_ML_SORTING_DEFAULT;
}
MLItem *item(int signedidx) const;
=====================================
modules/gui/qt/medialibrary/mlgenremodel.cpp
=====================================
@@ -39,10 +39,6 @@ static const int MLGENREMODEL_COVER_BLUR = 4;
//-------------------------------------------------------------------------------------------------
-QHash<QByteArray, vlc_ml_sorting_criteria_t> MLGenreModel::M_names_to_criteria = {
- {"name", VLC_ML_SORTING_ALPHA}
-};
-
MLGenreModel::MLGenreModel(QObject *parent)
: MLBaseModel(parent)
{
@@ -121,25 +117,11 @@ void MLGenreModel::onVlcMlEvent(const MLEvent &event)
MLBaseModel::onVlcMlEvent(event);
}
-vlc_ml_sorting_criteria_t MLGenreModel::roleToCriteria(int role) const
-{
- switch (role)
- {
- case GENRE_NAME:
- return VLC_ML_SORTING_ALPHA;
- default :
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLGenreModel::nameToCriteria(QByteArray name) const
{
- return M_names_to_criteria.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLGenreModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-{
- return M_names_to_criteria.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"name", VLC_ML_SORTING_ALPHA},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
QString MLGenreModel::getCover(MLGenre * genre) const
=====================================
modules/gui/qt/medialibrary/mlgenremodel.hpp
=====================================
@@ -65,9 +65,7 @@ protected:
private:
void onVlcMlEvent(const MLEvent &event) override;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
QString getCover(MLGenre * genre) const;
@@ -81,9 +79,6 @@ private:
std::vector<std::unique_ptr<MLItem>> load(vlc_medialibrary_t* ml, const vlc_ml_query_params_t* queryParams) const override;
std::unique_ptr<MLItem> loadItemById(vlc_medialibrary_t* ml, MLItemId itemId) const override;
};
-
-private: // Variables
- static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
};
=====================================
modules/gui/qt/medialibrary/mlhelper.cpp
=====================================
@@ -18,9 +18,6 @@
#include "mlhelper.hpp"
-// MediaLibrary includes
-#include "mlbasemodel.hpp"
-
#include <QDir>
QString toValidLocalFile(const char *mrl)
@@ -37,3 +34,11 @@ QString urlToDisplayString(const QUrl &url)
return displayString;
}
+
+QString getFirstSymbol(const QString &str)
+{
+ QString ret("#");
+ if ( str.length() > 0 && str[0].isLetter() )
+ ret = str[0].toUpper();
+ return ret;
+}
=====================================
modules/gui/qt/medialibrary/mlhelper.hpp
=====================================
@@ -19,23 +19,17 @@
#ifndef MLHELPER_HPP
#define MLHELPER_HPP
-#include <memory>
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <memory>
+
#include <vlc_media_library.h>
+
#include <QString>
#include <QUrl>
-// Forward declarations
-class MLBaseModel;
-class MLItem;
-class MLItemId;
-class CoverGenerator;
-class QUrl;
-
template<typename T>
class MLDeleter
{
@@ -116,4 +110,6 @@ QUrl getParentURLFromMLItem(T *mlItem)
return parentDirUrl;
}
+QString getFirstSymbol(const QString &);
+
#endif // MLHELPER_HPP
=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
=====================================
@@ -323,14 +323,6 @@ QVariant MLPlaylistListModel::headerData(int section, Qt::Orientation orientatio
// Protected MLBaseModel implementation
//-------------------------------------------------------------------------------------------------
-vlc_ml_sorting_criteria_t MLPlaylistListModel::roleToCriteria(int role) const /* override */
-{
- if (role == PLAYLIST_NAME)
- return VLC_ML_SORTING_ALPHA;
- else
- return VLC_ML_SORTING_DEFAULT;
-}
-
std::unique_ptr<MLListCacheLoader> MLPlaylistListModel::createMLLoader() const /* override */
{
return std::make_unique<MLListCacheLoader>(m_mediaLib, std::make_shared<MLPlaylistListModel::Loader>(*this, m_playlistType));
=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.hpp
=====================================
@@ -86,8 +86,6 @@ public: // QAbstractItemModel reimplementation
protected: // MLBaseModel implementation
QVariant itemRoleData(MLItem* item, int role = Qt::DisplayRole) const override;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
-
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private: // Functions
=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.cpp
=====================================
@@ -33,17 +33,6 @@
#include "playlist/playlist_controller.hpp"
#include "playlist/media.hpp"
-//-------------------------------------------------------------------------------------------------
-// Static variables
-
-static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
-{
- {"id", VLC_ML_SORTING_DEFAULT},
- {"title", VLC_ML_SORTING_ALPHA},
- {"duration", VLC_ML_SORTING_DURATION},
- {"playcount", VLC_ML_SORTING_PLAYCOUNT},
-};
-
//=================================================================================================
// MLPlaylistModel
//=================================================================================================
@@ -384,29 +373,14 @@ QVariant MLPlaylistModel::itemRoleData(MLItem *item, int role) const /* override
// Protected MLBaseModel implementation
//-------------------------------------------------------------------------------------------------
-vlc_ml_sorting_criteria_t MLPlaylistModel::roleToCriteria(int role) const /* override */
-{
- switch (role)
- {
- case MEDIA_TITLE:
- return VLC_ML_SORTING_ALPHA;
- case MEDIA_DURATION:
- return VLC_ML_SORTING_DURATION;
- case MEDIA_PLAYCOUNT:
- return VLC_ML_SORTING_PLAYCOUNT;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLPlaylistModel::nameToCriteria(QByteArray name) const /* override */
{
- return criterias.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLPlaylistModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const /* override */
-{
- return criterias.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"id", VLC_ML_SORTING_DEFAULT},
+ {"title", VLC_ML_SORTING_ALPHA},
+ {"duration", VLC_ML_SORTING_DURATION},
+ {"playcount", VLC_ML_SORTING_PLAYCOUNT},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
//-------------------------------------------------------------------------------------------------
=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.hpp
=====================================
@@ -68,12 +68,8 @@ signals:
protected: // MLBaseModel implementation
QVariant itemRoleData(MLItem *item, int role = Qt::DisplayRole) const override;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
-
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
-
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
protected: // MLBaseModel reimplementation
=====================================
modules/gui/qt/medialibrary/mlrecentsmodel.hpp
=====================================
@@ -68,12 +68,6 @@ protected:
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private:
- vlc_ml_sorting_criteria_t roleToCriteria( int /* role */ ) const override{
- return VLC_ML_SORTING_DEFAULT;
- }
- vlc_ml_sorting_criteria_t nameToCriteria( QByteArray /* name */ ) const override{
- return VLC_ML_SORTING_DEFAULT;
- }
void onVlcMlEvent( const MLEvent &event ) override;
struct Loader : public MLListCacheLoader::MLOp
=====================================
modules/gui/qt/medialibrary/mlurlmodel.cpp
=====================================
@@ -106,18 +106,6 @@ void MLUrlModel::deleteStream( const MLItemId itemId )
});
}
-vlc_ml_sorting_criteria_t MLUrlModel::roleToCriteria(int role) const
-{
- switch (role) {
- case URL_URL :
- return VLC_ML_SORTING_DEFAULT;
- case URL_LAST_PLAYED_DATE :
- return VLC_ML_SORTING_LASTMODIFICATIONDATE;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
void MLUrlModel::onVlcMlEvent(const MLEvent &event)
{
switch (event.i_type)
=====================================
modules/gui/qt/medialibrary/mlurlmodel.hpp
=====================================
@@ -71,7 +71,6 @@ protected:
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
private:
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
void onVlcMlEvent( const MLEvent &event ) override;
struct Loader : public MLListCacheLoader::MLOp
=====================================
modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp
=====================================
@@ -42,12 +42,6 @@
static const int MLVIDEOFOLDERSMODEL_COVER_WIDTH = 260 * 3; // 16 / 10 ratio
static const int MLVIDEOFOLDERSMODEL_COVER_HEIGHT = 162 * 3;
-static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
-{
- { "title", VLC_ML_SORTING_ALPHA },
- { "duration", VLC_ML_SORTING_DURATION }
-};
-
// Ctor / dtor
/* explicit */ MLVideoFoldersModel::MLVideoFoldersModel(QObject * parent) : MLBaseModel(parent) {}
@@ -102,28 +96,12 @@ QVariant MLVideoFoldersModel::itemRoleData(MLItem * item, const int role) const
}
}
-vlc_ml_sorting_criteria_t MLVideoFoldersModel::roleToCriteria(int role) const /* override */
-{
- switch (role)
- {
- case FOLDER_TITLE:
- return VLC_ML_SORTING_ALPHA;
- case FOLDER_DURATION:
- return VLC_ML_SORTING_DURATION;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLVideoFoldersModel::nameToCriteria(QByteArray name) const /* override */
{
- return criterias.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLVideoFoldersModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-/* override */
-{
- return criterias.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ { "title", VLC_ML_SORTING_ALPHA },
+ { "duration", VLC_ML_SORTING_DURATION },
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
std::unique_ptr<MLListCacheLoader>
=====================================
modules/gui/qt/medialibrary/mlvideofoldersmodel.hpp
=====================================
@@ -51,12 +51,8 @@ public: // MLBaseModel reimplementation
protected:
QVariant itemRoleData(MLItem *item, int role = Qt::DisplayRole) const override;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
-
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
-
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
protected: // MLBaseModel reimplementation
=====================================
modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp
=====================================
@@ -44,13 +44,6 @@
static const int MLVIDEOGROUPSMODEL_COVER_WIDTH = 260 * 3; // 16 / 10 ratio
static const int MLVIDEOGROUPSMODEL_COVER_HEIGHT = 162 * 3;
-static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
-{
- { "title", VLC_ML_SORTING_ALPHA },
- { "duration", VLC_ML_SORTING_DURATION },
- { "date", VLC_ML_SORTING_INSERTIONDATE }
-};
-
//=================================================================================================
// MLVideoGroupsModel
//=================================================================================================
@@ -144,30 +137,13 @@ QVariant MLVideoGroupsModel::itemRoleData(MLItem * item, const int role) const /
}
}
-vlc_ml_sorting_criteria_t MLVideoGroupsModel::roleToCriteria(int role) const /* override */
-{
- switch (role)
- {
- case VIDEO_TITLE:
- return VLC_ML_SORTING_ALPHA;
- case VIDEO_DURATION:
- return VLC_ML_SORTING_DURATION;
- case GROUP_DATE:
- return VLC_ML_SORTING_INSERTIONDATE;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLVideoGroupsModel::nameToCriteria(QByteArray name) const /* override */
{
- return criterias.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLVideoGroupsModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-/* override */
-{
- return criterias.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ { "title", VLC_ML_SORTING_ALPHA },
+ { "duration", VLC_ML_SORTING_DURATION },
+ { "date", VLC_ML_SORTING_INSERTIONDATE },
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
std::unique_ptr<MLListCacheLoader> MLVideoGroupsModel::createMLLoader() const /* override */
=====================================
modules/gui/qt/medialibrary/mlvideogroupsmodel.hpp
=====================================
@@ -50,12 +50,8 @@ public: // MLVideoModel reimplementation
protected: // MLVideoModel reimplementation
QVariant itemRoleData(MLItem *item, int role = Qt::DisplayRole) const override;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
-
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
-
std::unique_ptr<MLListCacheLoader> createMLLoader() const override;
void onVlcMlEvent(const MLEvent & event) override;
=====================================
modules/gui/qt/medialibrary/mlvideomodel.cpp
=====================================
@@ -33,12 +33,6 @@ QVariantList getVariantList(const QList<T> & desc)
return list;
}
-QHash<QByteArray, vlc_ml_sorting_criteria_t> MLVideoModel::M_names_to_criteria = {
- {"title", VLC_ML_SORTING_ALPHA},
- {"duration", VLC_ML_SORTING_DURATION},
- {"playcount", VLC_ML_SORTING_PLAYCOUNT},
-};
-
MLVideoModel::MLVideoModel(QObject* parent)
: MLBaseModel(parent)
{
@@ -177,29 +171,13 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
};
}
-vlc_ml_sorting_criteria_t MLVideoModel::roleToCriteria(int role) const
-{
- switch(role)
- {
- case VIDEO_TITLE:
- return VLC_ML_SORTING_ALPHA;
- case VIDEO_DURATION:
- return VLC_ML_SORTING_DURATION;
- case VIDEO_PLAYCOUNT:
- return VLC_ML_SORTING_PLAYCOUNT;
- default:
- return VLC_ML_SORTING_DEFAULT;
- }
-}
-
vlc_ml_sorting_criteria_t MLVideoModel::nameToCriteria(QByteArray name) const
{
- return M_names_to_criteria.value(name, VLC_ML_SORTING_DEFAULT);
-}
-
-QByteArray MLVideoModel::criteriaToName(vlc_ml_sorting_criteria_t criteria) const
-{
- return M_names_to_criteria.key(criteria, "");
+ return QHash<QByteArray, vlc_ml_sorting_criteria_t> {
+ {"title", VLC_ML_SORTING_ALPHA},
+ {"duration", VLC_ML_SORTING_DURATION},
+ {"playcount", VLC_ML_SORTING_PLAYCOUNT},
+ }.value(name, VLC_ML_SORTING_DEFAULT);
}
// Protected MLBaseModel reimplementation
=====================================
modules/gui/qt/medialibrary/mlvideomodel.hpp
=====================================
@@ -88,12 +88,8 @@ protected: // MLBaseModel reimplementation
private:
void generateThumbnail(uint64_t id) const;
- vlc_ml_sorting_criteria_t roleToCriteria(int role) const override;
vlc_ml_sorting_criteria_t nameToCriteria(QByteArray name) const override;
- static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
- QByteArray criteriaToName(vlc_ml_sorting_criteria_t criteria) const override;
-
struct Loader : public MLListCacheLoader::MLOp
{
using MLListCacheLoader::MLOp::MLOp;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b2358bbf038ae9080d5f49ec78679cb39a0c0b2c...60bcaecb212d5b8264f6076b0259c595726653cd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b2358bbf038ae9080d5f49ec78679cb39a0c0b2c...60bcaecb212d5b8264f6076b0259c595726653cd
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list