diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index 383105d0d4..a42717f79d 100644 --- a/modules/gui/qt/Makefile.am +++ b/modules/gui/qt/Makefile.am @@ -163,6 +163,8 @@ libqt_plugin_la_SOURCES = \ gui/qt/medialibrary/mlgrouplistmodel.hpp \ gui/qt/medialibrary/mlhelper.cpp \ gui/qt/medialibrary/mlhelper.hpp \ + gui/qt/medialibrary/mlitemcover.cpp \ + gui/qt/medialibrary/mlitemcover.hpp \ gui/qt/medialibrary/mlqmltypes.hpp \ gui/qt/medialibrary/mlqueryparams.cpp \ gui/qt/medialibrary/mlqueryparams.hpp \ diff --git a/modules/gui/qt/medialibrary/mlgenre.cpp b/modules/gui/qt/medialibrary/mlgenre.cpp index 640b35e6cf..9d2b61c02c 100644 --- a/modules/gui/qt/medialibrary/mlgenre.cpp +++ b/modules/gui/qt/medialibrary/mlgenre.cpp @@ -19,9 +19,8 @@ #include "mlgenre.hpp" MLGenre::MLGenre(vlc_medialibrary_t* ml, const vlc_ml_genre_t *_data ) - : MLItem ( MLItemId( _data->i_id, VLC_ML_PARENT_GENRE ) ) + : MLItemCover( MLItemId( _data->i_id, VLC_ML_PARENT_GENRE ) ) , m_ml ( ml ) - , m_generator( nullptr ) , m_name ( QString::fromUtf8( _data->psz_name ) ) , m_nbTracks ( (unsigned int)_data->i_nb_tracks ) @@ -29,16 +28,6 @@ MLGenre::MLGenre(vlc_medialibrary_t* ml, const vlc_ml_genre_t *_data ) assert(_data); } -bool MLGenre::hasGenerator() const -{ - return m_generator.get(); -} - -void MLGenre::setGenerator(CoverGenerator * generator) -{ - m_generator.reset(generator); -} - QString MLGenre::getName() const { return m_name; @@ -48,14 +37,3 @@ unsigned int MLGenre::getNbTracks() const { return m_nbTracks; } - -QString MLGenre::getCover() const -{ - return m_cover; -} - -void MLGenre::setCover(const QString & fileName) -{ - m_cover = fileName; -} - diff --git a/modules/gui/qt/medialibrary/mlgenre.hpp b/modules/gui/qt/medialibrary/mlgenre.hpp index ebeb6c1082..1af666ff43 100644 --- a/modules/gui/qt/medialibrary/mlgenre.hpp +++ b/modules/gui/qt/medialibrary/mlgenre.hpp @@ -23,36 +23,22 @@ #include "config.h" #endif -// Util includes -#include "util/covergenerator.hpp" - // MediaLibrary includes -#include "mlqmltypes.hpp" +#include "mlitemcover.hpp" -class MLGenre : public MLItem +class MLGenre : public MLItemCover { public: - MLGenre( vlc_medialibrary_t* _ml, const vlc_ml_genre_t *_data ); - - bool hasGenerator() const; - void setGenerator(CoverGenerator * generator); + MLGenre(vlc_medialibrary_t * _ml, const vlc_ml_genre_t * _data); QString getName() const; + unsigned int getNbTracks() const; - QString getCover() const; - void setCover(const QString & fileName); - -private slots: - void generateThumbnail(); - private: - vlc_medialibrary_t* m_ml; - - TaskHandle m_generator; + vlc_medialibrary_t * m_ml; QString m_name; - QString m_cover; unsigned int m_nbTracks; }; diff --git a/modules/gui/qt/medialibrary/mlgroup.cpp b/modules/gui/qt/medialibrary/mlgroup.cpp index 88faafc5e5..65ea406bb4 100644 --- a/modules/gui/qt/medialibrary/mlgroup.cpp +++ b/modules/gui/qt/medialibrary/mlgroup.cpp @@ -28,9 +28,8 @@ //------------------------------------------------------------------------------------------------- MLGroup::MLGroup(vlc_medialibrary_t * ml, const vlc_ml_group_t * data) - : MLItem(MLItemId(data->i_id, VLC_ML_PARENT_GROUP)) + : MLItemCover(MLItemId(data->i_id, VLC_ML_PARENT_GROUP)) , m_ml(ml) - , m_generator(nullptr) , m_name(qfu(data->psz_name)) , m_duration(data->i_duration) , m_date(data->i_creation_date) @@ -43,18 +42,6 @@ MLGroup::MLGroup(vlc_medialibrary_t * ml, const vlc_ml_group_t * data) // Interface //------------------------------------------------------------------------------------------------- -bool MLGroup::hasGenerator() const -{ - return m_generator.get(); -} - -void MLGroup::setGenerator(CoverGenerator * generator) -{ - m_generator.reset(generator); -} - -//------------------------------------------------------------------------------------------------- - QString MLGroup::getName() const { return m_name; @@ -62,18 +49,6 @@ QString MLGroup::getName() const //------------------------------------------------------------------------------------------------- -QString MLGroup::getCover() const -{ - return m_cover; -} - -void MLGroup::setCover(const QString & fileName) -{ - m_cover = fileName; -} - -//------------------------------------------------------------------------------------------------- - int64_t MLGroup::getDuration() const { return m_duration; diff --git a/modules/gui/qt/medialibrary/mlgroup.hpp b/modules/gui/qt/medialibrary/mlgroup.hpp index 598594a073..576d4f1a4e 100644 --- a/modules/gui/qt/medialibrary/mlgroup.hpp +++ b/modules/gui/qt/medialibrary/mlgroup.hpp @@ -25,26 +25,17 @@ #include "config.h" #endif -// Util includes -#include "util/covergenerator.hpp" - // MediaLibrary includes -#include "mlqmltypes.hpp" +#include "mlitemcover.hpp" -class MLGroup : public MLItem +class MLGroup : public MLItemCover { public: MLGroup(vlc_medialibrary_t * ml, const vlc_ml_group_t * data); public: // Interface - bool hasGenerator() const; - void setGenerator(CoverGenerator * generator); - QString getName() const; - QString getCover() const; - void setCover(const QString & fileName); - int64_t getDuration() const; unsigned int getDate() const; @@ -54,12 +45,8 @@ public: // Interface private: vlc_medialibrary_t * m_ml; - TaskHandle m_generator; - QString m_name; - QString m_cover; - int64_t m_duration; unsigned int m_date; diff --git a/modules/gui/qt/medialibrary/mlitemcover.cpp b/modules/gui/qt/medialibrary/mlitemcover.cpp new file mode 100644 index 0000000000..484103e9b2 --- /dev/null +++ b/modules/gui/qt/medialibrary/mlitemcover.cpp @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (C) 2021 VLC authors and VideoLAN + * + * Authors: Benjamin Arnaud + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "mlitemcover.hpp" + +//------------------------------------------------------------------------------------------------- +// Ctor / dtor +//------------------------------------------------------------------------------------------------- + +MLItemCover::MLItemCover(const MLItemId & id) + : MLItem(id) + , m_generator(nullptr) {} + +//------------------------------------------------------------------------------------------------- +// Interface +//------------------------------------------------------------------------------------------------- + +bool MLItemCover::hasGenerator() const +{ + return m_generator.get(); +} + +void MLItemCover::setGenerator(CoverGenerator * generator) +{ + m_generator.reset(generator); +} + +//------------------------------------------------------------------------------------------------- + +QString MLItemCover::getCover() const +{ + return m_cover; +} + +void MLItemCover::setCover(const QString & fileName) +{ + m_cover = fileName; +} diff --git a/modules/gui/qt/medialibrary/mlitemcover.hpp b/modules/gui/qt/medialibrary/mlitemcover.hpp new file mode 100644 index 0000000000..1064a67ecd --- /dev/null +++ b/modules/gui/qt/medialibrary/mlitemcover.hpp @@ -0,0 +1,52 @@ +/***************************************************************************** + * Copyright (C) 2021 VLC authors and VideoLAN + * + * Authors: Benjamin Arnaud + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef MLITEMCOVER_HPP +#define MLITEMCOVER_HPP + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +// Util includes +#include "util/covergenerator.hpp" + +// MediaLibrary includes +#include "mlqmltypes.hpp" + +class MLItemCover : public MLItem +{ +public: + /* explicit */ MLItemCover(const MLItemId & id); + +public: // Interface + bool hasGenerator() const; + void setGenerator(CoverGenerator * generator); + + QString getCover() const; + void setCover(const QString & fileName); + +private: + TaskHandle m_generator; + + QString m_cover; +}; + +#endif diff --git a/modules/gui/qt/medialibrary/mlplaylist.cpp b/modules/gui/qt/medialibrary/mlplaylist.cpp index ea4a9dc90d..3adef6ee89 100644 --- a/modules/gui/qt/medialibrary/mlplaylist.cpp +++ b/modules/gui/qt/medialibrary/mlplaylist.cpp @@ -26,9 +26,8 @@ //------------------------------------------------------------------------------------------------- MLPlaylist::MLPlaylist(vlc_medialibrary_t * ml, const vlc_ml_playlist_t * data) - : MLItem(MLItemId(data->i_id, VLC_ML_PARENT_PLAYLIST)) + : MLItemCover(MLItemId(data->i_id, VLC_ML_PARENT_PLAYLIST)) , m_ml(ml) - , m_generator(nullptr) , m_name(qfu(data->psz_name)) , m_duration(0) // TODO m_duration , m_count(data->i_nb_media) @@ -40,18 +39,6 @@ MLPlaylist::MLPlaylist(vlc_medialibrary_t * ml, const vlc_ml_playlist_t * data) // Interface //------------------------------------------------------------------------------------------------- -bool MLPlaylist::hasGenerator() const -{ - return m_generator.get(); -} - -void MLPlaylist::setGenerator(CoverGenerator * generator) -{ - m_generator.reset(generator); -} - -//------------------------------------------------------------------------------------------------- - QString MLPlaylist::getName() const { return m_name; @@ -59,18 +46,6 @@ QString MLPlaylist::getName() const //------------------------------------------------------------------------------------------------- -QString MLPlaylist::getCover() const -{ - return m_cover; -} - -void MLPlaylist::setCover(const QString & fileName) -{ - m_cover = fileName; -} - -//------------------------------------------------------------------------------------------------- - int64_t MLPlaylist::getDuration() const { return m_duration; diff --git a/modules/gui/qt/medialibrary/mlplaylist.hpp b/modules/gui/qt/medialibrary/mlplaylist.hpp index 5df9ab0371..cf76d7b26d 100644 --- a/modules/gui/qt/medialibrary/mlplaylist.hpp +++ b/modules/gui/qt/medialibrary/mlplaylist.hpp @@ -23,26 +23,17 @@ #include "config.h" #endif -// Util includes -#include "util/covergenerator.hpp" - // MediaLibrary includes -#include "mlqmltypes.hpp" +#include "mlitemcover.hpp" -class MLPlaylist : public MLItem +class MLPlaylist : public MLItemCover { public: MLPlaylist(vlc_medialibrary_t * ml, const vlc_ml_playlist_t * data); public: // Interface - bool hasGenerator() const; - void setGenerator(CoverGenerator * generator); - QString getName() const; - QString getCover() const; - void setCover(const QString & fileName); - int64_t getDuration() const; unsigned int getCount() const; @@ -50,10 +41,7 @@ public: // Interface private: vlc_medialibrary_t * m_ml; - TaskHandle m_generator; - QString m_name; - QString m_cover; int64_t m_duration; diff --git a/po/POTFILES.in b/po/POTFILES.in index 8cb3df8eaa..04a3985b64 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -777,6 +777,8 @@ modules/gui/qt/medialibrary/mlgroup.cpp modules/gui/qt/medialibrary/mlgroup.hpp modules/gui/qt/medialibrary/mlgrouplistmodel.cpp modules/gui/qt/medialibrary/mlgrouplistmodel.hpp +modules/gui/qt/medialibrary/mlitemcover.cpp +modules/gui/qt/medialibrary/mlitemcover.hpp modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp modules/gui/qt/medialibrary/mlplaylistlistmodel.hpp modules/gui/qt/medialibrary/mlplaylistmedia.cpp