[vlc-devel] [PATCH 04/18] qml, qt: remove duration_short property

Prince Gupta guptaprince8832 at gmail.com
Thu Apr 1 14:29:39 UTC 2021


with duration_short property we have to map ml_sorting criteria with
multiple roles, which makes MLBaseModel::sortCriteria unstable, so
remove duration_short, have duration property return raw "msec" and
convert it to string in the view
---
 modules/gui/qt/medialibrary/mlalbum.cpp       | 30 ++---------------
 modules/gui/qt/medialibrary/mlalbum.hpp       |  6 ++--
 modules/gui/qt/medialibrary/mlalbummodel.cpp  |  7 +---
 modules/gui/qt/medialibrary/mlalbummodel.hpp  |  1 -
 modules/gui/qt/medialibrary/mlalbumtrack.cpp  | 32 ++-----------------
 modules/gui/qt/medialibrary/mlalbumtrack.hpp  |  6 ++--
 .../gui/qt/medialibrary/mlalbumtrackmodel.cpp |  7 +---
 .../gui/qt/medialibrary/mlalbumtrackmodel.hpp |  1 -
 .../gui/qt/medialibrary/mlplaylistmedia.cpp   |  9 ++----
 .../gui/qt/medialibrary/mlplaylistmedia.hpp   |  3 +-
 .../gui/qt/medialibrary/mlplaylistmodel.cpp   |  5 ---
 .../gui/qt/medialibrary/mlplaylistmodel.hpp   |  1 -
 modules/gui/qt/medialibrary/mlvideo.cpp       | 12 ++-----
 modules/gui/qt/medialibrary/mlvideo.hpp       |  3 +-
 modules/gui/qt/medialibrary/mlvideomodel.cpp  |  5 ---
 modules/gui/qt/medialibrary/mlvideomodel.hpp  |  1 -
 .../gui/qt/medialibrary/qml/MusicAlbums.qml   |  2 +-
 .../qml/MusicAlbumsGridExpandDelegate.qml     |  5 +--
 .../gui/qt/medialibrary/qml/MusicArtist.qml   |  2 +-
 .../qml/MusicTrackListDisplay.qml             |  6 ++--
 .../gui/qt/medialibrary/qml/PlaylistMedia.qml |  2 +-
 modules/gui/qt/medialibrary/qml/VideoAll.qml  |  2 +-
 .../qml/VideoDisplayRecentVideos.qml          |  3 +-
 .../gui/qt/medialibrary/qml/VideoGridItem.qml |  3 +-
 .../medialibrary/qml/VideoInfoExpandPanel.qml |  3 +-
 .../qt/medialibrary/qml/VideoListDisplay.qml  |  2 +-
 modules/gui/qt/widgets/qml/TableColumns.qml   |  3 +-
 27 files changed, 37 insertions(+), 125 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlalbum.cpp b/modules/gui/qt/medialibrary/mlalbum.cpp
index b9edaa2d8d..dc68b7cb03 100644
--- a/modules/gui/qt/medialibrary/mlalbum.cpp
+++ b/modules/gui/qt/medialibrary/mlalbum.cpp
@@ -28,31 +28,10 @@ MLAlbum::MLAlbum(vlc_medialibrary_t* _ml, const vlc_ml_album_t *_data, QObject *
     , m_cover       ( QString::fromUtf8( _data->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl ) )
     , m_mainArtist  ( QString::fromUtf8( _data->psz_artist ) )
     , m_nbTracks    ( _data->i_nb_tracks )
+    , m_duration    ( _data->i_duration )
 {
     assert( _data );
     assert( _ml );
-
-    int t_sec = _data->i_duration / 1000;
-    int sec = t_sec % 60;
-    int min = (t_sec / 60) % 60;
-    int hour = t_sec / 3600;
-    if (hour == 0)
-    {
-        m_duration = QString("%1:%2")
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-        m_durationShort = m_duration;
-    }
-    else
-    {
-        m_duration = QString("%1:%2:%3")
-                .arg(hour, 2, 10, QChar('0'))
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-        m_durationShort = QString("%1h%2")
-                .arg(hour)
-                .arg(min, 2, 10, QChar('0'));
-    }
 }
 
 QString MLAlbum::getTitle() const
@@ -86,16 +65,11 @@ unsigned int MLAlbum::getNbTracks() const
     return m_nbTracks;
 }
 
