Commit a45d4754 authored by Ilkka Ollakka's avatar Ilkka Ollakka

qt4: store showflags in playlist_model instead every PLItem

we don't use per-item showflags anyway, as currently they are all same
on model-wide. And I didn't comeup any use-case currently that would
need per-item showflags.
parent f85eafb4
......@@ -58,28 +58,6 @@ void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent, PLModel *m,
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;
}
}
/*
......@@ -144,6 +122,5 @@ void PLItem::update( playlist_item_t *p_item )
/* Useful for the model */
i_type = p_item->p_input->i_type;
i_showflags = parentItem ? parentItem->i_showflags : i_showflags;
}
......@@ -65,7 +65,6 @@ protected:
QList<PLItem*> children;
int i_type;
int i_id;
int i_showflags;
input_item_t *p_input;
private:
......
......@@ -81,6 +81,17 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
if( i_depth == DEPTH_SEL )
i_showflags = 0;
else
{
i_showflags = getSettings()->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 */
}
/* Icons initialization */
#define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( x ) )
ADD_ICON( UNKNOWN , type_unknown_xpm );
......@@ -116,7 +127,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
PLModel::~PLModel()
{
if(i_depth == -1)
getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
getSettings()->setValue( "qt-pl-showflags", i_showflags );
delCallbacks();
delete rootItem;
}
......@@ -356,7 +367,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
while( metadata < COLUMN_END )
{
if( item->i_showflags & metadata )
if( i_showflags & metadata )
running_index++;
if( running_index == index.column() )
break;
......@@ -417,7 +428,7 @@ QVariant PLModel::headerData( int section, Qt::Orientation orientation,
while( metadata < COLUMN_END )
{
if( metadata & rootItem->i_showflags )
if( metadata & i_showflags )
running_index++;
if( running_index == section )
break;
......@@ -487,7 +498,7 @@ int PLModel::columnCount( const QModelIndex &i) const
while( metadata < COLUMN_END )
{
if( metadata & rootItem->i_showflags )
if( metadata & i_showflags )
columnCount++;
metadata <<= 1;
}
......@@ -971,20 +982,20 @@ void PLModel::viewchanged( int meta )
index = __MIN( index, columnCount() );
QModelIndex parent = createIndex( 0, 0, rootItem );
if( rootItem->i_showflags & meta )
if( i_showflags & meta )
/* Removing columns */
{
beginRemoveColumns( parent, index, index+1 );
rootItem->i_showflags &= ~( meta );
getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
i_showflags &= ~( meta );
getSettings()->setValue( "qt-pl-showflags", i_showflags );
endRemoveColumns();
}
else
{
/* Adding columns */
beginInsertColumns( parent, index, index+1 );
rootItem->i_showflags |= meta;
getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
i_showflags |= meta;
getSettings()->setValue( "qt-pl-showflags", i_showflags );
endInsertColumns();
}
emit columnsChanged( meta );
......
......@@ -124,7 +124,7 @@ public:
int row, int column, const QModelIndex &target );
QStringList mimeTypes() const;
int shownFlags() { return rootItem->i_showflags; }
int shownFlags() { return i_showflags; }
private:
void addCallbacks();
......@@ -137,6 +137,7 @@ private:
playlist_t *p_playlist;
intf_thread_t *p_intf;
int i_depth;
int i_showflags;
static QIcon icons[ITEM_TYPE_NUMBER];
......
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