mirror of
https://github.com/videolan/vlc.git
synced 2024-12-12 03:06:13 +08:00
Qt: add rename directory option
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
This commit is contained in:
parent
f217d32de8
commit
ab81a8461d
@ -67,6 +67,8 @@
|
|||||||
#define I_POP_INFO N_("Information...")
|
#define I_POP_INFO N_("Information...")
|
||||||
#define I_POP_NEWFOLDER I_DIR_OR_FOLDER( N_("Create Directory..."), \
|
#define I_POP_NEWFOLDER I_DIR_OR_FOLDER( N_("Create Directory..."), \
|
||||||
N_("Create Folder...") )
|
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..."), \
|
#define I_POP_EXPLORE I_DIR_OR_FOLDER( N_("Show Containing Directory..."), \
|
||||||
N_("Show Containing Folder...") )
|
N_("Show Containing Folder...") )
|
||||||
#define I_POP_STREAM N_("Stream...")
|
#define I_POP_STREAM N_("Stream...")
|
||||||
|
@ -957,6 +957,19 @@ void PLModel::createNode( QModelIndex index, QString name )
|
|||||||
PL_UNLOCK;
|
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 )
|
bool PLModel::action( QAction *action, const QModelIndexList &indexes )
|
||||||
{
|
{
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
@ -1077,6 +1090,9 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
|
|||||||
return getURI( index ).startsWith( "file://" );
|
return getURI( index ).startsWith( "file://" );
|
||||||
case ACTION_CREATENODE:
|
case ACTION_CREATENODE:
|
||||||
return ( canEdit() && isTree() );
|
return ( canEdit() && isTree() );
|
||||||
|
case ACTION_RENAMENODE:
|
||||||
|
return ( index != rootIndex() ) && !isLeaf( index );
|
||||||
|
break;
|
||||||
case ACTION_CLEAR:
|
case ACTION_CLEAR:
|
||||||
return rowCount() && canEdit();
|
return rowCount() && canEdit();
|
||||||
case ACTION_ENQUEUEFILE:
|
case ACTION_ENQUEUEFILE:
|
||||||
|
@ -76,6 +76,7 @@ public:
|
|||||||
virtual void rebuild( playlist_item_t * p = NULL ) { model()->rebuild( p ); }
|
virtual void rebuild( playlist_item_t * p = NULL ) { model()->rebuild( p ); }
|
||||||
virtual void doDelete( QModelIndexList list ) { model()->doDelete( mapListToSource( list ) ); }
|
virtual void doDelete( QModelIndexList list ) { model()->doDelete( mapListToSource( list ) ); }
|
||||||
virtual void createNode( QModelIndex a, QString b ) { model()->createNode( mapToSource( a ), b ); }
|
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 void removeAll() { model()->removeAll(); }
|
||||||
|
|
||||||
virtual QModelIndex rootIndex() const { return mapFromSource( model()->rootIndex() ); }
|
virtual QModelIndex rootIndex() const { return mapFromSource( model()->rootIndex() ); }
|
||||||
@ -165,6 +166,7 @@ public:
|
|||||||
virtual void rebuild( playlist_item_t * p = NULL );
|
virtual void rebuild( playlist_item_t * p = NULL );
|
||||||
virtual void doDelete( QModelIndexList selected );
|
virtual void doDelete( QModelIndexList selected );
|
||||||
virtual void createNode( QModelIndex index, QString name );
|
virtual void createNode( QModelIndex index, QString name );
|
||||||
|
virtual void renameNode( QModelIndex index, QString name );
|
||||||
virtual void removeAll();
|
virtual void removeAll();
|
||||||
|
|
||||||
/* Lookups */
|
/* Lookups */
|
||||||
|
@ -51,6 +51,12 @@
|
|||||||
I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
|
I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
|
||||||
N_( "Enter name for new folder:" ) )
|
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 <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -198,6 +204,9 @@ bool StandardPLPanel::popup( const QPoint &point )
|
|||||||
ADD_MENU_ENTRY( addIcon, qtr(I_POP_NEWFOLDER),
|
ADD_MENU_ENTRY( addIcon, qtr(I_POP_NEWFOLDER),
|
||||||
VLCModelSubInterface::ACTION_CREATENODE )
|
VLCModelSubInterface::ACTION_CREATENODE )
|
||||||
|
|
||||||
|
ADD_MENU_ENTRY( QIcon(), qtr(I_POP_RENAMEFOLDER),
|
||||||
|
VLCModelSubInterface::ACTION_RENAMENODE )
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
/* In PL or ML, allow to add a file/folder */
|
/* In PL or ML, allow to add a file/folder */
|
||||||
ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDF),
|
ADD_MENU_ENTRY( addIcon, qtr(I_PL_ADDF),
|
||||||
@ -325,6 +334,14 @@ void StandardPLPanel::popupAction( QAction *action )
|
|||||||
model->createNode( index, temp );
|
model->createNode( index, temp );
|
||||||
break;
|
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:
|
case VLCModelSubInterface::ACTION_ENQUEUEFILE:
|
||||||
uris = THEDP->showSimpleOpen();
|
uris = THEDP->showSimpleOpen();
|
||||||
if ( uris.isEmpty() ) return;
|
if ( uris.isEmpty() ) return;
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
virtual void rebuild( playlist_item_t * p = NULL ) = 0;
|
virtual void rebuild( playlist_item_t * p = NULL ) = 0;
|
||||||
virtual void doDelete( QModelIndexList ) = 0;
|
virtual void doDelete( QModelIndexList ) = 0;
|
||||||
virtual void createNode( QModelIndex, QString ) = 0;
|
virtual void createNode( QModelIndex, QString ) = 0;
|
||||||
|
virtual void renameNode( QModelIndex, QString ) = 0;
|
||||||
virtual void removeAll() = 0;
|
virtual void removeAll() = 0;
|
||||||
|
|
||||||
virtual QModelIndex rootIndex() const = 0;
|
virtual QModelIndex rootIndex() const = 0;
|
||||||
@ -89,6 +90,7 @@ public:
|
|||||||
ACTION_SORT,
|
ACTION_SORT,
|
||||||
ACTION_EXPLORE,
|
ACTION_EXPLORE,
|
||||||
ACTION_CREATENODE,
|
ACTION_CREATENODE,
|
||||||
|
ACTION_RENAMENODE,
|
||||||
ACTION_CLEAR,
|
ACTION_CLEAR,
|
||||||
ACTION_ENQUEUEFILE,
|
ACTION_ENQUEUEFILE,
|
||||||
ACTION_ENQUEUEDIR,
|
ACTION_ENQUEUEDIR,
|
||||||
|
Loading…
Reference in New Issue
Block a user