]> git.sesse.net Git - vlc/commitdiff
Qt: add rename directory option
authorEdward Wang <edward.c.wang@compdigitec.com>
Sat, 12 Oct 2013 04:13:09 +0000 (00:13 -0400)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 12 Oct 2013 20:07:51 +0000 (22:07 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
include/vlc_intf_strings.h
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/vlc_model.hpp

index c075c98c6b869684955a93147e5311e530fffc14..25c57b37172dd9463d882efdf74d329949a07d03 100644 (file)
@@ -67,6 +67,8 @@
 #define I_POP_INFO N_("Information...")
 #define I_POP_NEWFOLDER I_DIR_OR_FOLDER( N_("Create Directory..."), \
                                          N_("Create Folder...") )
+#define I_POP_RENAMEFOLDER I_DIR_OR_FOLDER( N_("Rename Directory..."), \
+                                         N_("Rename Folder...") )
 #define I_POP_EXPLORE I_DIR_OR_FOLDER( N_("Show Containing Directory..."), \
                                        N_("Show Containing Folder...") )
 #define I_POP_STREAM N_("Stream...")
index 0c7e762a6f4abee6c8f6a172be8a98724a3689b7..92530adf26e0f35089b563cde4157375d1cfdfd8 100644 (file)
@@ -957,6 +957,19 @@ void PLModel::createNode( QModelIndex index, QString name )
     PL_UNLOCK;
 }
 
+void PLModel::renameNode( QModelIndex index, QString name )
+{
+    if( name.isEmpty() || !index.isValid() ) return;
+
+    PL_LOCK;
+    if ( !index.isValid() ) index = rootIndex();
+    input_item_t* p_input = this->getInputItem( index );
+    input_item_SetName( p_input, qtu( name ) );
+    playlist_t *p_playlist = pl_Get( p_intf );
+    input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
+    PL_UNLOCK;
+}
+
 bool PLModel::action( QAction *action, const QModelIndexList &indexes )
 {
     QModelIndex index;
@@ -1077,6 +1090,9 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
             return getURI( index ).startsWith( "file://" );
     case ACTION_CREATENODE:
         return ( canEdit() && isTree() );
+    case ACTION_RENAMENODE:
+        return ( index != rootIndex() ) && !isLeaf( index );
+        break;
     case ACTION_CLEAR:
         return rowCount() && canEdit();
     case ACTION_ENQUEUEFILE:
index 1434f1b160d7e6f227ca53dac4b1d1f2a978ad58..2ebba86f6712df19fc6989d198b9249de1b94ee7 100644 (file)
@@ -76,6 +76,7 @@ public:
     virtual void rebuild( playlist_item_t * p = NULL ) { model()->rebuild( p ); }
     virtual void doDelete( QModelIndexList list ) { model()->doDelete( mapListToSource( list ) ); }
     virtual void createNode( QModelIndex a, QString b ) { model()->createNode( mapToSource( a ), b ); }
+    virtual void renameNode( QModelIndex a, QString b ) { model()->renameNode( mapToSource( a ), b ); }
     virtual void removeAll() { model()->removeAll(); }
 
     virtual QModelIndex rootIndex() const { return mapFromSource( model()->rootIndex() ); }
@@ -165,6 +166,7 @@ public:
     virtual void rebuild( playlist_item_t * p = NULL );
     virtual void doDelete( QModelIndexList selected );
     virtual void createNode( QModelIndex index, QString name );
+    virtual void renameNode( QModelIndex index, QString name );
     virtual void removeAll();
 
     /* Lookups */
index 2cc7e189bb99864a8e1a5e8cf07b9dcd768a2387..9642722037a9bc8e85ab425206e1d79ffa5d111f 100644 (file)
     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>
@@ -198,6 +204,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),
@@ -325,6 +334,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;
index 45f6cab68002386671d686e0926183a81d6dbcf2..fb7571d603433bc9addebca9ad7c56b120cd8a30 100644 (file)
@@ -65,6 +65,7 @@ public:
     virtual void rebuild( playlist_item_t * p = NULL ) = 0;
     virtual void doDelete( QModelIndexList ) = 0;
     virtual void createNode( QModelIndex, QString ) = 0;
+    virtual void renameNode( QModelIndex, QString ) = 0;
     virtual void removeAll() = 0;
 
     virtual QModelIndex rootIndex() const = 0;
@@ -89,6 +90,7 @@ public:
         ACTION_SORT,
         ACTION_EXPLORE,
         ACTION_CREATENODE,
+        ACTION_RENAMENODE,
         ACTION_CLEAR,
         ACTION_ENQUEUEFILE,
         ACTION_ENQUEUEDIR,