[vlc-devel] commit: qt4: store showflags in playlist_model instead every PLItem ( Ilkka Ollakka )
git version control
git at videolan.org
Sun Aug 16 14:33:12 CEST 2009
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Aug 16 15:31:15 2009 +0300| [a45d47543a6e71ecd1ede201c6e90304c2c4e8d3] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a45d47543a6e71ecd1ede201c6e90304c2c4e8d3
---
.../gui/qt4/components/playlist/playlist_item.cpp | 23 ---------------
.../gui/qt4/components/playlist/playlist_item.hpp | 1 -
.../gui/qt4/components/playlist/playlist_model.cpp | 29 +++++++++++++------
.../gui/qt4/components/playlist/playlist_model.hpp | 3 +-
4 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_item.cpp b/modules/gui/qt4/components/playlist/playlist_item.cpp
index 6c0c3a3..8d49500 100644
--- a/modules/gui/qt4/components/playlist/playlist_item.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_item.cpp
@@ -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;
}
diff --git a/modules/gui/qt4/components/playlist/playlist_item.hpp b/modules/gui/qt4/components/playlist/playlist_item.hpp
index c5734f3..da34983 100644
--- a/modules/gui/qt4/components/playlist/playlist_item.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_item.hpp
@@ -65,7 +65,6 @@ protected:
QList<PLItem*> children;
int i_type;
int i_id;
- int i_showflags;
input_item_t *p_input;
private:
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 91a1c7e..9b191fa 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 41fb688..6a84f83 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -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];
More information about the vlc-devel
mailing list