[vlc-commits] gui/qt: fix PLModel::action( ACTION_SORT, ... )

Filip Roséen git at videolan.org
Sun Jul 24 20:39:15 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Sat Jul 23 16:22:08 2016 +0200| [6ccc5f1564a97cb78b0a7d4710923408543954e7] | committer: Francois Cartegnie

gui/qt: fix PLModel::action( ACTION_SORT, ... )

Given that one should always be able to sort the playlist, aborting sort
on "indexes.empty()" is inaccurate since we should not mandate that:

 - a user either right-clicks on an entity in order to sort, or;
 - has at least one index selected.

 This commit fixes the above described issue, as well as the arguments
 passed to PLModel::sort. More specifically, that the first argument is
 the first index (if any), and the second being the root index.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ccc5f1564a97cb78b0a7d4710923408543954e7
---

 modules/gui/qt/components/playlist/playlist_model.cpp |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index a1dc43d..14720ae 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -960,10 +960,10 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
         return true;
 
     case ACTION_SORT:
-        if ( indexes.empty() ) break;
-        index = indexes.first().parent();
-        if( !index.isValid() ) index = rootIndex();
-        sort( indexes.first(), index,
+        if ( !indexes.empty() )
+            index = indexes.first();
+
+        sort( index, rootIndex(),
               a.column > 0 ? a.column - 1 : -a.column - 1,
               a.column > 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
         return true;



More information about the vlc-commits mailing list