[vlc-devel] [PATCH 07/15] qt/playlist_model: Add the 'getItemsForIndexes' function
Benjamin Arnaud
benjamin.arnaud at videolabs.io
Thu Mar 11 09:16:51 UTC 2021
---
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;
--
2.25.1
More information about the vlc-devel
mailing list