Commit 5a38d2b2 authored by Jakob Leben's avatar Jakob Leben

Qt4: implement PLModel::popupAddNode()

parent c54fe5a7
...@@ -948,7 +948,20 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ...@@ -948,7 +948,20 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
{ {
i_popup_item = p_item->i_id; i_popup_item = p_item->i_id;
i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1; i_popup_parent = p_item->p_parent ? p_item->p_parent->i_id : -1;
bool node = p_item->i_children > -1;
bool tree = false;
if( node )
{
/* check whether we are in tree view */
playlist_item_t *p_up = p_item;
while( p_up )
{
if ( p_up == p_playlist->p_root_category ) tree = true;
p_up = p_up->p_parent;
}
}
PL_UNLOCK; PL_UNLOCK;
current_selection = list; current_selection = list;
QMenu *menu = new QMenu; QMenu *menu = new QMenu;
menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) ); menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
...@@ -958,11 +971,12 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ...@@ -958,11 +971,12 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) ); menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
menu->addSeparator(); menu->addSeparator();
menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) ); menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
if( p_item->i_children > -1 ) if( node )
{ {
menu->addSeparator(); menu->addSeparator();
menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) ); menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAdd() ) ); if( tree );
menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAddNode() ) );
} }
menu->addSeparator(); menu->addSeparator();
menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) ); menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
...@@ -1096,6 +1110,23 @@ void PLModel::popupExplore() ...@@ -1096,6 +1110,23 @@ void PLModel::popupExplore()
PL_UNLOCK; PL_UNLOCK;
} }
#include <QInputDialog>
void PLModel::popupAddNode()
{
bool ok;
QString name = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
QString( "Add node" ), QString( "Enter name for new node" ),
QLineEdit::Normal, QString(), &ok);
if( !ok || name.isEmpty() ) return;
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item );
if( p_item )
{
playlist_NodeCreate( p_playlist, qtu( name ), p_item, 0, NULL );
}
PL_UNLOCK;
}
/********************************************************************** /**********************************************************************
* Playlist callbacks * Playlist callbacks
**********************************************************************/ **********************************************************************/
......
...@@ -186,6 +186,7 @@ private slots: ...@@ -186,6 +186,7 @@ private slots:
void popupStream(); void popupStream();
void popupSave(); void popupSave();
void popupExplore(); void popupExplore();
void popupAddNode();
void viewchanged( int ); void viewchanged( int );
void ProcessInputItemUpdate( input_item_t *); void ProcessInputItemUpdate( input_item_t *);
void ProcessInputItemUpdate( input_thread_t* p_input ); void ProcessInputItemUpdate( input_thread_t* p_input );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment