Also emit layoutAboutToBeChanged/layoutChanged() more. Speeds up
playlist-view atleast for me
#include <assert.h>
#include "qt4.hpp"
#include <assert.h>
#include "qt4.hpp"
-#include "components/playlist/playlist_model.hpp"
+#include "playlist_item.hpp"
#include <vlc_intf_strings.h>
#include <vlc_intf_strings.h>
#include "sorting.h"
/*************************************************************************
#include "sorting.h"
/*************************************************************************
-void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent, PLModel *m, QSettings *settings )
+void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent )
{
parentItem = parent; /* Can be NULL, but only for the rootItem */
i_id = _playlist_item->i_id; /* Playlist item specific id */
{
parentItem = parent; /* Can be NULL, but only for the rootItem */
i_id = _playlist_item->i_id; /* Playlist item specific id */
- model = m; /* PLModel (QAbsmodel) */
p_input = _playlist_item->p_input;
vlc_gc_incref( p_input );
p_input = _playlist_item->p_input;
vlc_gc_incref( p_input );
- assert( model ); /* We need a model */
}
/*
Constructors
Call the above function init
*/
}
/*
Constructors
Call the above function init
*/
-PLItem::PLItem( playlist_item_t *p_item, PLItem *parent, PLModel *m )
+PLItem::PLItem( playlist_item_t *p_item, PLItem *parent )
- init( p_item, parent, m, NULL );
+ init( p_item, parent );
-PLItem::PLItem( playlist_item_t * p_item, QSettings *settings, PLModel *m )
+PLItem::PLItem( playlist_item_t * p_item )
- init( p_item, NULL, m, settings );
*/
void PLItem::insertChild( PLItem *item, int i_pos, bool signal )
{
*/
void PLItem::insertChild( PLItem *item, int i_pos, bool signal )
{
- if( signal )
- model->beginInsertRows( model->index( this , 0 ), i_pos, i_pos );
children.insert( i_pos, item );
children.insert( i_pos, item );
- if( signal )
- model->endInsertRows();
-void PLItem::remove( PLItem *removed )
+void PLItem::remove( PLItem *removed, int i_depth )
- if( model->i_depth == DEPTH_SEL || parentItem )
+ if( i_depth == DEPTH_SEL || parentItem )
{
int i_index = parentItem->children.indexOf( removed );
{
int i_index = parentItem->children.indexOf( removed );
- model->beginRemoveRows( model->index( parentItem, 0 ),
- i_index, i_index );
parentItem->children.removeAt( i_index );
parentItem->children.removeAt( i_index );
- model->endRemoveRows();
{
friend class PLModel;
public:
{
friend class PLModel;
public:
- PLItem( playlist_item_t *, PLItem *parent, PLModel * );
- PLItem( playlist_item_t *, QSettings *, PLModel * );
+ PLItem( playlist_item_t *, PLItem *parent );
+ PLItem( playlist_item_t * );
~PLItem();
int row() const;
~PLItem();
int row() const;
void insertChild( PLItem *, int p, bool signal = true );
void appendChild( PLItem *item, bool signal = true )
{
void insertChild( PLItem *, int p, bool signal = true );
void appendChild( PLItem *item, bool signal = true )
{
- insertChild( item, children.count(), signal );
+ children.insert( children.count(), item );
- void remove( PLItem *removed );
+ void remove( PLItem *removed, int i_depth );
PLItem *child( int row ) { return children.value( row ); };
int childCount() const { return children.count(); };
PLItem *child( int row ) { return children.value( row ); };
int childCount() const { return children.count(); };
input_item_t *p_input;
private:
input_item_t *p_input;
private:
- void init( playlist_item_t *, PLItem *, PLModel *, QSettings * );
+ void init( playlist_item_t *, PLItem * );
{
PLItem *item = FindById( rootItem, i_id );
if( currentItem && item && currentItem->p_input == item->p_input ) currentItem = NULL;
{
PLItem *item = FindById( rootItem, i_id );
if( currentItem && item && currentItem->p_input == item->p_input ) currentItem = NULL;
- if( item ) item->remove( item );
+ if( item ) item->remove( item, i_depth );
}
/* callbacks and slots */
}
/* callbacks and slots */
int columncount = 0;
int metadata = 1;
int columncount = 0;
int metadata = 1;
- if( item->model->i_depth == DEPTH_SEL )
+ if( i_depth == DEPTH_SEL )
{
vlc_mutex_lock( &item->p_input->lock );
QString returninfo = QString( qfu( item->p_input->psz_name ) );
{
vlc_mutex_lock( &item->p_input->lock );
QString returninfo = QString( qfu( item->p_input->psz_name ) );
p_item->p_parent->i_id != rootItem->i_id )
goto end;
p_item->p_parent->i_id != rootItem->i_id )
goto end;
- newItem = new PLItem( p_item, nodeItem, this );
+ newItem = new PLItem( p_item, nodeItem );
+ emit layoutAboutToBeChanged();
+ emit beginInsertRows( index( newItem, 0 ), nodeItem->childCount(), nodeItem->childCount()+1 );
nodeItem->appendChild( newItem );
nodeItem->appendChild( newItem );
+ emit endInsertRows();
+ emit layoutChanged();
UpdateTreeItem( p_item, newItem, true );
end:
PL_UNLOCK;
UpdateTreeItem( p_item, newItem, true );
end:
PL_UNLOCK;
/* Invalidate cache */
i_cached_id = i_cached_input_id = -1;
/* Invalidate cache */
i_cached_id = i_cached_input_id = -1;
+ emit layoutAboutToBeChanged();
+
PL_LOCK;
/* Clear the tree */
if( rootItem )
{
if( rootItem->children.size() )
{
PL_LOCK;
/* Clear the tree */
if( rootItem )
{
if( rootItem->children.size() )
{
- beginRemoveRows( index( rootItem, 0 ), 0,
+ emit beginRemoveRows( index( rootItem, 0 ), 0,
rootItem->children.size() -1 );
qDeleteAll( rootItem->children );
rootItem->children.clear();
rootItem->children.size() -1 );
qDeleteAll( rootItem->children );
rootItem->children.clear();
}
}
if( p_root )
{
delete rootItem;
}
}
if( p_root )
{
delete rootItem;
- rootItem = new PLItem( p_root, getSettings(), this );
+ rootItem = new PLItem( p_root );
}
assert( rootItem );
/* Recreate from root */
}
assert( rootItem );
/* Recreate from root */
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateNodeChildren( PLItem *root )
{
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateNodeChildren( PLItem *root )
{
+ emit layoutAboutToBeChanged();
playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
UpdateNodeChildren( p_node, root );
playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
UpdateNodeChildren( p_node, root );
}
/* This function must be entered WITH the playlist lock */
}
/* This function must be entered WITH the playlist lock */
for( int i = 0; i < p_node->i_children ; i++ )
{
if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
for( int i = 0; i < p_node->i_children ; i++ )
{
if( p_node->pp_children[i]->i_flags & PLAYLIST_DBL_FLAG ) continue;
- PLItem *newItem = new PLItem( p_node->pp_children[i], root, this );
- root->appendChild( newItem, false );
- UpdateTreeItem( newItem, false, true );
+ PLItem *newItem = new PLItem( p_node->pp_children[i], root );
+ emit beginInsertRows( index( newItem, 0 ), root->childCount(), root->childCount()+1 );
+ root->appendChild( newItem );
+ emit endInsertRows();
+ UpdateTreeItem( newItem, true, true );
if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
UpdateNodeChildren( p_node->pp_children[i], newItem );
}
if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
UpdateNodeChildren( p_node->pp_children[i], newItem );
}
else
playlist_NodeDelete( p_playlist, p_item, true, false );
/* And finally, remove it from the tree */
else
playlist_NodeDelete( p_playlist, p_item, true, false );
/* And finally, remove it from the tree */
+ emit beginRemoveRows( index( item->parentItem, 0), item->parentItem->children.indexOf( item ),
+ item->parentItem->children.indexOf( item )+1 );
+ item->remove( item, i_depth );
+ emit endRemoveRows();
if( i_showflags & meta )
/* Removing columns */
{
if( i_showflags & meta )
/* Removing columns */
{
- beginRemoveColumns( parent, index, index+1 );
+ emit beginRemoveColumns( parent, index, index+1 );
i_showflags &= ~( meta );
getSettings()->setValue( "qt-pl-showflags", i_showflags );
i_showflags &= ~( meta );
getSettings()->setValue( "qt-pl-showflags", i_showflags );
+ emit endRemoveColumns();
}
else
{
/* Adding columns */
}
else
{
/* Adding columns */
- beginInsertColumns( parent, index, index+1 );
+ emit beginInsertColumns( parent, index, index+1 );
i_showflags |= meta;
getSettings()->setValue( "qt-pl-showflags", i_showflags );
i_showflags |= meta;
getSettings()->setValue( "qt-pl-showflags", i_showflags );
+ emit endInsertColumns();
}
emit columnsChanged( meta );
rebuild();
}
emit columnsChanged( meta );
rebuild();