]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/standardpanel.cpp
Adds batch convert support to the VLC GUI.
[vlc] / modules / gui / qt4 / components / playlist / standardpanel.cpp
index f528dfa9f2be91c69bf4dd4566299b09fdd4788f..eb99f1bef3e210bf7d8b46de7014478132afc623 100644 (file)
 
 #include "components/playlist/vlc_model.hpp"      /* VLCModel */
 #include "components/playlist/playlist_model.hpp" /* PLModel */
-#include "components/playlist/ml_model.hpp"       /* MLModel */
 #include "components/playlist/views.hpp"          /* 3 views */
 #include "components/playlist/selector.hpp"       /* PLSelector */
-#include "util/customwidgets.hpp"                 /* PixmapAnimator */
+#include "util/animators.hpp"                     /* PixmapAnimator */
 #include "menus.hpp"                              /* Popup */
 #include "input_manager.hpp"                      /* THEMIM */
 #include "dialogs_provider.hpp"                   /* THEDP */
     I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
                      N_( "Enter name for new folder:" ) )
 
+#define I_RENAME_DIR \
+    I_DIR_OR_FOLDER( N_("Rename Directory"), N_( "Rename Folder" ) )
+#define I_RENAME_DIR_NAME \
+    I_DIR_OR_FOLDER( N_( "Enter a new name for the directory:" ), \
+                     N_( "Enter a new name for the folder:" ) )
+
 #include <QHeaderView>
 #include <QMenu>
 #include <QKeyEvent>
@@ -73,7 +78,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_item_t *p_root,
                                   PLSelector *_p_selector,
-                                  VLCProxyModel *_p_model )
+                                  VLCModel *_p_model )
                 : QWidget( _parent ),
                   model( _p_model ),
                   p_intf( _p_intf ),
@@ -108,9 +113,9 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     DCONNECT( THEMIM, leafBecameParent( int ),
               this, browseInto( int ) );
 
-    CONNECT( model->sigs, currentIndexChanged( const QModelIndex& ),
+    CONNECT( model, currentIndexChanged( const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
-    CONNECT( model->sigs, rootIndexChanged(), this, browseInto() );
+    CONNECT( model, rootIndexChanged(), this, browseInto() );
 
     setRootItem( p_root, false );
 }
@@ -152,14 +157,14 @@ void StandardPLPanel::popupPlView( const QPoint &point )
         currentView->selectionModel()->select( index, QItemSelectionModel::Select );
     }
 
-    if( !popup( globalPoint ) ) VLCMenuBar::PopupMenu( p_intf, true );
+    if( !popup( globalPoint ) ) THEDP->setPopupMenu();
 }
 
 /*********** Popup *********/
 bool StandardPLPanel::popup( const QPoint &point )
 {
     QModelIndex index = popupIndex( currentView ); /* index for menu logic only. Do not store.*/
-    VLCProxyModel *model = qobject_cast<VLCProxyModel *>(currentView->model());
+    VLCModel *model = qobject_cast<VLCModel *>(currentView->model());
 
 #define ADD_MENU_ENTRY( icon, title, act ) \
     if ( model->isSupportedAction( act, index ) )\
@@ -198,6 +203,9 @@ bool StandardPLPanel::popup( const QPoint &point )
     ADD_MENU_ENTRY( addIcon, qtr(I_POP_NEWFOLDER),
                     VLCModelSubInterface::ACTION_CREATENODE )
 
+    ADD_MENU_ENTRY( QIcon(), qtr(I_POP_RENAMEFOLDER),
+                    VLCModelSubInterface::ACTION_RENAMENODE )
+
     menu.addSeparator();
     /* In PL or ML, allow to add a file/folder */
     ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDF),
@@ -212,6 +220,10 @@ bool StandardPLPanel::popup( const QPoint &point )
     ADD_MENU_ENTRY( QIcon(), qtr(I_PL_ADDPL),
                     VLCModelSubInterface::ACTION_ADDTOPLAYLIST );
 
+    menu.addSeparator();
+    ADD_MENU_ENTRY( QIcon(), qtr( I_PL_SAVE ),
+                    VLCModelSubInterface::ACTION_SAVETOPLAYLIST );
+
     menu.addSeparator();
 
     /* Item removal */
