[vlc-commits] qt/playlist_model: Add the 'getItemsForIndexes' function
Benjamin Arnaud
git at videolan.org
Mon Mar 15 10:34:53 UTC 2021
vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Thu Mar 11 10:16:51 2021 +0100| [c869a60d0340f8ad9b3cb1738381d2b80a062a9f] | committer: Pierre Lamot
qt/playlist_model: Add the 'getItemsForIndexes' function
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c869a60d0340f8ad9b3cb1738381d2b80a062a9f
---
modules/gui/qt/playlist/playlist_model.cpp | 31 ++++++++++++++++++++++++++++++
modules/gui/qt/playlist/playlist_model.hpp | 2 ++
2 files changed, 33 insertions(+)
diff --git a/modules/gui/qt/playlist/playlist_model.cpp b/modules/gui/qt/playlist/playlist_model.cpp
index ac793bd839..0db95e545a 100644
--- a/modules/gui/qt/playlist/playlist_model.cpp
+++ b/modules/gui/qt/playlist/playlist_model.cpp
@@ -24,6 +24,7 @@
#include "playlist_model_p.hpp"
#include <algorithm>
#include <assert.h>
+#include "util/qmlinputitem.hpp"
namespace vlc {
namespace playlist {
@@ -422,6 +423,36 @@ int PlaylistListModel::getCurrentIndex() const
return d->m_current;
}
+/* Q_INVOKABLE */
+QVariantList PlaylistListModel::getItemsForIndexes(const QList<int> & indexes) const
+{
+ Q_D(const PlaylistListModel);
+
+ QVariantList items;
+
+ for (int index : indexes)
+ {
+ if (index < 0 || index >= d->m_items.count())
+ continue;
+
+ vlc_playlist_item_t * item = d->m_items[index].raw();
+
+ if (item == nullptr)
+ continue;
+
+ input_item_t * media = vlc_playlist_item_GetMedia(item);
+
+ if (media == nullptr)
+ continue;
+
+ QmlInputItem input(media, true);
+
+ items.append(QVariant::fromValue(input));
+ }
+
+ return items;
+}
+
PlaylistPtr PlaylistListModel::getPlaylistId() const
{
Q_D(const PlaylistListModel);
diff --git a/modules/gui/qt/playlist/playlist_model.hpp b/modules/gui/qt/playlist/playlist_model.hpp
index fdf487316e..79f533c008 100644
--- a/modules/gui/qt/playlist/playlist_model.hpp
+++ b/modules/gui/qt/playlist/playlist_model.hpp
@@ -73,6 +73,8 @@ public:
int getCurrentIndex() const;
+ Q_INVOKABLE QVariantList getItemsForIndexes(const QList<int> & indexes) const;
+
protected:
bool isRowSelected(int row) const override;
void setRowSelected(int row, bool selected) override;
More information about the vlc-commits
mailing list