*/
-void PLItem::init( int _i_id, int _i_input_id, bool _is_node, PLItem *parent, PLModel *m, QSettings *settings )
+void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent, PLModel *m, QSettings *settings )
{
parentItem = parent; /* Can be NULL, but only for the rootItem */
- i_id = _i_id; /* Playlist item specific id */
- i_input_id = _i_input_id; /* Identifier of the input */
+ i_id = _playlist_item->i_id; /* Playlist item specific id */
+ i_input_id = _playlist_item->p_input->i_id; /* Identifier of the input */
model = m; /* PLModel (QAbsmodel) */
i_type = -1; /* Item type - Avoid segfault */
b_current = false; /* Is the item the current Item or not */
- b_is_node = _is_node;
+ 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 */
if( model->i_depth == DEPTH_SEL ) /* Selector Panel */
{
i_showflags = 0;
- item_col_strings.append( "" );
}
else
{
{
i_showflags = parentItem->i_showflags;
//Add empty string and update() handles data appending
- item_col_strings.append( "" );
}
}
Call the above function init
So far the first constructor isn't used...
*/
-PLItem::PLItem( int _i_id, int _i_input_id, bool _is_node, PLItem *parent, PLModel *m )
+PLItem::PLItem( playlist_item_t *p_item, PLItem *parent, PLModel *m )
{
- init( _i_id, _i_input_id, _is_node, parent, m, NULL );
-}
-
-PLItem::PLItem( playlist_item_t * p_item, PLItem *parent, PLModel *m )
-{
- init( p_item->i_id, p_item->p_input->i_id, p_item->i_children > -1,
- parent, m, NULL );
+ init( p_item, parent, m, NULL );
}
PLItem::PLItem( playlist_item_t * p_item, QSettings *settings, PLModel *m )
{
- init( p_item->i_id, p_item->p_input->i_id, p_item->i_children > -1,
- NULL, m, settings );
+ init( p_item, NULL, m, settings );
}
PLItem::~PLItem()
/* Column manager */
void PLItem::updateColumnHeaders()
{
- item_col_strings.clear();
-
assert( i_showflags < COLUMN_END );
-
- for( uint32_t i_index=1; i_index < COLUMN_END; i_index <<= 1 )
- {
- if( i_showflags & i_index )
- item_col_strings.append( qfu( psz_column_title( i_index ) ) );
- }
}
/* So far signal is always true.
b_current = iscurrent;
b_is_node = p_item->i_children > -1;
- item_col_strings.clear();
-
- if( model->i_depth == 1 ) /* Selector Panel */
- {
- item_col_strings.append( qfu( p_item->p_input->psz_name ) );
- return;
- }
-
i_showflags = parentItem ? parentItem->i_showflags : i_showflags;
-
- /* Meta: ID */
- if( i_showflags & COLUMN_NUMBER )
- {
- QModelIndex idx = model->index( this, 0 );
- item_col_strings.append( QString::number( idx.row() + 1 ) );
- }
- /* Other meta informations */
- for( uint32_t i_index=2; i_index < COLUMN_END; i_index <<= 1 )
- {
- if( i_showflags & i_index )
- {
- char *psz = psz_column_meta( p_item->p_input, i_index );
- item_col_strings.append( qfu( psz ) );
- free( psz );
- }
- }
}
PLItem *item = static_cast<PLItem*>(index.internalPointer());
if( role == Qt::DisplayRole )
{
- return QVariant( item->columnString( index.column() ) );
+ int running_index = -1;
+ int columncount = 0;
+ int metadata = 1;
+
+ if( item->model->i_depth == DEPTH_SEL )
+ return QVariant( QString( qfu( item->p_input->psz_name ) ) );
+
+ while( metadata < COLUMN_END )
+ {
+ if( item->i_showflags & metadata )
+ running_index++;
+ if( running_index == index.column() )
+ break;
+ metadata <<= 1;
+ }
+
+ if( running_index != index.column() ) return QVariant();
+
+ QString returninfo;
+ if( metadata == COLUMN_NUMBER )
+ returninfo = QString::number( index.row() + 1 );
+ else
+ {
+ char *psz = psz_column_meta( item->p_input, metadata );
+ returninfo = QString( qfu( psz ) );
+ free( psz );
+ }
+ return QVariant( returninfo );
}
else if( role == Qt::DecorationRole && index.column() == 0 )
{
QVariant PLModel::headerData( int section, Qt::Orientation orientation,
int role ) const
{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- return QVariant( rootItem->columnString( section ) );
- return QVariant();
+ int metadata=1;
+ int running_index=-1;
+ if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
+ return QVariant();
+
+ if( i_depth == DEPTH_SEL ) return QVariant( QString("") );
+
+ while( metadata < COLUMN_END )
+ {
+ if( metadata & rootItem->i_showflags )
+ running_index++;
+ if( running_index == section )
+ break;
+ metadata <<= 1;
+ }
+
+ if( running_index != section ) return QVariant();
+
+ return QVariant( qfu( psz_column_title( metadata ) ) );
}
QModelIndex PLModel::index( int row, int column, const QModelIndex &parent )
int PLModel::columnCount( const QModelIndex &i) const
{
- return rootItem->item_col_strings.count();
+ int columnCount=0;
+ int metadata=1;
+ if( i_depth == DEPTH_SEL ) return 1;
+
+ while( metadata < COLUMN_END )
+ {
+ if( metadata & rootItem->i_showflags )
+ columnCount++;
+ metadata <<= 1;
+ }
+ return columnCount;
}
int PLModel::childrenCount( const QModelIndex &parent ) const
}
/* UNUSED emit layoutAboutToBeChanged(); */
- index = __MIN( index, rootItem->item_col_strings.count() );
+ index = __MIN( index, columnCount() );
QModelIndex parent = createIndex( 0, 0, rootItem );
if( rootItem->i_showflags & meta )
beginRemoveColumns( parent, index, index+1 );
rootItem->i_showflags &= ~( meta );
getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
- rootItem->updateColumnHeaders();
endRemoveColumns();
}
else
beginInsertColumns( parent, index, index+1 );
rootItem->i_showflags |= meta;
getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
- rootItem->updateColumnHeaders();
endInsertColumns();
}
emit columnsChanged( meta );