[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: add section property in video folders model

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Aug 13 06:41:25 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
f9bec4c6 by Prince Gupta at 2023-08-13T06:24:06+00:00
qt: add section property in video folders model

- - - - -
6a64f84f by Prince Gupta at 2023-08-13T06:24:06+00:00
qt: add section property in video groups model

- - - - -
ea2c917f by Prince Gupta at 2023-08-13T06:24:06+00:00
qml: allow changing section property in VideoALL

- - - - -
96426e4a by Prince Gupta at 2023-08-13T06:24:06+00:00
qml: fix section property assignment for different video groups

- - - - -


7 changed files:

- modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp
- modules/gui/qt/medialibrary/mlvideofoldersmodel.hpp
- modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp
- modules/gui/qt/medialibrary/mlvideogroupsmodel.hpp
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoListDisplay.qml


Changes:

=====================================
modules/gui/qt/medialibrary/mlvideofoldersmodel.cpp
=====================================
@@ -59,9 +59,10 @@ QHash<int, QByteArray> MLVideoFoldersModel::roleNames() const /* override */
     return {
         { FOLDER_ID, "id" },
         { FOLDER_TITLE, "title" },
+        { FOLDER_TITLE_FIRST_SYMBOL, "title_first_symbol" },
         { FOLDER_THUMBNAIL, "thumbnail" },
         { FOLDER_DURATION, "duration" },
-        { FOLDER_COUNT, "count"},
+        { FOLDER_COUNT, "count" },
     };
 }
 
@@ -84,6 +85,8 @@ QVariant MLVideoFoldersModel::itemRoleData(MLItem * item, const int role) const
             return QVariant::fromValue(folder->getId());
         case FOLDER_TITLE:
             return QVariant::fromValue(folder->getTitle());