-QString MLAlbum::getDuration() const
+int64_t MLAlbum::getDuration() const
 {
     return m_duration;
 }
 
-QString MLAlbum::getDurationShort() const
-{
-    return m_durationShort;
-}
-
 QString MLAlbum::getPresName() const
 {
     return m_title;
diff --git a/modules/gui/qt/medialibrary/mlalbum.hpp b/modules/gui/qt/medialibrary/mlalbum.hpp
index 6abba39cde..23e4ed2b0b 100644
--- a/modules/gui/qt/medialibrary/mlalbum.hpp
+++ b/modules/gui/qt/medialibrary/mlalbum.hpp
@@ -44,8 +44,7 @@ public:
     QString getCover() const;
     QString getArtist() const;
     unsigned int getNbTracks() const;
-    QString getDuration() const;
-    QString getDurationShort() const;
+    int64_t getDuration() const;
 
     Q_INVOKABLE QString getPresName() const;
     Q_INVOKABLE QString getPresImage() const;
@@ -61,6 +60,5 @@ private:
     QString m_mainArtist;
     QList<QString> m_otherArtists;
     unsigned int m_nbTracks;
-    QString m_duration;
-    QString m_durationShort;
+    int64_t m_duration;
 };
diff --git a/modules/gui/qt/medialibrary/mlalbummodel.cpp b/modules/gui/qt/medialibrary/mlalbummodel.cpp
index 150784df48..c601dc95f2 100644
--- a/modules/gui/qt/medialibrary/mlalbummodel.cpp
+++ b/modules/gui/qt/medialibrary/mlalbummodel.cpp
@@ -24,8 +24,7 @@ QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumModel::M_names_to_criteria =
     {"release_year", VLC_ML_SORTING_RELEASEDATE},
     {"main_artist", VLC_ML_SORTING_ARTIST},
     //{"nb_tracks"},
-    {"duration", VLC_ML_SORTING_DURATION},
-    {"duration_short", VLC_ML_SORTING_DURATION}
+    {"duration", VLC_ML_SORTING_DURATION}
 };
 
 MLAlbumModel::MLAlbumModel(QObject *parent)
@@ -60,8 +59,6 @@ QVariant MLAlbumModel::data(const QModelIndex &index, int role) const
         return QVariant::fromValue( ml_item->getNbTracks() );
     case ALBUM_DURATION:
         return QVariant::fromValue( ml_item->getDuration() );
-    case ALBUM_DURATION_SHORT:
-        return QVariant::fromValue( ml_item->getDurationShort() );
     case ALBUM_TITLE_FIRST_SYMBOL:
         return QVariant::fromValue( getFirstSymbol( ml_item->getTitle() ) );
     case ALBUM_MAIN_ARTIST_FIRST_SYMBOL:
@@ -82,7 +79,6 @@ QHash<int, QByteArray> MLAlbumModel::roleNames() const
         {ALBUM_MAIN_ARTIST, "main_artist"},
         {ALBUM_NB_TRACKS, "nb_tracks"},
         {ALBUM_DURATION, "duration"},
-        {ALBUM_DURATION_SHORT, "duration_short"},
         {ALBUM_TITLE_FIRST_SYMBOL, "title_first_symbol"},
         {ALBUM_MAIN_ARTIST_FIRST_SYMBOL, "main_artist_first_symbol"}
     };
@@ -139,7 +135,6 @@ vlc_ml_sorting_criteria_t MLAlbumModel::roleToCriteria(int role) const
     case ALBUM_MAIN_ARTIST :
         return VLC_ML_SORTING_ARTIST;
     case ALBUM_DURATION:
