[vlc-commits] qt: expose count in Track, Title, Chapter and Program models
Pierre Lamot
git at videolan.org
Tue Nov 19 16:49:51 CET 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Oct 16 16:52:32 2019 +0200| [231ee3f21c97ff22ce1b052d1216d51f93bd9715] | committer: Jean-Baptiste Kempf
qt: expose count in Track, Title, Chapter and Program models
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=231ee3f21c97ff22ce1b052d1216d51f93bd9715
---
modules/gui/qt/util/input_models.cpp | 6 ++++++
modules/gui/qt/util/input_models.hpp | 29 +++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/modules/gui/qt/util/input_models.cpp b/modules/gui/qt/util/input_models.cpp
index f344e8b7f1..3164ad845c 100644
--- a/modules/gui/qt/util/input_models.cpp
+++ b/modules/gui/qt/util/input_models.cpp
@@ -83,6 +83,7 @@ void TrackListModel::updateTracks(vlc_player_list_action action, const vlc_playe
beginInsertRows({}, m_data.size(), m_data.size());
m_data.append(Data{ track_info });
endInsertRows();
+ emit countChanged();
break;
}
case VLC_PLAYER_LIST_REMOVED:
@@ -97,6 +98,7 @@ void TrackListModel::updateTracks(vlc_player_list_action action, const vlc_playe
beginRemoveRows({}, pos, pos);
m_data.erase(it);
endRemoveRows();
+ emit countChanged();
break;
}
case VLC_PLAYER_LIST_UPDATED:
@@ -253,6 +255,7 @@ void TitleListModel::resetTitles(vlc_player_title_list *newTitleList)
else
m_count = 0;
endResetModel();
+ emit countChanged();
}
QHash<int, QByteArray> TitleListModel::roleNames() const
@@ -350,6 +353,7 @@ void ChapterListModel::resetTitle(const vlc_player_title *newTitle)
m_title =newTitle;
m_current = -1;
endResetModel();
+ emit countChanged();
}
QString ChapterListModel::getNameAtPosition(float pos) const
@@ -433,6 +437,7 @@ void ProgramListModel::updatePrograms(vlc_player_list_action action, const vlc_p
beginInsertRows({}, m_data.size(), m_data.size());
m_data.append(Data{ program });
endInsertRows();
+ emit countChanged();
break;
case VLC_PLAYER_LIST_REMOVED:
@@ -446,6 +451,7 @@ void ProgramListModel::updatePrograms(vlc_player_list_action action, const vlc_p
beginRemoveRows({}, pos, pos);
m_data.erase(it);
endRemoveRows();
+ emit countChanged();
break;
}
case VLC_PLAYER_LIST_UPDATED:
diff --git a/modules/gui/qt/util/input_models.hpp b/modules/gui/qt/util/input_models.hpp
index 3744291cff..d8f9db5467 100644
--- a/modules/gui/qt/util/input_models.hpp
+++ b/modules/gui/qt/util/input_models.hpp
@@ -44,6 +44,9 @@
class TrackListModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(int count READ getCount NOTIFY countChanged)
+
+
public:
TrackListModel(vlc_player_t* player, QObject* parent = nullptr);
@@ -63,6 +66,11 @@ public:
QHash<int, QByteArray> roleNames() const override;
+ inline int getCount() const { return m_data.size(); }
+
+signals:
+ void countChanged();
+
private:
vlc_player_t* m_player;
class Data {
@@ -95,6 +103,8 @@ private:
class TitleListModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(int count READ getCount NOTIFY countChanged)
+
public:
TitleListModel(vlc_player_t* player, QObject* parent = nullptr);
@@ -115,6 +125,11 @@ public:
QHash<int, QByteArray> roleNames() const override;
+ inline int getCount() const { return m_count; }
+
+signals:
+ void countChanged();
+
private:
vlc_player_t* m_player;
typedef vlc_shared_data_ptr_type(vlc_player_title_list, vlc_player_title_list_Hold, vlc_player_title_list_Release) PlayerTitleList;
@@ -137,6 +152,8 @@ private:
class ChapterListModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(int count READ getCount NOTIFY countChanged)
+
public:
//user role
enum ChapterListRoles {
@@ -160,6 +177,11 @@ public:
void resetTitle(const vlc_player_title* newTitle);
+ inline int getCount() const { return (m_title == nullptr) ? 0 : m_title->chapter_count; }
+
+signals:
+ void countChanged();
+
public slots:
QString getNameAtPosition(float pos) const;
@@ -182,6 +204,8 @@ private:
class ProgramListModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(int count READ getCount NOTIFY countChanged)
+
public:
ProgramListModel(vlc_player_t* player, QObject* parent = nullptr);
@@ -201,6 +225,11 @@ public:
QHash<int, QByteArray> roleNames() const override;
+ inline int getCount() const { return m_data.size(); }
+
+signals:
+ void countChanged();
+
private:
vlc_player_t* m_player;
class Data {
More information about the vlc-commits
mailing list