[vlc-devel] commit: Qt4: implement PLModel::popupSort[Asc/Desc]() (Jakob Leben )
git version control
git at videolan.org
Tue Aug 18 18:16:19 CEST 2009
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Aug 18 18:11:11 2009 +0200| [b15fc71ae49839e24fb90e92e86dc87fcc48b9a4] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b15fc71ae49839e24fb90e92e86dc87fcc48b9a4
---
.../gui/qt4/components/playlist/playlist_model.cpp | 23 ++++++++++++++++++-
.../gui/qt4/components/playlist/playlist_model.hpp | 5 +++-
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 7fc6fe8..9cf2509 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -892,6 +892,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
**********************************************************************/
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 41d93fd..caa4386 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -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 );
More information about the vlc-devel
mailing list