-    case ALBUM_DURATION_SHORT:
         return VLC_ML_SORTING_DURATION;
     default:
         return VLC_ML_SORTING_DEFAULT;
diff --git a/modules/gui/qt/medialibrary/mlalbummodel.hpp b/modules/gui/qt/medialibrary/mlalbummodel.hpp
index 32e668d6ad..61e1caf797 100644
--- a/modules/gui/qt/medialibrary/mlalbummodel.hpp
+++ b/modules/gui/qt/medialibrary/mlalbummodel.hpp
@@ -43,7 +43,6 @@ public:
         ALBUM_MAIN_ARTIST,
         ALBUM_NB_TRACKS,
         ALBUM_DURATION,
-        ALBUM_DURATION_SHORT,
 
         ALBUM_TITLE_FIRST_SYMBOL,
         ALBUM_MAIN_ARTIST_FIRST_SYMBOL
diff --git a/modules/gui/qt/medialibrary/mlalbumtrack.cpp b/modules/gui/qt/medialibrary/mlalbumtrack.cpp
index ba3a32bb3a..309476428f 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrack.cpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrack.cpp
@@ -25,33 +25,12 @@ MLAlbumTrack::MLAlbumTrack(vlc_medialibrary_t* _ml, const vlc_ml_media_t *_data,
     , MLItem       ( MLItemId( _data->i_id, VLC_ML_PARENT_UNKNOWN ) )
     , m_title      ( QString::fromUtf8( _data->psz_title ) )
     , m_trackNumber( _data->album_track.i_track_nb )
-    , m_discNumber( _data->album_track.i_disc_nb )
+    , m_discNumber ( _data->album_track.i_disc_nb )
+    , m_duration   ( _data->i_duration )
 {
     assert( _data );
     assert( _data->i_type == VLC_ML_MEDIA_TYPE_AUDIO );
 
-    int t_sec = _data->i_duration / 1000;
-    int sec = t_sec % 60;
-    int min = (t_sec / 60) % 60;
-    int hour = t_sec / 3600;
-    if (hour == 0)
-    {
-        m_duration = QString("%1:%2")
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-        m_durationShort = m_duration;
-    }
-    else
-    {
-        m_duration = QString("%1:%2:%3")
-                .arg(hour, 2, 10, QChar('0'))
-                .arg(min, 2, 10, QChar('0'))
-                .arg(sec, 2, 10, QChar('0'));
-        m_durationShort = QString("%1h%2")
-                .arg(hour)
-                .arg(min, 2, 10, QChar('0'));
-    }
-
     for( const vlc_ml_file_t& file: ml_range_iterate<vlc_ml_file_t>( _data->p_files ) )
         if( file.i_type == VLC_ML_FILE_TYPE_MAIN )
         {
@@ -112,16 +91,11 @@ unsigned int MLAlbumTrack::getDiscNumber() const
     return m_discNumber;
 }
 
-QString MLAlbumTrack::getDuration() const
+int64_t MLAlbumTrack::getDuration() const
 {
     return m_duration;
 }
 
-QString MLAlbumTrack::getDurationShort() const
-{
-    return m_durationShort;
-}
-
 QString MLAlbumTrack::getMRL() const
 {
     return m_mrl;
diff --git a/modules/gui/qt/medialibrary/mlalbumtrack.hpp b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
index 7cda00f081..c84bc2faa5 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrack.hpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrack.hpp
@@ -44,8 +44,7 @@ public:
     QString getCover() const;
     unsigned int getTrackNumber() const;
     unsigned int getDiscNumber() const;
-    QString getDuration() const;
-    QString getDurationShort() const;
+    int64_t getDuration() const;
     QString getMRL() const;
 
 private:
@@ -55,8 +54,7 @@ private:
     QString m_cover;
     unsigned int m_trackNumber;
     unsigned int m_discNumber;
-    QString m_duration;
-    QString m_durationShort;
+    int64_t m_duration;
     QString m_mrl;
 
    ml_unique_ptr<vlc_ml_media_t> m_data;
diff --git a/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp b/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
index f4db5bd0a8..479be53f76 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
@@ -25,8 +25,7 @@ QHash<QByteArray, vlc_ml_sorting_criteria_t> MLAlbumTrackModel::M_names_to_crite
     {"track_number", VLC_ML_SORTING_TRACKNUMBER},
     {"release_year", VLC_ML_SORTING_RELEASEDATE},
     {"main_artist", VLC_ML_SORTING_ARTIST},
-    {"duration", VLC_ML_SORTING_DURATION},
-    {"duration_short", VLC_ML_SORTING_DURATION}
+    {"duration", VLC_ML_SORTING_DURATION}
 };
 
 MLAlbumTrackModel::MLAlbumTrackModel(QObject *parent)
@@ -58,8 +57,6 @@ QVariant MLAlbumTrackModel::data(const QModelIndex &index, int role) const
         return QVariant::fromValue( ml_track->getDiscNumber() );
     case TRACK_DURATION :
         return QVariant::fromValue( ml_track->getDuration() );
-    case TRACK_DURATION_SHORT :
-        return QVariant::fromValue( ml_track->getDurationShort() );
     case TRACK_ALBUM:
         return QVariant::fromValue( ml_track->getAlbumTitle() );
     case TRACK_ARTIST:
@@ -84,7 +81,6 @@ QHash<int, QByteArray> MLAlbumTrackModel::roleNames() const
         { TRACK_NUMBER, "track_number" },
         { TRACK_DISC_NUMBER, "disc_number" },
         { TRACK_DURATION, "duration" },
-        { TRACK_DURATION_SHORT, "duration_short" },
         { TRACK_ALBUM, "album_title"},
         { TRACK_ARTIST, "main_artist"},
         { TRACK_TITLE_FIRST_SYMBOL, "title_first_symbol"},
@@ -101,7 +97,6 @@ vlc_ml_sorting_criteria_t MLAlbumTrackModel::roleToCriteria(int role) const
     case TRACK_NUMBER :
         return VLC_ML_SORTING_TRACKNUMBER;
     case TRACK_DURATION :
-    case TRACK_DURATION_SHORT :
         return VLC_ML_SORTING_DURATION;
     default:
         return VLC_ML_SORTING_DEFAULT;
diff --git a/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp b/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
index 7cc4d46bc9..740ba96547 100644
--- a/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
@@ -40,7 +40,6 @@ public:
         TRACK_NUMBER,
         TRACK_DISC_NUMBER,
         TRACK_DURATION,
-        TRACK_DURATION_SHORT,
         TRACK_ALBUM,
         TRACK_ARTIST,
 
diff --git a/modules/gui/qt/medialibrary/mlplaylistmedia.cpp b/modules/gui/qt/medialibrary/mlplaylistmedia.cpp
index 2eb9855fcc..a3f19bdc17 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmedia.cpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmedia.cpp
@@ -131,14 +131,9 @@ QString MLPlaylistMedia::getThumbnail()
 
 //-------------------------------------------------------------------------------------------------
 
-QString MLPlaylistMedia::getDuration() const
+int64_t MLPlaylistMedia::getDuration() const
 {
-    return MsToString(m_duration);
-}
-
-QString MLPlaylistMedia::getDurationShort() const
-{
-    return MsToString(m_duration, true);
+    return m_duration;
 }
 
 //-------------------------------------------------------------------------------------------------
diff --git a/modules/gui/qt/medialibrary/mlplaylistmedia.hpp b/modules/gui/qt/medialibrary/mlplaylistmedia.hpp
index a1e0da2304..b927da51fb 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmedia.hpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmedia.hpp
@@ -43,8 +43,7 @@ public: // Interface
 
     QString getThumbnail();
 
-    QString getDuration     () const;
-    QString getDurationShort() const;
+    int64_t getDuration() const;
 
     QString getResolutionName() const;
 
diff --git a/modules/gui/qt/medialibrary/mlplaylistmodel.cpp b/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
index 8993ade0ed..98f37e93ed 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmodel.cpp
@@ -37,7 +37,6 @@ static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
     {"id",             VLC_ML_SORTING_DEFAULT},
     {"title",          VLC_ML_SORTING_ALPHA},
     {"duration",       VLC_ML_SORTING_DURATION},
-    {"duration_short", VLC_ML_SORTING_DURATION},
     {"playcount",      VLC_ML_SORTING_PLAYCOUNT},
 };
 
@@ -177,7 +176,6 @@ QHash<int, QByteArray> MLPlaylistModel::roleNames() const /* override */
         { MEDIA_TITLE,              "title"              },
         { MEDIA_THUMBNAIL,          "thumbnail"          },
         { MEDIA_DURATION,           "duration"           },
-        { MEDIA_DURATION_SHORT,     "duration_short"     },
         { MEDIA_PROGRESS,           "progress"           },
         { MEDIA_PLAYCOUNT,          "playcount"          },
         { MEDIA_RESOLUTION,         "resolution_name"    },
@@ -207,8 +205,6 @@ QVariant MLPlaylistModel::data(const QModelIndex & index, int role) const /* ove
             return QVariant::fromValue(media->getThumbnail());
         case MEDIA_DURATION:
             return QVariant::fromValue(media->getDuration());
-        case MEDIA_DURATION_SHORT:
-            return QVariant::fromValue(media->getDurationShort());
         case MEDIA_PROGRESS:
             return QVariant::fromValue(media->getProgress());
         case MEDIA_PLAYCOUNT:
@@ -243,7 +239,6 @@ vlc_ml_sorting_criteria_t MLPlaylistModel::roleToCriteria(int role) const /* ove
         case MEDIA_TITLE:
             return VLC_ML_SORTING_ALPHA;
         case MEDIA_DURATION:
-        case MEDIA_DURATION_SHORT:
             return VLC_ML_SORTING_DURATION;
         case MEDIA_PLAYCOUNT:
             return VLC_ML_SORTING_PLAYCOUNT;
diff --git a/modules/gui/qt/medialibrary/mlplaylistmodel.hpp b/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
index 2fb9b663c9..ce3edb87b8 100644
--- a/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlplaylistmodel.hpp
@@ -33,7 +33,6 @@ public:
         MEDIA_TITLE,
         MEDIA_THUMBNAIL,
         MEDIA_DURATION,
-        MEDIA_DURATION_SHORT,
         MEDIA_PROGRESS,
         MEDIA_PLAYCOUNT,
         MEDIA_RESOLUTION,
diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index 10bb975e75..de7a778e91 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -77,6 +77,7 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data)
     , m_ml( ml )
     , m_title( QString::fromUtf8( data->psz_title ) )
     , m_thumbnail( QString::fromUtf8( data->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl ) )
+    , m_duration( data->i_duration )
     , m_progress( data->f_progress )
     , m_playCount( data->i_playcount )
     , m_thumbnailStatus( data->thumbnails[VLC_ML_THUMBNAIL_SMALL].i_status )
@@ -87,8 +88,6 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data)
 {
     assert( data->i_type == VLC_ML_MEDIA_TYPE_VIDEO || data->i_type == VLC_ML_MEDIA_TYPE_UNKNOWN );
 
-    m_duration = data->i_duration;
-
     for( const vlc_ml_file_t& file: ml_range_iterate<vlc_ml_file_t>( data->p_files ) )
         if( file.i_type == VLC_ML_FILE_TYPE_MAIN )
         {
@@ -179,14 +178,9 @@ QString MLVideo::getThumbnail()
     return m_thumbnail;
 }
 
-QString MLVideo::getDuration() const
-{
-    return MsToString( m_duration );
-}
-
-QString MLVideo::getDurationShort() const
+int64_t MLVideo::getDuration() const
 {
-    return MsToString( m_duration, true );
+    return m_duration;
 }
 
 QString MLVideo::getMRL() const
diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp
index 604b17a37a..59de5046b7 100644
--- a/modules/gui/qt/medialibrary/mlvideo.hpp
+++ b/modules/gui/qt/medialibrary/mlvideo.hpp
@@ -92,8 +92,7 @@ public:
 
     QString getTitle() const;
     QString getThumbnail();
-    QString getDuration() const;
-    QString getDurationShort() const;
+    int64_t getDuration() const;
     QString getResolutionName() const;
     QString getChannel() const;
     QString getMRL() const;
diff --git a/modules/gui/qt/medialibrary/mlvideomodel.cpp b/modules/gui/qt/medialibrary/mlvideomodel.cpp
index b9bbde25d0..1301a81bdc 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.cpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.cpp
@@ -22,7 +22,6 @@ QHash<QByteArray, vlc_ml_sorting_criteria_t> MLVideoModel::M_names_to_criteria =
     {"id", VLC_ML_SORTING_DEFAULT},
     {"title", VLC_ML_SORTING_ALPHA},
     {"duration", VLC_ML_SORTING_DURATION},
-    {"duration_short", VLC_ML_SORTING_DURATION},
     {"playcount", VLC_ML_SORTING_PLAYCOUNT},
 };
 
@@ -46,8 +45,6 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
             return QVariant::fromValue( video->getThumbnail() );
         case VIDEO_DURATION:
             return QVariant::fromValue( video->getDuration() );
-        case VIDEO_DURATION_SHORT:
-            return QVariant::fromValue( video->getDurationShort() );
         case VIDEO_PROGRESS:
             return QVariant::fromValue( video->getProgress() );
         case VIDEO_PLAYCOUNT:
@@ -79,7 +76,6 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
         { VIDEO_TITLE, "title" },
         { VIDEO_THUMBNAIL, "thumbnail" },
         { VIDEO_DURATION, "duration" },
-        { VIDEO_DURATION_SHORT, "duration_short" },
         { VIDEO_PROGRESS, "progress" },
         { VIDEO_PLAYCOUNT, "playcount" },
         { VIDEO_RESOLUTION, "resolution_name" },
@@ -99,7 +95,6 @@ vlc_ml_sorting_criteria_t MLVideoModel::roleToCriteria(int role) const
         case VIDEO_TITLE:
             return VLC_ML_SORTING_ALPHA;
         case VIDEO_DURATION:
-        case VIDEO_DURATION_SHORT:
             return VLC_ML_SORTING_DURATION;
         case VIDEO_PLAYCOUNT:
             return VLC_ML_SORTING_PLAYCOUNT;
diff --git a/modules/gui/qt/medialibrary/mlvideomodel.hpp b/modules/gui/qt/medialibrary/mlvideomodel.hpp
index fd581f6331..0f4ffb07a6 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.hpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.hpp
@@ -41,7 +41,6 @@ public:
         VIDEO_TITLE,
         VIDEO_THUMBNAIL,
         VIDEO_DURATION,
-        VIDEO_DURATION_SHORT,
         VIDEO_PROGRESS,
         VIDEO_PLAYCOUNT,
         VIDEO_RESOLUTION,
diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
index 9fb277ff77..cb2bf205b6 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
@@ -218,7 +218,7 @@ Widgets.NavigableFocusScope {
             sortModel:  [
                 { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(2), text: i18n.qtr("Title"), headerDelegate: tableColumns.titleHeaderDelegate, colDelegate: tableColumns.titleDelegate },
                 { criteria: "main_artist", width: VLCStyle.colWidth(Math.max(tableView_id._nbCols - 3, 1)), text: i18n.qtr("Artist") },
-                { criteria: "duration_short", width:VLCStyle.colWidth(1), showSection: "", headerDelegate: tableColumns.timeHeaderDelegate, colDelegate: tableColumns.timeColDelegate },
+                { criteria: "duration", width:VLCStyle.colWidth(1), showSection: "", headerDelegate: tableColumns.timeHeaderDelegate, colDelegate: tableColumns.timeColDelegate },
             ]
 
             navigationCancel: function() {
diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml b/modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
index b3b01c20c8..f974b740f3 100644
--- a/modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
@@ -23,6 +23,7 @@ import QtQml.Models 2.11
 import org.videolan.medialib 0.1
 
 import "qrc:///widgets/" as Widgets
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 Widgets.NavigableFocusScope {
@@ -177,7 +178,7 @@ Widgets.NavigableFocusScope {
                 text: i18n.qtr("%1 - %2 - %3")
                     .arg(model.main_artist || i18n.qtr("Unknown artist"))
                     .arg(model.release_year || "")
-                    .arg(model.duration || "")
+                    .arg(Helpers.msToString(model.duration) || "")
 
                 Layout.fillWidth: true
                 Layout.preferredHeight: implicitHeight
@@ -240,7 +241,7 @@ Widgets.NavigableFocusScope {
 
                 sortModel: [
                     { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(Math.max(expand_track_id._nbCols - 1, 1)), visible: true, text: i18n.qtr("Title"), showSection: "", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
-                    { criteria: "duration_short",          width: VLCStyle.colWidth(1), visible: true, showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
+                    { criteria: "duration",               width: VLCStyle.colWidth(1), visible: true, showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
                 ]
 
                 navigationParent: root
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtist.qml b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
index d880e0391a..8fe689454e 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtist.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
@@ -356,7 +356,7 @@ Widgets.NavigableFocusScope {
             sortModel:  [
                 { isPrimary: true, criteria: "title", width: VLCStyle.colWidth(2), text: i18n.qtr("Title"), headerDelegate: tableColumns.titleHeaderDelegate, colDelegate: tableColumns.titleDelegate },
                 { criteria: "album_title", width: VLCStyle.colWidth(Math.max(tableView_id._nbCols - 3, 1)), text: i18n.qtr("Album") },
-                { criteria: "duration_short", width:VLCStyle.colWidth(1), showSection: "", headerDelegate: tableColumns.timeHeaderDelegate, colDelegate: tableColumns.timeColDelegate },
+                { criteria: "duration", width:VLCStyle.colWidth(1), showSection: "", headerDelegate: tableColumns.timeHeaderDelegate, colDelegate: tableColumns.timeColDelegate },
             ]
 
             navigationCancel: function() {
diff --git a/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
index 374430730d..1ff16eba0f 100644
--- a/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
@@ -33,14 +33,14 @@ Widgets.KeyNavigableTableView {
         { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(1), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(1), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(1), text: i18n.qtr("Artist"),   showSection: "main_artist" },
-        { criteria: "duration_short", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
+        { criteria: "duration", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
     ]
 
     property var sortModelMedium: [
         { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(2), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(2), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(1), text: i18n.qtr("Artist"),   showSection: "main_artist" },
-        { criteria: "duration_short", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
+        { criteria: "duration", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
     ]
 
     readonly property int _expandingColsSpan: Math.floor((VLCStyle.gridColumnsForWidth(root.availableRowWidth) - 3 /* static cols (track_number, etc)*/) / 3)
