[vlc-devel] commit: Revert "Qt4: remove b_current on PLItem, and store currentIndex when it changes" (Ilkka Ollakka )
git version control
git at videolan.org
Fri Aug 14 18:29:21 CEST 2009
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Aug 14 19:27:27 2009 +0300| [1cadbc438d7b7991bb2947a34d7e8bc35be0ff61] | committer: Ilkka Ollakka
Revert "Qt4: remove b_current on PLItem, and store currentIndex when it changes"
This reverts commit 753731a2c9d0fd724cc7c2fd6ad573483876bc7a.
Didn't afterall worked correctly even thought I thought I tested it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cadbc438d7b7991bb2947a34d7e8bc35be0ff61
---
.../gui/qt4/components/playlist/playlist_item.cpp | 4 +++-
.../gui/qt4/components/playlist/playlist_item.hpp | 3 ++-
.../gui/qt4/components/playlist/playlist_model.cpp | 14 +++++---------
.../gui/qt4/components/playlist/playlist_model.hpp | 3 +--
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_item.cpp b/modules/gui/qt4/components/playlist/playlist_item.cpp
index f160328..694fcaf 100644
--- a/modules/gui/qt4/components/playlist/playlist_item.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_item.cpp
@@ -54,6 +54,7 @@ void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent, PLModel *m,
i_id = _playlist_item->i_id; /* Playlist item specific id */
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 = _playlist_item->i_children > -1;
p_input = _playlist_item->p_input;
vlc_gc_incref( p_input );
@@ -138,12 +139,13 @@ int PLItem::row() const
}
/* update the PL Item, get the good names and so on */
-void PLItem::update( playlist_item_t *p_item )
+void PLItem::update( playlist_item_t *p_item, bool iscurrent )
{
assert( p_item->p_input == p_input);
/* Useful for the model */
i_type = p_item->p_input->i_type;
+ b_current = iscurrent;
b_is_node = p_item->i_children > -1;
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 c8cb2c6..48fd164 100644
--- a/modules/gui/qt4/components/playlist/playlist_item.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_item.hpp
@@ -59,10 +59,11 @@ public:
PLItem *parent() { return parentItem; };
- void update( playlist_item_t * );
+ void update( playlist_item_t *, bool );
protected:
QList<PLItem*> children;
+ bool b_current;
int i_type;
int i_id;
int i_showflags;
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 33e6dd2..b2afe6b 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -77,7 +77,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
i_cached_id = -1;
i_cached_input_id = -1;
i_popup_item = i_popup_parent = -1;
- currentIndex = QModelIndex();
rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
@@ -371,7 +370,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
}
else if( role == Qt::FontRole )
{
- if( isCurrent( index ) )
+ if( item->b_current == true )
{
QFont f; f.setBold( true ); return QVariant( f );
}
@@ -379,12 +378,10 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
return QVariant();
}
-bool PLModel::isCurrent( const QModelIndex &index ) const
+bool PLModel::isCurrent( const QModelIndex &index )
{
assert( index.isValid() );
- if(!currentIndex.isValid()) return false;
- return static_cast<PLItem*>(index.internalPointer())->p_input ==
- static_cast<PLItem*>(currentIndex.internalPointer())->p_input;
+ return static_cast<PLItem*>(index.internalPointer())->b_current;
}
int PLModel::itemId( const QModelIndex &index ) const
@@ -650,7 +647,6 @@ void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
{
PLItem *item = FindByInput( rootItem, input_GetItem( p_input )->i_id );
emit currentChanged( index( item, 0 ) );
- currentIndex = index( item, 0 );
}
}
void PLModel::ProcessInputItemUpdate( input_item_t *p_item )
@@ -786,9 +782,9 @@ void PLModel::UpdateTreeItem( playlist_item_t *p_item, PLItem *item,
if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
p_item->p_parent->i_id != rootItem->i_id )
return;
- item->update( p_item );
+ item->update( p_item, p_item == playlist_CurrentPlayingItem( p_playlist ) );
if( signal )
- emit dataChanged( index( item, 0 ) , index( item, columnCount( QModelIndex() ) ) );
+ emit dataChanged( index( item, 0 ) , index( item, 1 ) );
}
/************************* Actions ******************************/
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index e09ac76..124e198 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -98,7 +98,7 @@ public:
QModelIndex index( int r, int c, const QModelIndex &parent ) const;
QModelIndex index( PLItem *, int c ) const;
int itemId( const QModelIndex &index ) const;
- bool isCurrent( const QModelIndex &index ) const;
+ bool isCurrent( const QModelIndex &index );
QModelIndex parent( const QModelIndex &index ) const;
int childrenCount( const QModelIndex &parent = QModelIndex() ) const;
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
@@ -155,7 +155,6 @@ private:
/* Popup */
int i_popup_item, i_popup_parent;
QModelIndexList current_selection;
- QModelIndex currentIndex;
QSignalMapper *ContextUpdateMapper;
/* Lookups */
More information about the vlc-devel
mailing list