@@ -267,7 +279,7 @@ bool StandardPLPanel::popup( const QPoint &point )
 
 void StandardPLPanel::popupAction( QAction *action )
 {
-    VLCProxyModel *model = qobject_cast<VLCProxyModel *>(currentView->model());
+    VLCModel *model = qobject_cast<VLCModel *>(currentView->model());
     VLCModelSubInterface::actionsContainerType a =
             action->data().value<VLCModelSubInterface::actionsContainerType>();
     QModelIndexList list = currentView->selectionModel()->selectedRows();
@@ -296,7 +308,7 @@ void StandardPLPanel::popupAction( QAction *action )
     case VLCModelSubInterface::ACTION_EXPLORE:
         /* locally handled only */
         temp = model->getURI( index );
-        if( ! temp.isEmpty() ) path = make_path( temp.toAscii().constData() );
+        if( ! temp.isEmpty() ) path = make_path( temp.toLatin1().constData() );
         if( path == NULL ) return;
         QDesktopServices::openUrl(
                     QUrl::fromLocalFile( QFileInfo( qfu( path ) ).absolutePath() ) );
@@ -307,14 +319,22 @@ void StandardPLPanel::popupAction( QAction *action )
         /* locally handled only */
         temp = model->getURI( index );
         if ( ! temp.isEmpty() )
-            THEDP->streamingDialog( NULL, temp, false );
+        {
+            QStringList tempList;
+            tempList.append(temp);
+            THEDP->streamingDialog( NULL, tempList, false );
+        }
         break;
 
     case VLCModelSubInterface::ACTION_SAVE:
         /* locally handled only */
         temp = model->getURI( index );
         if ( ! temp.isEmpty() )
-            THEDP->streamingDialog( NULL, temp );
+        {
+            QStringList tempList;
+            tempList.append(temp);
+            THEDP->streamingDialog( NULL, tempList );
+        }
         break;
 
     case VLCModelSubInterface::ACTION_CREATENODE:
@@ -325,6 +345,14 @@ void StandardPLPanel::popupAction( QAction *action )
         model->createNode( index, temp );
         break;
 
+    case VLCModelSubInterface::ACTION_RENAMENODE:
+        temp = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
+            qtr( I_RENAME_DIR ), qtr( I_RENAME_DIR_NAME ),
+            QLineEdit::Normal, model->getTitle( index ), &ok);
+        if ( !ok ) return;
+        model->renameNode( index, temp );
+        break;
+
     case VLCModelSubInterface::ACTION_ENQUEUEFILE:
         uris = THEDP->showSimpleOpen();
         if ( uris.isEmpty() ) return;
@@ -338,7 +366,7 @@ void StandardPLPanel::popupAction( QAction *action )
         break;
 
     case VLCModelSubInterface::ACTION_ENQUEUEDIR:
-        temp = THEDP->getDirectoryDialog();
+        temp = DialogsProvider::getDirectoryDialog( p_intf );
         if ( temp.isEmpty() ) return;
         a.uris << temp;
         action->setData( QVariant::fromValue( a ) );
@@ -358,6 +386,9 @@ void StandardPLPanel::popupAction( QAction *action )
                 RecentsMRL::getInstance( p_intf )->addRecent( file );
         break;
 
+    case VLCModelSubInterface::ACTION_SAVETOPLAYLIST:
+        THEDP->savePlayingToPlaylist();
+        break;
     default:
         model->action( action, list );
     }
@@ -454,21 +485,8 @@ void StandardPLPanel::searchDelayed( const QString& searchText )
 /* This activated by the selector selection */
 void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
 {
-#ifdef SQL_MEDIA_LIBRARY
-    if( b )
-    {
-        msg_Dbg( p_intf, "Setting the SQL ML" );
-        if ( model->switchToModel( VLCProxyModel::SQLML_MODEL ) )
-            currentView->setModel( model );
-    }
-    else
-#else
     Q_UNUSED( b );
-#endif
-    {
-        if ( model->switchToModel( VLCProxyModel::PL_MODEL ) )
-            model->rebuild( p_item );
-    }
+    model->rebuild( p_item );
 }
 
 void StandardPLPanel::browseInto( const QModelIndex &index )
@@ -786,10 +804,13 @@ void StandardPLPanel::activate( const QModelIndex &index )
         {
             playlist_Lock( THEPL );
             playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index, PLAYLIST_ID ) );
-            p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
-            lastActivatedPLItemId = p_item->i_id;
+            if ( p_item )
+            {
+                p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
+                lastActivatedPLItemId = p_item->i_id;
+            }
             playlist_Unlock( THEPL );
-            if ( index.isValid() )
+            if ( p_item && index.isValid() )
                 model->activateItem( index );
         }
     }