@@ -48,7 +48,7 @@ Widgets.KeyNavigableTableView {
         { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(root._expandingColsSpan), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(root._expandingColsSpan), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(root._expandingColsSpan), text: i18n.qtr("Artist"),   showSection: "main_artist" },
-        { criteria: "duration_short", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
+        { criteria: "duration", width: VLCStyle.colWidth(1), text: i18n.qtr("Duration"), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
         { criteria: "track_number",width: VLCStyle.colWidth(1), text: i18n.qtr("Track"), showSection: "" },
         { criteria: "disc_number", width: VLCStyle.colWidth(1), text: i18n.qtr("Disc"),  showSection: "" },
     ]
diff --git a/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml b/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
index 2193684521..27cc4c9b4e 100644
--- a/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
+++ b/modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
@@ -70,7 +70,7 @@ MainInterface.MainTableView {
 
         text: i18n.qtr("Title")
     }, {
-        criteria: "duration_short",
+        criteria: "duration",
 
         width: VLCStyle.colWidth(1),
 
diff --git a/modules/gui/qt/medialibrary/qml/VideoAll.qml b/modules/gui/qt/medialibrary/qml/VideoAll.qml
index 52245bb9a3..56e7ff9334 100644
--- a/modules/gui/qt/medialibrary/qml/VideoAll.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoAll.qml
@@ -46,7 +46,7 @@ Widgets.NavigableFocusScope {
 
     property var sortModel: [
         { text: i18n.qtr("Alphabetic"), criteria: "title"          },
-        { text: i18n.qtr("Duration"),   criteria: "duration_short" }
+        { text: i18n.qtr("Duration"),   criteria: "duration" }
     ]
 
     //---------------------------------------------------------------------------------------------
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml b/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
index 9c05d66c89..4223796189 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
@@ -23,6 +23,7 @@ import org.videolan.medialib 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///util/" as Util
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 Widgets.NavigableFocusScope {
@@ -101,7 +102,7 @@ Widgets.NavigableFocusScope {
 
                 image: model.thumbnail || VLCStyle.noArtCover
                 title: model.title || i18n.qtr("Unknown title")
-                subtitle: model.duration || ""
+                subtitle: Helpers.msToString(model.duration) || ""
                 labels: [
                     model.resolution_name || "",
                     model.channel || ""
diff --git a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
index 3a7c599c8e..86a0e59181 100644
--- a/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoGridItem.qml
@@ -20,6 +20,7 @@ import QtQuick 2.11
 import org.videolan.medialib 0.1
 
 import "qrc:///widgets/" as Widgets
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 Widgets.GridItem {
@@ -28,7 +29,7 @@ Widgets.GridItem {
 
     image: model.thumbnail || VLCStyle.noArtCover
     title: model.title || i18n.qtr("Unknown title")
-    subtitle: model.duration || ""
+    subtitle: Helpers.msToString(model.duration) || ""
     labels: [
         model.resolution_name || "",
         model.channel || ""
diff --git a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
index fd96622da0..59314c6b3a 100644
--- a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
@@ -24,6 +24,7 @@ import org.videolan.medialib 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///util/KeyHelper.js" as KeyHelper
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 Widgets.NavigableFocusScope {
@@ -169,7 +170,7 @@ Widgets.NavigableFocusScope {
                 }
 
                 Widgets.CaptionLabel {
-                    text: model.duration
+                    text: Helpers.msToString(model.duration)
                     color: VLCStyle.colors.text
                     width: parent.width
                 }
diff --git a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
index 8df4327dbe..36d8f2f9af 100644
--- a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
@@ -34,7 +34,7 @@ MainInterface.MainTableView {
     sortModel: [
         { type: "image", criteria: "thumbnail", width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { isPrimary: true, criteria: "title",   width: VLCStyle.colWidth(Math.max(listView_id._nbCols - 2, 1)), text: i18n.qtr("Title"),    showSection: "title" },
-        { criteria: "duration_short",            width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate, showContextButton: true },
+        { criteria: "duration",                 width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate, showContextButton: true },
     ]
 
     section.property: "title_first_symbol"
diff --git a/modules/gui/qt/widgets/qml/TableColumns.qml b/modules/gui/qt/widgets/qml/TableColumns.qml
index 140f31808d..491e92c44c 100644
--- a/modules/gui/qt/widgets/qml/TableColumns.qml
+++ b/modules/gui/qt/widgets/qml/TableColumns.qml
@@ -20,6 +20,7 @@ import QtQuick.Controls 2.4
 import QtQuick.Layouts 1.4
 
 import "qrc:///widgets/" as Widgets
+import "qrc:///util/Helpers.js" as Helpers
 import "qrc:///style/"
 
 Item {
@@ -108,7 +109,7 @@ Item {
             width: timeTextMetric.width
             height: parent.height
             horizontalAlignment: Text.AlignHCenter
-            text: !rowModel ? "" : rowModel[model.criteria] || ""
+            text: !rowModel || !rowModel[model.criteria] ? "" : Helpers.msToString(rowModel[model.criteria], true)
             color: foregroundColor
         }
     }
-- 
2.27.0



More information about the vlc-devel mailing list