[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: add operator< to MLItemId
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Sep 3 17:20:33 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
94eb6a6c by Fatih Uzunoglu at 2023-09-03T17:06:12+00:00
qt: add operator< to MLItemId
- - - - -
b789fcef by Fatih Uzunoglu at 2023-09-03T17:06:12+00:00
qt: make operator== and operator!= const in MLItemId
- - - - -
15fc2b8f by Fatih Uzunoglu at 2023-09-03T17:06:12+00:00
qt: get rid of QVariantList usage in MediaLib::mlInputItem
- - - - -
4 changed files:
- modules/gui/qt/medialibrary/medialib.cpp
- modules/gui/qt/medialibrary/medialib.hpp
- modules/gui/qt/medialibrary/mlqmltypes.hpp
- modules/gui/qt/qt.cpp
Changes:
=====================================
modules/gui/qt/medialibrary/medialib.cpp
=====================================
@@ -270,7 +270,7 @@ void MediaLib::reload()
});
}
-void MediaLib::mlInputItem(const QVariantList& variantList, QJSValue callback)
+void MediaLib::mlInputItem(const QVector<MLItemId>& itemIdVector, QJSValue callback)
{
if (!callback.isCallable()) // invalid argument
{
@@ -278,17 +278,11 @@ void MediaLib::mlInputItem(const QVariantList& variantList, QJSValue callback)
return;
}
- std::vector<MLItemId> mlIdList;
- for (const auto& variant : variantList)
- {
- if (variant.canConvert<MLItemId>())
- mlIdList.push_back(variant.value<MLItemId>());
- }
struct Ctx {
std::vector<SharedInputItem> items;
};
- if (mlIdList.empty())
+ if (itemIdVector.empty())
{
//call the callback with and empty list
auto jsEngine = qjsEngine(this);
@@ -299,11 +293,11 @@ void MediaLib::mlInputItem(const QVariantList& variantList, QJSValue callback)
return;
}
- auto it = m_inputItemQuery.find(variantList);
+ auto it = m_inputItemQuery.find(itemIdVector);
if (it == m_inputItemQuery.end())
{
- it = m_inputItemQuery.insert(variantList, {callback});
+ it = m_inputItemQuery.insert(itemIdVector, {callback});
}
else
{
@@ -321,8 +315,8 @@ void MediaLib::mlInputItem(const QVariantList& variantList, QJSValue callback)
runOnMLThread<Ctx>(this,
//ML thread
- [mlIdList](vlc_medialibrary_t* ml, Ctx& ctx){
- for (auto mlId : mlIdList)
+ [itemIdVector](vlc_medialibrary_t* ml, Ctx& ctx){
+ for (auto mlId : itemIdVector)
{
// NOTE: When we have a parent it's a collection of media(s).
if (mlId.type == VLC_ML_PARENT_UNKNOWN)
=====================================
modules/gui/qt/medialibrary/medialib.hpp
=====================================
@@ -73,7 +73,7 @@ public:
Q_INVOKABLE void reload();
- Q_INVOKABLE void mlInputItem(const QVariantList& variantList, QJSValue callback);
+ Q_INVOKABLE void mlInputItem(const QVector<MLItemId>& itemIdVector, QJSValue callback);
inline bool idle() const { return m_idle; }
inline int discoveryPending() const { return m_discoveryPending; }
@@ -218,7 +218,7 @@ private:
QMap<quint64, RunOnMLThreadBaseRunner*> m_runningTasks;
QMultiMap<const QObject*, quint64> m_objectTasks;
- QMap<QVariantList, QVector<QJSValue>> m_inputItemQuery;
+ QMap<QVector<MLItemId>, QVector<QJSValue>> m_inputItemQuery;
};
class RunOnMLThreadBaseRunner : public QObject, public QRunnable
=====================================
modules/gui/qt/medialibrary/mlqmltypes.hpp
=====================================
@@ -33,14 +33,19 @@ class MLItemId
public:
MLItemId() : id(0), type( VLC_ML_PARENT_UNKNOWN ) {}
MLItemId( int64_t i, vlc_ml_parent_type t ) : id( i ), type( t ) {}
- bool operator==( const MLItemId& other )
+ bool operator==( const MLItemId& other ) const
{
return id == other.id && type == other.type;
}
- bool operator!=( const MLItemId& other )
+ bool operator!=( const MLItemId& other ) const
{
return !(*this == other);
}
+ bool operator<( const MLItemId& other ) const
+ {
+ return id < other.id;
+ }
+
int64_t id;
vlc_ml_parent_type type;
=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -679,6 +679,7 @@ static inline void registerMetaTypes()
qRegisterMetaType<PlaylistItem>();
qRegisterMetaType<DialogId>();
qRegisterMetaType<MLItemId>();
+ qRegisterMetaType<QVector<MLItemId>>();
}
static void *Thread( void *obj )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8c72e5373036eec4815832be0c573963201d2bde...15fc2b8f97c8fe403af9a9dd6e0bb35ff1dd3ad2
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8c72e5373036eec4815832be0c573963201d2bde...15fc2b8f97c8fe403af9a9dd6e0bb35ff1dd3ad2
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