Commit b15fc71a authored by Jakob Leben's avatar Jakob Leben

Qt4: implement PLModel::popupSort[Asc/Desc]()

Implement recursive sorting of a single playlist node from popup menu,
in either ascending or descending order. Node is sorted by values in
column which was right clicked to bring up the popup menu.
parent c4e943d7
......@@ -891,6 +891,11 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
/******* Volume III: Sorting and searching ********/
void PLModel::sort( int column, Qt::SortOrder order )
{
sort( rootItem->i_id, column, order );
}
void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
{
int i_index = -1;
int i_flag = 0;
......@@ -912,7 +917,7 @@ next:
PL_LOCK;
{
playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id );
i_root_id );
if( p_root && i_flag )
{
playlist_RecursiveNodeSort( p_playlist, p_root,
......@@ -946,6 +951,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
int i_id;
if( index.isValid() ) i_id = itemId( index );
else i_id = rootItem->i_id;
i_popup_column = index.column();
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
if( p_item )
......@@ -979,8 +985,11 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
if( node )
{
QMenu *sort_menu = new QMenu( qtr(I_POP_SORT) );
sort_menu->addAction( qtr( "Ascending" ), this, SLOT( popupSortAsc() ) );
sort_menu->addAction( qtr( "Descending" ), this, SLOT( popupSortDesc() ) );
menu->addSeparator();
menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
menu->addMenu( sort_menu );
}
}
if( node && tree )
......@@ -1137,6 +1146,16 @@ void PLModel::popupAddNode()
}
PL_UNLOCK;
}
void PLModel::popupSortAsc()
{
sort( i_popup_item, i_popup_column, Qt::AscendingOrder );
}
void PLModel::popupSortDesc()
{
sort( i_popup_item, i_popup_column, Qt::DescendingOrder );
}
/**********************************************************************
* Playlist callbacks
**********************************************************************/
......
......@@ -116,6 +116,7 @@ public:
void doDelete( QModelIndexList selected );
void search( const QString& search_text );
void sort( int column, Qt::SortOrder order );
void sort( int i_root_id, int column, Qt::SortOrder order );
void removeItem( int );
/* DnD handling */
......@@ -155,7 +156,7 @@ private:
void doDeleteItem( PLItem *item, QModelIndexList *fullList );
/* Popup */
int i_popup_item, i_popup_parent;
int i_popup_item, i_popup_parent, i_popup_column;
QModelIndexList current_selection;
QSignalMapper *ContextUpdateMapper;
......@@ -188,6 +189,8 @@ private slots:
void popupSave();
void popupExplore();
void popupAddNode();
void popupSortAsc();
void popupSortDesc();
void viewchanged( int );
void ProcessInputItemUpdate( input_item_t *);
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