Commit 335ca010 authored by Prince Gupta's avatar Prince Gupta Committed by Jean-Baptiste Kempf
Browse files

qt/mlfoldersmodel: allow directly adding/removing a url

fix MLFoldersModel::remove, ensure MRL are fully encoded
Refs #25555
parent ef29f1df
......@@ -97,6 +97,15 @@ QHash<int, QByteArray> MLFoldersBaseModel::roleNames() const
};
}
void MLFoldersBaseModel::removeAt(int index)
{
assert(index < rowCount());
const QModelIndex idx = this->index( index, 0 );
if (idx.isValid())
remove( data( idx, MRL ).toUrl() );
}
void MLFoldersBaseModel::update()
{
beginResetModel();
......@@ -129,12 +138,9 @@ std::vector<MLFoldersBaseModel::EntryPoint> MLFoldersModel::entryPoints() const
return r;
}
void MLFoldersModel::removeAt( int index )
void MLFoldersModel::remove( const QUrl &mrl )
{
assert(index < rowCount());
const QModelIndex idx = this->index( index, 0 );
if (idx.isValid())
vlc_ml_remove_folder( ml() , qtu( data( idx, MLFoldersBaseModel::MRL ).value<QString>() ) );
vlc_ml_remove_folder( ml() , qtu( mrl.toString( QUrl::FullyEncoded ) ) );
}
void MLFoldersModel::add(const QUrl &mrl )
......@@ -142,14 +148,9 @@ void MLFoldersModel::add(const QUrl &mrl )
vlc_ml_add_folder( ml() , qtu( mrl.toString( QUrl::FullyEncoded ) ) );
}
void MLBannedFoldersModel::removeAt(int index)
void MLBannedFoldersModel::remove(const QUrl &mrl)
{
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>() ) );
}
vlc_ml_unban_folder( ml() , qtu( mrl.toString( QUrl::FullyEncoded ) ) );
}
void MLBannedFoldersModel::add(const QUrl &mrl)
......
......@@ -59,8 +59,9 @@ public:
QHash<int, QByteArray> roleNames() const override;
public slots:
virtual void removeAt( int index ) = 0;
virtual void remove( const QUrl &mrl ) = 0;
virtual void add( const QUrl &mrl ) = 0;
void removeAt( int index );
signals:
void ctxChanged();
......@@ -93,7 +94,7 @@ class MLFoldersModel : public MLFoldersBaseModel
public:
using MLFoldersBaseModel::MLFoldersBaseModel;
void removeAt( int index ) override;
void remove( const QUrl &mrl ) override;
void add( const QUrl &mrl ) override;
private:
......@@ -105,7 +106,7 @@ class MLBannedFoldersModel : public MLFoldersBaseModel
public:
using MLFoldersBaseModel::MLFoldersBaseModel;
void removeAt( int index ) override;
void remove( const QUrl &mrl ) override;
void add( const QUrl &mrl ) override;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment