[vlc-commits] qt: add MLBannedFoldersModel

Prince Gupta git at videolan.org
Mon Mar 1 10:40:18 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Tue Feb 23 15:54:02 2021 +0530| [98a9c96bd8e243b384f676e4a5931c17bb845099] | committer: Pierre Lamot

qt: add MLBannedFoldersModel

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=98a9c96bd8e243b384f676e4a5931c17bb845099
---

 modules/gui/qt/medialibrary/mlfoldersmodel.cpp | 28 ++++++++++++++++++++++++++
 modules/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



More information about the vlc-commits mailing list