#include <assert.h>
#include "qt4.hpp"
-#include "components/playlist/playlist_model.hpp"
+#include "playlist_item.hpp"
#include <vlc_intf_strings.h>
-#include <QSettings>
-
#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 */
- model = m; /* PLModel (QAbsmodel) */
- i_type = -1; /* Item type - Avoid segfault */
- b_is_node = _playlist_item->i_children > -1;
p_input = _playlist_item->p_input;
vlc_gc_incref( p_input );
- assert( model ); /* We need a model */
-
- /* No parent, should be the 2 main ones */
- if( parentItem == NULL )
- {
- if( model->i_depth == DEPTH_SEL ) /* Selector Panel */
- {
- i_showflags = 0;
- }
- else
- {
- i_showflags = settings->value( "qt-pl-showflags", COLUMN_DEFAULT ).toInt();
- if( i_showflags < 1)
- i_showflags = COLUMN_DEFAULT; /* reasonable default to show something; */
- else if ( i_showflags >= COLUMN_END )
- i_showflags = COLUMN_END - 1; /* show everything */
-
- }
- }
- else
- {
- i_showflags = parentItem->i_showflags;
- }
}
/*
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 );
+ init( p_item, NULL );
}
PLItem::~PLItem()
*/
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 );
- if( signal )
- model->endInsertRows();
}
-void PLItem::remove( PLItem *removed )
+void PLItem::removeChild( PLItem *item )
+{
+ children.removeOne( item );
+ delete item;
+}
+
+void PLItem::removeChildren()
+{
+ qDeleteAll( children );
+ children.clear();
+}
+
+void PLItem::takeChildAt( int index )
{
- if( model->i_depth == DEPTH_SEL || parentItem )
- {
- int i_index = parentItem->children.indexOf( removed );
- model->beginRemoveRows( model->index( parentItem, 0 ),
- i_index, i_index );
- parentItem->children.removeAt( i_index );
- model->endRemoveRows();
- }
+ PLItem *child = children[index];
+ child->parentItem = NULL;
+ children.removeAt( index );
}
/* This function is used to get one's parent's row number in the model */
return 0;
}
-/* update the PL Item, get the good names and so on */
-void PLItem::update( playlist_item_t *p_item )
-{
- assert( p_item->p_input == p_input);
-
- /* Useful for the model */
- i_type = p_item->p_input->i_type;
- b_is_node = p_item->i_children > -1;
-
- i_showflags = parentItem ? parentItem->i_showflags : i_showflags;
-}
-