[vlc-devel] commit: Qt: track the currentView and simplify the code ( Jean-Baptiste Kempf )

git version control git at videolan.org
Tue Jan 26 01:25:02 CET 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Jan 26 01:23:38 2010 +0100| [ede2bb15ef44639f38c2139c1a1f1eefc0678058] | committer: Jean-Baptiste Kempf 

Qt: track the currentView and simplify the code

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

 .../gui/qt4/components/playlist/standardpanel.cpp  |   22 +++++++++----------
 .../gui/qt4/components/playlist/standardpanel.hpp  |    1 +
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index ae4d309..4da7e87 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -175,14 +175,9 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
 
 void StandardPLPanel::popupPlView( const QPoint &point )
 {
-    QAbstractItemView *aView;
-    if ( treeView && treeView->isVisible() ) aView = treeView;
-    else if( iconView && iconView->isVisible() ) aView = iconView;
-    else return;
-
-    QModelIndex index = aView->indexAt( point );
-    QPoint globalPoint = aView->viewport()->mapToGlobal( point );
-    QItemSelectionModel *selection = aView->selectionModel();
+    QModelIndex index = currentView->indexAt( point );
+    QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
+    QItemSelectionModel *selection = currentView->selectionModel();
     QModelIndexList list = selection->selectedIndexes();
     model->popup( index, globalPoint, list );
 }
@@ -258,9 +253,7 @@ void StandardPLPanel::keyPressEvent( QKeyEvent *e )
 
 void StandardPLPanel::deleteSelection()
 {
-    //FIXME
-    if( !treeView ) return;
-    QItemSelectionModel *selection = treeView->selectionModel();
+    QItemSelectionModel *selection = currentView->selectionModel();
     QModelIndexList list = selection->selectedIndexes();
     model->doDelete( list );
 }
@@ -307,7 +300,7 @@ void StandardPLPanel::createTreeView()
     {
         for( int m = 1, c = 0; m != COLUMN_END; m <<= 1, c++ )
         {
-            treeView->setClumnHidden( c, !( m & COLUMN_DEFAULT ) );
+            treeView->setColumnHidden( c, !( m & COLUMN_DEFAULT ) );
             if( m == COLUMN_TITLE ) treeView->header()->resizeSection( c, 200 );
             else if( m == COLUMN_DURATION ) treeView->header()->resizeSection( c, 80 );
         }
@@ -341,11 +334,16 @@ void StandardPLPanel::toggleView()
 
         treeView->hide();
         iconView->show();
+        currentView = iconView;
     }
     else
     {
+        if( treeView == NULL )
+            createTreeView();
+
         iconView->hide();
         treeView->show();
+        currentView = treeView;
     }
 }
 
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 715583a..0da499e 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -71,6 +71,7 @@ private:
 
     QTreeView   *treeView;
     PlIconView  *iconView;
+    QAbstractItemView *currentView;
 
     int currentRootId;
     QSignalMapper *selectColumnsSigMapper;




More information about the vlc-devel mailing list