[vlc-devel] commit: QT4: only scroll playlist to new item when it changes ( Ilkka Ollakka )

git version control git at videolan.org
Sat Jul 25 14:29:07 CEST 2009


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Jul 25 15:26:07 2009 +0300| [5f81bec53ccae76400188a5baa9d7ce099fdadef] | committer: Ilkka Ollakka 

QT4: only scroll playlist to new item when it changes

should fix bug #2947 ,now it scrolls to new item when theres actual
input-change, not just data changed.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f81bec53ccae76400188a5baa9d7ce099fdadef
---

 .../gui/qt4/components/playlist/playlist_model.cpp |    5 +++++
 .../gui/qt4/components/playlist/playlist_model.hpp |    2 ++
 .../gui/qt4/components/playlist/standardpanel.cpp  |   10 ++++------
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index f17b7df..998ebb2 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -530,6 +530,11 @@ void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
 {
     if( !p_input ) return;
     ProcessInputItemUpdate( input_GetItem( p_input )->i_id );
+    if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
+    {
+        PLItem *item = FindByInput( rootItem, input_GetItem( p_input )->i_id );
+        emit currentChanged( index( item, 0 ) );
+    }
 }
 void PLModel::ProcessInputItemUpdate( int i_input_id )
 {
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 6e55161..a28c3a8 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -167,6 +167,8 @@ private:
     int i_cached_input_id;
 signals:
     void shouldRemove( int );
+    void currentChanged( const QModelIndex& );
+
 
 public slots:
     void activateItem( const QModelIndex &index );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 7b41816..51cb0f9 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -72,7 +72,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     view->setDragEnabled( true );
     view->setAcceptDrops( true );
     view->setDropIndicatorShown( true );
-    view->setAutoScroll( true );
 
 
     getSettings()->beginGroup("Playlist");
@@ -97,10 +96,10 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
              model,activateItem( const QModelIndex& ) );
     CONNECT( view, rightClicked( QModelIndex , QPoint ),
              this, doPopup( QModelIndex, QPoint ) );
-    CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
-             this, handleExpansion( const QModelIndex& ) );
     CONNECT( view->header(), customContextMenuRequested( const QPoint & ),
              this, popupSelectColumn( QPoint ) );
+    CONNECT( model, currentChanged( const QModelIndex& ),
+             this, handleExpansion( const QModelIndex& ) );
 
     currentRootId = -1;
     CONNECT( parent, rootChanged( int ), this, setCurrentRootId( int ) );
@@ -207,10 +206,9 @@ void StandardPLPanel::gotoPlayingItem()
     view->scrollTo( view->currentIndex() );
 }
 
-void StandardPLPanel::handleExpansion( const QModelIndex &index )
+void StandardPLPanel::handleExpansion( const QModelIndex& index )
 {
-    if( model->isCurrent( index ) )
-        view->scrollTo( index, QAbstractItemView::EnsureVisible );
+    view->scrollTo( index, QAbstractItemView::EnsureVisible );
 }
 
 void StandardPLPanel::setCurrentRootId( int _new )




More information about the vlc-devel mailing list