+        case FOLDER_TITLE_FIRST_SYMBOL:
+            return QVariant::fromValue( getFirstSymbol(folder->getTitle()) );
         case FOLDER_THUMBNAIL:
         {
             return ml()->customCover()->get(folder->getId()


=====================================
modules/gui/qt/medialibrary/mlvideofoldersmodel.hpp
=====================================
@@ -36,6 +36,7 @@ public:
     {
         FOLDER_ID = Qt::UserRole + 1,
         FOLDER_TITLE,
+        FOLDER_TITLE_FIRST_SYMBOL,
         FOLDER_THUMBNAIL,
         FOLDER_DURATION,
         FOLDER_COUNT


=====================================
modules/gui/qt/medialibrary/mlvideogroupsmodel.cpp
=====================================
@@ -65,9 +65,20 @@ QHash<int, QByteArray> MLVideoGroupsModel::roleNames() const /* override */
 {
     QHash<int, QByteArray> hash = MLVideoModel::roleNames();
 
-    hash.insert(GROUP_IS_VIDEO, "isVideo");
-    hash.insert(GROUP_DATE,     "date");
-    hash.insert(GROUP_COUNT,    "count");
+    const QHash<int, QByteArray> groupRoles =
+    {
+        {GROUP_IS_VIDEO, "isVideo"},
+        {GROUP_TITLE_FIRST_SYMBOL, "group_title_first_symbol"},
+        {GROUP_DATE, "date"},
+        {GROUP_COUNT, "count"},
+    };
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+    for (auto i = groupRoles.begin(); i != groupRoles.end(); ++i)
+        hash.insert(i.key(), i.value());
+#else
+    hash.insert(groupRoles);
+#endif
 
     return hash;
 }
@@ -103,6 +114,8 @@ QVariant MLVideoGroupsModel::itemRoleData(MLItem * item, const int role) const /
                 return QVariant::fromValue(group->getDuration());
             case GROUP_IS_VIDEO:
                 return false;
+            case GROUP_TITLE_FIRST_SYMBOL:
+                return QVariant::fromValue( getFirstSymbol(group->getTitle() ));
             case GROUP_DATE:
                 return QVariant::fromValue(group->getDate());
             case GROUP_COUNT:
@@ -119,6 +132,10 @@ QVariant MLVideoGroupsModel::itemRoleData(MLItem * item, const int role) const /
         {
             case Qt::DisplayRole:
                 return QVariant::fromValue(video->getTitle());
+            case GROUP_TITLE_FIRST_SYMBOL:
+                // videos and groups are shown mixed, force this item into a group
+                // for grouping the data must be sorted by title
+                return QVariant::fromValue( getFirstSymbol(video->getTitle() ));
             case GROUP_IS_VIDEO:
                 return true;
             case GROUP_DATE:


=====================================
modules/gui/qt/medialibrary/mlvideogroupsmodel.hpp
=====================================
@@ -36,6 +36,7 @@ public:
     {
         // NOTE: Group specific.
         GROUP_IS_VIDEO = VIDEO_TITLE_FIRST_SYMBOL + 1,
+        GROUP_TITLE_FIRST_SYMBOL,
         GROUP_DATE,
         GROUP_COUNT
     };


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -44,6 +44,9 @@ MainInterface.MainViewLoader {
 
     readonly property int currentIndex: Helpers.get(currentItem, "currentIndex", -1)
 
+    // 'role' used for tableview's section text
+    /* required */ property string sectionProperty
+
     // NOTE: The ContextMenu depends on the model so we have to provide it too.
     /* required */ property var contextMenu
 
@@ -261,6 +264,8 @@ MainInterface.MainViewLoader {
 
             activeFocusOnTab: true
 
+            section.property: root.sectionProperty
+
             // Navigation
 
             Navigation.parentItem: root


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -60,6 +60,8 @@ VideoAll {
 
     listLabels: !!_meta ? _meta.listLabels : root.getLabel
 
+    sectionProperty: !!_meta && !!_meta.sectionProperty ? _meta.sectionProperty : ""
+
     // Functions
 
     function _updateMetaModel(groupping) {
@@ -130,6 +132,15 @@ VideoAll {
 
             property var listLabels: root.getLabel
 
+            property string sectionProperty: {
+                switch (model.sortCriteria) {
+                case "title":
+                    return "title_first_symbol"
+                default:
+                    return ""
+                }
+            }
+
             function onAction(indexes) {
                 model.addAndPlay( indexes )
                 g_mainDisplay.showPlayer()
@@ -149,6 +160,15 @@ VideoAll {
 
             property var model: MLVideoGroupsModel { ml: MediaLib }
 
+            property string sectionProperty: {
+                switch (model.sortCriteria) {
+                case "title":
+                    return "group_title_first_symbol"
+                default:
+                    return ""
+                }
+            }
+
             property var gridLabels: function (model) {
                 return root.getLabelGroup(model, I18n.qtr("%1 Videos"))
             }
@@ -196,6 +216,15 @@ VideoAll {
 
             property var model: MLVideoFoldersModel { ml: MediaLib }
 
+            property string sectionProperty: {
+                switch (model.sortCriteria) {
+                case "title":
+                    return "title_first_symbol"
+                default:
+                    return ""
+                }
+            }
+
             property var gridLabels: function (model) {
                 return root.getLabelGroup(model, I18n.qtr("%1 Videos"))
             }


=====================================
modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
=====================================
@@ -115,23 +115,6 @@ MainInterface.MainTableView {
 
     rowHeight: VLCStyle.tableCoverRow_height
 
-    //---------------------------------------------------------------------------------------------
-    // Connections
-    //---------------------------------------------------------------------------------------------
-
-    Connections {
-        target: model
-        onSortCriteriaChanged: {
-            switch (model.sortCriteria) {
-            case "title":
-                listView_id.section.property = "title_first_symbol"
-                break;
-            default:
-                listView_id.section.property = ""
-            }
-        }
-    }
-
     //---------------------------------------------------------------------------------------------
     // Functions
     //---------------------------------------------------------------------------------------------



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b23942d4a61612b84a3f4e85b294b3bb2c2e891e...96426e4a6549c99262ac7f23d0d6d791e1d773b6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b23942d4a61612b84a3f4e85b294b3bb2c2e891e...96426e4a6549c99262ac7f23d0d6d791e1d773b6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list