[vlc-devel] [PATCH 12/16] qt: add MLBannedFoldersModel
Prince Gupta
guptaprince8832 at gmail.com
Tue Feb 23 10:06:02 UTC 2021
---
.../gui/qt/medialibrary/mlfoldersmodel.cpp | 28 +++++++++++++++++++
.../gui/qt/medialibrary/mlfoldersmodel.hpp | 12 ++++++++
2 files changed, 40 insertions(+)
diff --git a/modules/gui/qt/medialibrary/mlfoldersmodel.cpp b/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
index 2ac1aa3f99..56fcb2fb64 100644
--- a/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
@@ -139,3 +139,31 @@ void MLFoldersModel::add(const QUrl &mrl )
{
vlc_ml_add_folder( ml() , qtu( mrl.toString( QUrl::None ) ) );
}
+
+void MLBannedFoldersModel::removeAt(int index)
+{
+ assert(index < rowCount());
+ const QModelIndex idx = this->index( index, 0 );
+ if (idx.isValid())
+ {
+ vlc_ml_unban_folder( ml() , qtu( data( idx, MLFoldersBaseModel::MRL ).value<QString>() ) );
+ }
+}
+
+void MLBannedFoldersModel::add(const QUrl &mrl)
+{
+ vlc_ml_ban_folder( ml() , qtu( mrl.toString( QUrl::None ) ) );
+}
+
+std::vector<MLFoldersBaseModel::EntryPoint> MLBannedFoldersModel::entryPoints() const
+{
+ std::vector<MLFoldersBaseModel::EntryPoint> r;
+
+ vlc_ml_entry_point_list_t * entrypoints = nullptr;
+ vlc_ml_list_banned_folder( ml() , &entrypoints );
+ for ( unsigned int i=0 ; i<entrypoints->i_nb_items ; i++ )
+ r.emplace_back( entrypoints->p_items[i] );
+ vlc_ml_release(entrypoints);
+
+ return r;
+}
diff --git a/modules/gui/qt/medialibrary/mlfoldersmodel.hpp b/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
index 2006151899..941e379f7c 100644
--- a/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
@@ -100,4 +100,16 @@ private:
std::vector<EntryPoint> entryPoints() const final;
};
+class MLBannedFoldersModel : public MLFoldersBaseModel
+{
+public:
+ using MLFoldersBaseModel::MLFoldersBaseModel;
+
+ void removeAt( int index ) override;
+ void add( const QUrl &mrl ) override;
+
+private:
+ std::vector<EntryPoint> entryPoints() const final;
+};
+
#endif // ML_FOLDERS_MODEL_HPP
--
2.25.1
More information about the vlc-devel
mailing list