[vlc-devel] commit: Qt: include Add File/Directory/ Advanced Open actions in playlist right-click menu (Jakob Leben )
git version control
git at videolan.org
Sun Feb 14 06:43:06 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sun Feb 14 05:42:09 2010 +0100| [0c323ab08961702f5c0bd7787645b49663a14462] | committer: Jakob Leben
Qt: include Add File/Directory/Advanced Open actions in playlist right-click menu
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c323ab08961702f5c0bd7787645b49663a14462
---
.../gui/qt4/components/playlist/playlist_model.cpp | 43 +++++++++++++++-----
.../gui/qt4/components/playlist/playlist_model.hpp | 2 +-
.../gui/qt4/components/playlist/standardpanel.cpp | 12 ++----
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 05c0ffc..7952b66 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -869,7 +869,7 @@ void PLModel::search( const QString& search_text, const QModelIndex & idx, bool
}
/*********** Popup *********/
-void PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
+bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list )
{
int i_id = index.isValid() ? itemId( index ) : rootItem->i_id;
@@ -877,12 +877,14 @@ void PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
if( !p_item )
{
- PL_UNLOCK; return;
+ PL_UNLOCK;
+ return false;
}
+
i_popup_item = index.isValid() ? p_item->i_id : -1;
i_popup_parent = index.isValid() ?
( p_item->p_parent ? p_item->p_parent->i_id : -1 ) :
- ( p_item->i_id );
+ ( rootItem->i_id );
i_popup_column = index.column();
bool tree = var_InheritBool( p_intf, "playlist-tree" );
@@ -901,22 +903,41 @@ void PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
menu.addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
menu.addSeparator();
menu.addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
+ menu.addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+ }
+ if( canEdit() )
+ {
menu.addSeparator();
- QMenu *sort_menu = menu.addMenu( qtr( "Sort by ") +
+ if( tree ) menu.addAction( qtr(I_POP_ADD) + QString("..."), this, SLOT( popupAddNode() ) );
+ if( rootItem->i_id == THEPL->p_playing->i_id )
+ {
+ menu.addAction( qtr(I_PL_ADDF), THEDP, SLOT( simplePLAppendDialog()) );
+ menu.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
+ menu.addAction( qtr(I_OP_ADVOP), THEDP, SLOT( PLAppendDialog()) );
+ }
+ else if( THEPL->p_media_library &&
+ rootItem->i_id == THEPL->p_media_library->i_id )
+ {
+ menu.addAction( qtr(I_PL_ADDF), THEDP, SLOT( simpleMLAppendDialog()) );
+ menu.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
+ menu.addAction( qtr(I_OP_ADVOP), THEDP, SLOT( MLAppendDialog() ) );
+ }
+ }
+ if( i_popup_item > -1 )
+ {
+ menu.addSeparator();
+ QMenu *sort_menu = menu.addMenu( qtr( "Sort by" ) + QString(" ") +
qfu( psz_column_title( columnToMeta( index.column() ) ) ) );
sort_menu->addAction( qtr( "Ascending" ),
this, SLOT( popupSortAsc() ) );
sort_menu->addAction( qtr( "Descending" ),
this, SLOT( popupSortDesc() ) );
}
- if( tree && canEdit() )
- menu.addAction( qtr(I_POP_ADD), this, SLOT( popupAddNode() ) );
- if( i_popup_item > -1 )
+ if( !menu.isEmpty() )
{
- menu.addSeparator();
- menu.addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+ menu.exec( point ); return true;
}
- if( !menu.isEmpty() ) menu.exec( point );
+ else return false;
}
void PLModel::popupDel()
@@ -1009,7 +1030,7 @@ void PLModel::popupAddNode()
{
bool ok;
QString name = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
- qtr( I_POP_ADD ), qtr( "Enter name for new node:" ),
+ qtr( I_POP_ADD ), qtr( "Enter name for new folder:" ),
QLineEdit::Normal, QString(), &ok);
if( !ok || name.isEmpty() ) return;
PL_LOCK;
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 1f72799..88c78e3 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -94,7 +94,7 @@ public:
static int columnToMeta( int column );
/* Actions */
- void popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
+ bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
void doDelete( QModelIndexList selected );
void search( const QString& search_text, const QModelIndex & root, bool b_recursive );
void sort( int column, Qt::SortOrder order );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index eb4f7e0..357d75f 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -216,15 +216,11 @@ void StandardPLPanel::popupPlView( const QPoint &point )
{
QModelIndex index = currentView->indexAt( point );
QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
- if( !index.isValid() ){
+ QItemSelectionModel *selection = currentView->selectionModel();
+ QModelIndexList list = selection->selectedIndexes();
+
+ if( !model->popup( index, globalPoint, list ) )
QVLCMenu::PopupMenu( p_intf, true );
- }
- else
- {
- QItemSelectionModel *selection = currentView->selectionModel();
- QModelIndexList list = selection->selectedIndexes();
- model->popup( index, globalPoint, list );
- }
}
void StandardPLPanel::popupSelectColumn( QPoint pos )
More information about the vlc-devel
mailing list