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