[vlc-devel] commit: Qt: simplify selected item deletion in playlist model (Jakob Leben )
git version control
git at videolan.org
Wed Feb 10 11:07:50 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Feb 10 09:48:49 2010 +0100| [74d4a589a628631de88cce97a52135757380367c] | committer: Jakob Leben
Qt: simplify selected item deletion in playlist model
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=74d4a589a628631de88cce97a52135757380367c
---
.../gui/qt4/components/playlist/playlist_model.cpp | 43 ++++++-------------
.../gui/qt4/components/playlist/playlist_model.hpp | 1 -
2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 8ef1235..742c58c 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -757,18 +757,22 @@ void PLModel::doDelete( QModelIndexList selected )
{
if( !canEdit() ) return;
- for( int i = selected.size() -1 ; i >= 0; i-- )
+ while( !selected.isEmpty() )
{
- QModelIndex index = selected[i];
+ QModelIndex index = selected[0];
+ selected.removeAt( 0 );
+
if( index.column() != 0 ) continue;
+
PLItem *item = getItem( index );
- if( item )
- {
- if( item->children.size() )
- recurseDelete( item->children, &selected );
- doDeleteItem( item, &selected );
- }
- if( i > selected.size() ) i = selected.size();
+ if( item->children.size() )
+ recurseDelete( item->children, &selected );
+
+ PL_LOCK;
+ playlist_DeleteFromInput( p_playlist, item->p_input, pl_Locked );
+ PL_UNLOCK;
+
+ removeItem( item );
}
}
@@ -779,29 +783,10 @@ void PLModel::recurseDelete( QList<PLItem*> children, QModelIndexList *fullList
PLItem *item = children[i];
if( item->children.size() )
recurseDelete( item->children, fullList );
- doDeleteItem( item, fullList );
+ fullList->removeAll( index( item, 0 ) );
}
}
-void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
-{
- QModelIndex deleteIndex = index( item, 0 );
- fullList->removeAll( deleteIndex );
-
- PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
- if( !p_item )
- {
- PL_UNLOCK;
- return;
- }
- playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
- PL_UNLOCK;
-
- /* And finally, remove it from the tree */
- removeItem( item );
-}
-
/******* Volume III: Sorting and searching ********/
void PLModel::sort( int column, Qt::SortOrder order )
{
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index cb5e68c..67c8726 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -120,7 +120,6 @@ private:
/* Actions */
void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
- void doDeleteItem( PLItem *item, QModelIndexList *fullList );
void updateTreeItem( PLItem * );
void removeItem ( PLItem * );
void takeItem( PLItem * ); //will not delete item
More information about the vlc-devel
mailing list