vlc | branch: master | Romain Vimont <[email protected]> | Tue Jul 9 18:30:28 2019 +0200| [b433af8e501a883b3cc7b78f2283ec5e88cb0078] | committer: Jean-Baptiste Kempf
qt: playlist: expose count as a property This will allow to bind the number of items to a Qml variable. Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b433af8e501a883b3cc7b78f2283ec5e88cb0078 --- modules/gui/qt/components/playlist/playlist_model.cpp | 6 ++++++ modules/gui/qt/components/playlist/playlist_model.hpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp index 983319abd9..49b8aaad22 100644 --- a/modules/gui/qt/components/playlist/playlist_model.cpp +++ b/modules/gui/qt/components/playlist/playlist_model.cpp @@ -178,6 +178,8 @@ void PlaylistListModelPrivate::onItemsReset(const QVector<PlaylistItem>& newCont q->beginResetModel(); m_items = newContent; q->endResetModel(); + + emit q->countChanged(m_items.size()); } void PlaylistListModelPrivate::onItemsAdded(const QVector<PlaylistItem>& added, size_t index) @@ -188,6 +190,8 @@ void PlaylistListModelPrivate::onItemsAdded(const QVector<PlaylistItem>& added, m_items.insert(index, count, nullptr); std::move(added.cbegin(), added.cend(), m_items.begin() + index); q->endInsertRows(); + + emit q->countChanged(m_items.size()); } void PlaylistListModelPrivate::onItemsMoved(size_t index, size_t count, size_t target) @@ -218,6 +222,8 @@ void PlaylistListModelPrivate::onItemsRemoved(size_t index, size_t count) q->beginRemoveRows({}, index, index + count - 1); m_items.remove(index, count); q->endRemoveRows(); + + emit q->countChanged(m_items.size()); } diff --git a/modules/gui/qt/components/playlist/playlist_model.hpp b/modules/gui/qt/components/playlist/playlist_model.hpp index ff6f0a46f6..cc932fed70 100644 --- a/modules/gui/qt/components/playlist/playlist_model.hpp +++ b/modules/gui/qt/components/playlist/playlist_model.hpp @@ -38,6 +38,7 @@ class PlaylistListModel : public SelectableListModel Q_OBJECT Q_PROPERTY(PlaylistPtr playlistId READ getPlaylistId WRITE setPlaylistId NOTIFY playlistIdChanged) Q_PROPERTY(int currentIndex READ getCurrentIndex NOTIFY currentIndexChanged) + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) public: enum Roles @@ -82,6 +83,7 @@ public slots: signals: void playlistIdChanged(const PlaylistPtr& ); void currentIndexChanged( int ); + void countChanged(int); private: Q_DECLARE_PRIVATE(PlaylistListModel) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
