diff --git a/include/vlc_intf_strings.h b/include/vlc_intf_strings.h index c075c98c6b..25c57b3717 100644 --- a/include/vlc_intf_strings.h +++ b/include/vlc_intf_strings.h @@ -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...") diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp index 0c7e762a6f..92530adf26 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.cpp +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp @@ -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: diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp index 1434f1b160..2ebba86f67 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.hpp +++ b/modules/gui/qt4/components/playlist/playlist_model.hpp @@ -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 */ diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 2cc7e189bb..9642722037 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -51,6 +51,12 @@ 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 #include #include @@ -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; diff --git a/modules/gui/qt4/components/playlist/vlc_model.hpp b/modules/gui/qt4/components/playlist/vlc_model.hpp index 45f6cab680..fb7571d603 100644 --- a/modules/gui/qt4/components/playlist/vlc_model.hpp +++ b/modules/gui/qt4/components/playlist/vlc_model.hpp @@ -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,