[vlc-devel] [PATCH] Add Sort by random option in QT gui. (Feature request #12374)
Noah Goldsmid
noahgoldsmid at live.nl
Thu Jul 7 23:15:17 CEST 2016
---
Adds a sort by Random option in the QT gui. (Feature request #12374)
modules/gui/qt/components/playlist/sorting.h | 8 ++++++--
modules/gui/qt/components/playlist/standardpanel.cpp | 7 +++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/components/playlist/sorting.h b/modules/gui/qt/components/playlist/sorting.h
index fe0a615..bc1ffd2 100644
--- a/modules/gui/qt/components/playlist/sorting.h
+++ b/modules/gui/qt/components/playlist/sorting.h
@@ -42,10 +42,10 @@ enum
COLUMN_RATING = 0x0200,
COLUMN_COVER = 0x0400,
COLUMN_DISC_NUMBER = 0x0800,
-
+ COLUMN_RANDOM = 0x1000,
/* Add new entries here and update the COLUMN_END value*/
- COLUMN_END = 0x1000
+ COLUMN_END = 0x2000
};
#define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
@@ -67,6 +67,7 @@ static inline const char * psz_column_title( uint32_t i_column )
case COLUMN_RATING: return VLC_META_RATING;
case COLUMN_COVER: return _("Cover");
case COLUMN_DISC_NUMBER: return VLC_META_DISCNUMBER;
+ case COLUMN_RANDOM: return _("Random");
default: abort();
}
}
@@ -81,6 +82,8 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
{
case COLUMN_NUMBER:
return NULL;
+ case COLUMN_RANDOM:
+ return NULL;
case COLUMN_TITLE:
return input_item_GetTitleFbName( p_item );
case COLUMN_DURATION:
@@ -127,6 +130,7 @@ static inline int i_column_sorting( uint32_t i_column )
case COLUMN_URI: return SORT_URI;
case COLUMN_RATING: return SORT_RATING;
case COLUMN_DISC_NUMBER: return SORT_DISC_NUMBER;
+ case COLUMN_RANDOM: return SORT_RANDOM;
default: abort();
}
}
diff --git a/modules/gui/qt/components/playlist/standardpanel.cpp b/modules/gui/qt/components/playlist/standardpanel.cpp
index 4f04823..96aba1d 100644
--- a/modules/gui/qt/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt/components/playlist/standardpanel.cpp
@@ -262,6 +262,11 @@ bool StandardPLPanel::popup( const QPoint &point )
container.column = -1 * (model->columnFromMeta(Column)+1);
action->setData( QVariant::fromValue( container ) );
}
+ /* Adding random shuffle option after foreach because it does not need an Ascending/
+ Descending option */
+ action = sortingMenu->addAction( qfu( psz_column_title( COLUMN_RANDOM ) ) );
+ container.column = model->columnFromMeta( COLUMN_RANDOM ) + 1;
+ action->setData( QVariant::fromValue( container ) );
menu.addMenu( sortingMenu );
}
@@ -437,6 +442,8 @@ void StandardPLPanel::popupSelectColumn( QPoint )
* QTreeView will behave weird */
for( int i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
{
+ /* Skip the RANDOM_COLUMN, which is just for sorting purposes */
+ if ( i == COLUMN_RANDOM ) continue;
QAction* option = menu.addAction( qfu( psz_column_title( i ) ) );
option->setCheckable( true );
option->setChecked( !treeView->isColumnHidden( j ) );
--
2.5.0
More information about the vlc-devel
mailing list