[vlc-commits] qt: add property durationShort to album model
Prince Gupta
git at videolan.org
Wed Jun 24 17:42:00 CEST 2020
vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Thu Jun 18 20:34:02 2020 +0530| [e1662eada45d55a66c24772ba849e5c5ddefd76a] | committer: Pierre Lamot
qt: add property durationShort to album model
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e1662eada45d55a66c24772ba849e5c5ddefd76a
---
modules/gui/qt/medialibrary/mlalbum.cpp | 13 +++++++++++++
modules/gui/qt/medialibrary/mlalbum.hpp | 3 +++
modules/gui/qt/medialibrary/mlalbummodel.cpp | 4 ++++
modules/gui/qt/medialibrary/mlalbummodel.hpp | 1 +
4 files changed, 21 insertions(+)
diff --git a/modules/gui/qt/medialibrary/mlalbum.cpp b/modules/gui/qt/medialibrary/mlalbum.cpp
index 2c4a1e9bb8..5fa09b5ba0 100644
--- a/modules/gui/qt/medialibrary/mlalbum.cpp
+++ b/modules/gui/qt/medialibrary/mlalbum.cpp
@@ -37,14 +37,22 @@ MLAlbum::MLAlbum(vlc_medialibrary_t* _ml, const vlc_ml_album_t *_data, QObject *
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'));
+ }
}
//private ctor for cloning
@@ -103,6 +111,11 @@ QString MLAlbum::getDuration() const
return m_duration;
}
+QString MLAlbum::getDurationShort() const
+{
+ return m_durationShort;
+}
+
MLAlbum *MLAlbum::clone(QObject *parent) const
{
return new MLAlbum(*this, parent);
diff --git a/modules/gui/qt/medialibrary/mlalbum.hpp b/modules/gui/qt/medialibrary/mlalbum.hpp
index b907e441b0..95ca6088a5 100644
--- a/modules/gui/qt/medialibrary/mlalbum.hpp
+++ b/modules/gui/qt/medialibrary/mlalbum.hpp
@@ -43,6 +43,7 @@ class MLAlbum : public QObject
Q_PROPERTY(QString artist READ getArtist CONSTANT)
Q_PROPERTY(unsigned int nbtracks READ getNbTracks CONSTANT)
Q_PROPERTY(QString duration READ getDuration CONSTANT)
+ Q_PROPERTY(QString durationShort READ getDuration CONSTANT)
public:
MLAlbum(vlc_medialibrary_t* _ml, const vlc_ml_album_t *_data, QObject *_parent = nullptr);
@@ -55,6 +56,7 @@ public:
QString getArtist() const;
unsigned int getNbTracks() const;
QString getDuration() const;
+ QString getDurationShort() const;
MLAlbum* clone(QObject *parent = nullptr) const;
@@ -77,4 +79,5 @@ private:
QList<QString> m_otherArtists;
unsigned int m_nbTracks;
QString m_duration;
+ QString m_durationShort;
};
diff --git a/modules/gui/qt/medialibrary/mlalbummodel.cpp b/modules/gui/qt/medialibrary/mlalbummodel.cpp
index b4a62b9de0..d8a686eeda 100644
--- a/modules/gui/qt/medialibrary/mlalbummodel.cpp
+++ b/modules/gui/qt/medialibrary/mlalbummodel.cpp
@@ -59,6 +59,8 @@ 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:
@@ -79,6 +81,7 @@ QHash<int, QByteArray> MLAlbumModel::roleNames() const
{ALBUM_MAIN_ARTIST, "main_artist"},
{ALBUM_NB_TRACKS, "nb_tracks"},
{ALBUM_DURATION, "duration"},
+ {ALBUM_DURATION_SHORT, "durationShort"},
{ALBUM_TITLE_FIRST_SYMBOL, "title_first_symbol"},
{ALBUM_MAIN_ARTIST_FIRST_SYMBOL, "main_artist_first_symbol"}
};
@@ -150,6 +153,7 @@ 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 f531851d00..972fbc64a7 100644
--- a/modules/gui/qt/medialibrary/mlalbummodel.hpp
+++ b/modules/gui/qt/medialibrary/mlalbummodel.hpp
@@ -43,6 +43,7 @@ public:
ALBUM_MAIN_ARTIST,
ALBUM_NB_TRACKS,
ALBUM_DURATION,
+ ALBUM_DURATION_SHORT,
ALBUM_TITLE_FIRST_SYMBOL,
ALBUM_MAIN_ARTIST_FIRST_SYMBOL
More information about the vlc-commits
mailing list