[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: make `MLPlaylistListModel::create()` use `MLPlaylistListModel::append()` for initial items
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri May 17 12:55:56 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
9138c70e by Fatih Uzunoglu at 2024-05-17T12:37:36+00:00
qt: make `MLPlaylistListModel::create()` use `MLPlaylistListModel::append()` for initial items
Currently, the code is duplicated and only the `append()` path has
the functionality of supporting foreign items.
- - - - -
f113a23a by Fatih Uzunoglu at 2024-05-17T12:37:36+00:00
Revert "qt: use `QVector<SharedInputItem>` instead of `QVariantList` as `NetworkMediaModel::getItemsForIndexes()` return type"
This reverts commit 8b36c244517bca9c3d43adbb76b499690e646bcd.
- - - - -
9eee74e8 by Fatih Uzunoglu at 2024-05-17T12:37:36+00:00
Revert "qt: use `QVector<SharedInputItem>` instead of `QVariantList` as `NetworkDeviceModel::getItemsForIndexes()` return type"
This reverts commit 37dd8a1e0b118069b9659f128077271387aaa769.
- - - - -
d6be0506 by Fatih Uzunoglu at 2024-05-17T12:37:36+00:00
Revert "qt: use `QVector<SharedInputItem>` instead of `QVariantList` as `PlaylistListModel::getItemsForIndexes()` return type"
This reverts commit ee5566c8b53af97a70ca9698cb3ded15cb029792.
- - - - -
7 changed files:
- modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
- modules/gui/qt/network/networkdevicemodel.cpp
- modules/gui/qt/network/networkdevicemodel.hpp
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/network/networkmediamodel.hpp
- modules/gui/qt/playlist/playlist_model.cpp
- modules/gui/qt/playlist/playlist_model.hpp
Changes:
=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
=====================================
@@ -88,31 +88,25 @@ void appendMediaIntoPlaylist(vlc_medialibrary_t* ml, int64_t playlistId, const s
{
assert(m_mediaLib);
+ struct Ctx {
+ MLItemId createdPlaylistId;
+ };
- std::vector<MLItemId> itemList;
- for (const QVariant & id : initialItems)
- {
- if (id.canConvert<MLItemId>() == false)
- continue;
-
- const MLItemId & itemId = id.value<MLItemId>();
-
- if (itemId.id == 0)
- continue;
- itemList.push_back(itemId);
- }
-
- m_mediaLib->runOnMLThread(this,
+ m_mediaLib->runOnMLThread<Ctx>(this,
//ML thread
- [name, itemList](vlc_medialibrary_t* ml)
+ [name](vlc_medialibrary_t* ml, Ctx& ctx)
{
vlc_ml_playlist_t * playlist = vlc_ml_playlist_create(ml, qtu(name));
if (playlist)
{
- auto playlistId = playlist->i_id;
+ ctx.createdPlaylistId = MLItemId(playlist->i_id, VLC_ML_PARENT_UNKNOWN);
vlc_ml_playlist_release(playlist);
-
- appendMediaIntoPlaylist(ml, playlistId, itemList);
+ }
+ },
+ [this, initialItems](quint64, const Ctx& ctx) {
+ if (ctx.createdPlaylistId.id)
+ {
+ append(ctx.createdPlaylistId, initialItems);
}
});
}
=====================================
modules/gui/qt/network/networkdevicemodel.cpp
=====================================
@@ -559,10 +559,10 @@ bool NetworkDeviceModel::addAndPlay(const QModelIndexList& itemIdList)
}
/* Q_INVOKABLE */
-QVector<SharedInputItem> NetworkDeviceModel::getItemsForIndexes(const QModelIndexList & indexes) const
+QVariantList NetworkDeviceModel::getItemsForIndexes(const QModelIndexList & indexes) const
{
Q_D(const NetworkDeviceModel);
- QVector<SharedInputItem> items;
+ QVariantList items;
for (const QModelIndex & modelIndex : indexes)
{
@@ -570,7 +570,7 @@ QVector<SharedInputItem> NetworkDeviceModel::getItemsForIndexes(const QModelInde
if (!item)
continue;
- items.append(SharedInputItem(item->inputItem.get(), true));
+ items.append(QVariant::fromValue(SharedInputItem(item->inputItem.get(), true)));
}
return items;
=====================================
modules/gui/qt/network/networkdevicemodel.hpp
=====================================
@@ -115,7 +115,7 @@ public:
Q_INVOKABLE bool addAndPlay(const QVariantList& itemIdList);
Q_INVOKABLE bool addAndPlay(const QModelIndexList& itemIdList);
- Q_INVOKABLE QVector<SharedInputItem> getItemsForIndexes(const QModelIndexList & indexes) const;
+ Q_INVOKABLE QVariantList getItemsForIndexes(const QModelIndexList & indexes) const;
signals:
void ctxChanged();
=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -721,10 +721,10 @@ bool NetworkMediaModel::addAndPlay(const QModelIndexList& itemIdList)
}
/* Q_INVOKABLE */
-QVector<SharedInputItem> NetworkMediaModel::getItemsForIndexes(const QModelIndexList & indexes) const
+QVariantList NetworkMediaModel::getItemsForIndexes(const QModelIndexList & indexes) const
{
Q_D(const NetworkMediaModel);
- QVector<SharedInputItem> items;
+ QVariantList items;
for (const QModelIndex & modelIndex : indexes)
{
@@ -736,7 +736,7 @@ QVector<SharedInputItem> NetworkMediaModel::getItemsForIndexes(const QModelIndex
const NetworkTreeItem & tree = item->tree;
- items.append(SharedInputItem(tree.media.get(), true));
+ items.append(QVariant::fromValue(SharedInputItem(tree.media.get(), true)));
}
return items;
=====================================
modules/gui/qt/network/networkmediamodel.hpp
=====================================
@@ -173,7 +173,7 @@ public:
Q_INVOKABLE bool addAndPlay(const QVariantList& itemIdList);
Q_INVOKABLE bool addAndPlay(const QModelIndexList& itemIdList);
- Q_INVOKABLE QVector<SharedInputItem> getItemsForIndexes(const QModelIndexList & indexes) const;
+ Q_INVOKABLE QVariantList getItemsForIndexes(const QModelIndexList & indexes) const;
signals:
void nameChanged();
=====================================
modules/gui/qt/playlist/playlist_model.cpp
=====================================
@@ -24,6 +24,7 @@
#include "playlist_model_p.hpp"
#include <algorithm>
#include <cassert>
+#include "util/shared_input_item.hpp"
#include "playlist_controller.hpp"
namespace vlc {
@@ -401,11 +402,11 @@ int PlaylistListModel::getCurrentIndex() const
}
/* Q_INVOKABLE */
-QVector<SharedInputItem> PlaylistListModel::getItemsForIndexes(const QVector<int> & indexes) const
+QVariantList PlaylistListModel::getItemsForIndexes(const QVector<int> & indexes) const
{
Q_D(const PlaylistListModel);
- QVector<SharedInputItem> items;
+ QVariantList items;
for (int index : indexes)
{
@@ -422,7 +423,7 @@ QVector<SharedInputItem> PlaylistListModel::getItemsForIndexes(const QVector<int
if (media == nullptr)
continue;
- items.append(SharedInputItem(media, true));
+ items.append(QVariant::fromValue(SharedInputItem(media, true)));
}
return items;
=====================================
modules/gui/qt/playlist/playlist_model.hpp
=====================================
@@ -26,7 +26,6 @@
#include "playlist_common.hpp"
#include "playlist_item.hpp"
#include "util/vlctick.hpp"
-#include "util/shared_input_item.hpp"
#include <QAbstractListModel>
@@ -72,7 +71,7 @@ public:
int getCurrentIndex() const;
- Q_INVOKABLE QVector<SharedInputItem> getItemsForIndexes(const QVector<int> & indexes) const;
+ Q_INVOKABLE QVariantList getItemsForIndexes(const QVector<int> & indexes) const;
public slots:
Playlist getPlaylist() const;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/194d62d747ffbc5b3f58a4e53116244d26501ced...d6be050663254d94ece1aebbe8b49c3e16f26aad
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/194d62d747ffbc5b3f58a4e53116244d26501ced...d6be050663254d94ece1aebbe8b49c3e16f26aad
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list