[vlc-commits] qt: add title_first_symbol property to mlvideomodel
Abel Tesfaye
git at videolan.org
Tue Aug 20 18:21:12 CEST 2019
vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Fri Aug 9 13:49:27 2019 +0300| [4d856f3e20c571fe18f70007492a031d148829a7] | committer: Jean-Baptiste Kempf
qt: add title_first_symbol property to mlvideomodel
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4d856f3e20c571fe18f70007492a031d148829a7
---
modules/gui/qt/components/mediacenter/mlvideomodel.cpp | 13 +++++++++++++
modules/gui/qt/components/mediacenter/mlvideomodel.hpp | 1 +
2 files changed, 14 insertions(+)
diff --git a/modules/gui/qt/components/mediacenter/mlvideomodel.cpp b/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
index 01fe549d0f..26136de8ac 100644
--- a/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
+++ b/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
@@ -33,6 +33,8 @@ enum Role {
VIDEO_MRL,
VIDEO_VIDEO_TRACK,
VIDEO_AUDIO_TRACK,
+
+ VIDEO_TITLE_FIRST_SYMBOL,
};
}
@@ -80,6 +82,9 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
return QVariant::fromValue( video->getVideoDesc() );
case VIDEO_AUDIO_TRACK:
return QVariant::fromValue( video->getAudioDesc() );
+ case VIDEO_TITLE_FIRST_SYMBOL:
+ return QVariant::fromValue( getFirstSymbol( video->getTitle() ) );
+
default:
return {};
}
@@ -100,6 +105,7 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
{ VIDEO_MRL, "mrl" },
{ VIDEO_AUDIO_TRACK, "audioDesc" },
{ VIDEO_VIDEO_TRACK, "videoDesc" },
+ { VIDEO_TITLE_FIRST_SYMBOL, "title_first_symbol"},
};
}
@@ -158,3 +164,10 @@ void MLVideoModel::onVlcMlEvent(const vlc_ml_event_t* event)
}
MLBaseModel::onVlcMlEvent( event );
}
+QString MLVideoModel::getFirstSymbol( const QString& str )
+{
+ QString ret("#");
+ if ( str.length() > 0 && str[0].isLetter() )
+ ret = str[0].toUpper();
+ return ret;
+}
diff --git a/modules/gui/qt/components/mediacenter/mlvideomodel.hpp b/modules/gui/qt/components/mediacenter/mlvideomodel.hpp
index 91e2d62fe1..ae0bac0dc6 100644
--- a/modules/gui/qt/components/mediacenter/mlvideomodel.hpp
+++ b/modules/gui/qt/components/mediacenter/mlvideomodel.hpp
@@ -50,6 +50,7 @@ private:
virtual void onVlcMlEvent( const vlc_ml_event_t* event ) override;
static QHash<QByteArray, vlc_ml_sorting_criteria_t> M_names_to_criteria;
+ static QString getFirstSymbol( const QString& str );
};
#endif // MCVIDEOMODEL_H
More information about the vlc-commits
mailing list