[vlc-devel] commit: Qt4: allow adding node under playlist root item (Jakob Leben )

git version control git at videolan.org
Tue Aug 18 13:57:26 CEST 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Aug 18 13:55:42 2009 +0200| [ed38849075c4039ccfb989793927f97f3a658da7] | committer: Jakob Leben 

Qt4: allow adding node under playlist root item

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

 .../gui/qt4/components/playlist/playlist_model.cpp |   34 ++++++++++++-------
 .../gui/qt4/components/playlist/standardpanel.cpp  |    1 -
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index d8ba787..be45ac8 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -941,9 +941,11 @@ void PLModel::search( const QString& search_text )
 /*********** Popup *********/
 void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
 {
-    assert( index.isValid() );
     PL_LOCK;
-    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
+    int i_id;
+    if( index.isValid() ) i_id = itemId( index );
+    else i_id = rootItem->i_id;
+    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
     if( p_item )
     {
         i_popup_item = p_item->i_id;
@@ -964,22 +966,28 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
 
         current_selection = list;
         QMenu *menu = new QMenu;
-        menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
-        menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
-        menu->addSeparator();
-        menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
-        menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
-        menu->addSeparator();
-        menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
-        if( node )
+        if( index.isValid() )
         {
+            menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
+            menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
+            menu->addSeparator();
+            menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
+            menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
             menu->addSeparator();
+            menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
+        }
+        if( node )
+        {
+            if( index.isValid() ) menu->addSeparator();
             menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
-            if( tree );
+            if( tree )
                 menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAddNode() ) );
         }
-        menu->addSeparator();
-        menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+        if( index.isValid() )
+        {
+            menu->addSeparator();
+            menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+        }
         menu->popup( point );
     }
     else
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 4ac1da2..8c1cef8 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -336,7 +336,6 @@ void StandardPLPanel::search( const QString& searchText )
 
 void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
 {
-    if( !index.isValid() ) return;
     QItemSelectionModel *selection = view->selectionModel();
     QModelIndexList list = selection->selectedIndexes();
     model->popup( index, point, list );




More information about the vlc-devel mailing list