[vlc-commits] qml: sections of MusicTrackListDisplay are set by the sorting criteria

Adrien Maglo git at videolan.org
Thu Jun 13 13:10:51 CEST 2019


vlc | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon May 13 14:15:17 2019 +0200| [5a4280ab4a440dc691eb7834e8181c36eb756dd0] | committer: Thomas Guillem

qml: sections of MusicTrackListDisplay are set by the sorting criteria

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 .../gui/qt/components/mediacenter/mlalbumtrackmodel.cpp   | 15 ++++++++++++---
 modules/gui/qt/qml/mediacenter/MusicTrackListDisplay.qml  | 13 ++++++++++++-
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.cpp b/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.cpp
index 7ef567aeef..788b656b0e 100644
--- a/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.cpp
+++ b/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.cpp
@@ -29,7 +29,10 @@ enum Role {
     TRACK_DURATION,
     TRACK_ALBUM,
     TRACK_ARTIST,
-    TRACK_FIRST_SYMBOL,
+
+    TRACK_TITLE_FIRST_SYMBOL,
+    TRACK_ALBUM_FIRST_SYMBOL,
+    TRACK_ARTIST_FIRST_SYMBOL,
 };
 
 }
@@ -77,8 +80,12 @@ QVariant MLAlbumTrackModel::data(const QModelIndex &index, int role) const
         return QVariant::fromValue( ml_track->getAlbumTitle() );
     case TRACK_ARTIST:
         return QVariant::fromValue( ml_track->getArtist() );
-    case TRACK_FIRST_SYMBOL:
+    case TRACK_TITLE_FIRST_SYMBOL:
         return QVariant::fromValue( getFirstSymbol( ml_track->getTitle() ) );
+    case TRACK_ALBUM_FIRST_SYMBOL:
+        return QVariant::fromValue( getFirstSymbol( ml_track->getAlbumTitle() ) );
+    case TRACK_ARTIST_FIRST_SYMBOL:
+        return QVariant::fromValue( getFirstSymbol( ml_track->getArtist() ) );
     default :
         return QVariant();
     }
@@ -95,7 +102,9 @@ QHash<int, QByteArray> MLAlbumTrackModel::roleNames() const
         { TRACK_DURATION, "duration" },
         { TRACK_ALBUM, "album_title"},
         { TRACK_ARTIST, "main_artist"},
-        { TRACK_FIRST_SYMBOL, "first_symbol"},
+        { TRACK_TITLE_FIRST_SYMBOL, "title_first_symbol"},
+        { TRACK_ALBUM_FIRST_SYMBOL, "album_title_first_symbol"},
+        { TRACK_ARTIST_FIRST_SYMBOL, "main_artist_first_symbol"},
     };
 }
 
diff --git a/modules/gui/qt/qml/mediacenter/MusicTrackListDisplay.qml b/modules/gui/qt/qml/mediacenter/MusicTrackListDisplay.qml
index a33c0659f2..46701a4755 100644
--- a/modules/gui/qt/qml/mediacenter/MusicTrackListDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MusicTrackListDisplay.qml
@@ -37,13 +37,24 @@ Utils.KeyNavigableTableView {
         ListElement{ criteria: "disc_number"; width:0.05; text: qsTr("Disc");  showSection: "" }
     }
 
-    section.property: "first_symbol"
+    section.property: "title_first_symbol"
 
     headerColor: VLCStyle.colors.bg
 
     model: MLAlbumTrackModel {
         id: rootmodel
         ml: medialib
+        onSortCriteriaChanged: {
+            switch (rootmodel.sortCriteria) {
+            case "title":
+            case "album_title":
+            case "main_artist":
+                section.property = rootmodel.sortCriteria + "_first_symbol"
+                break;
+            default:
+                section.property = ""
+            }
+        }
     }
 
     property alias parentId: rootmodel.parentId



More information about the vlc-commits mailing list