[vlc-devel] [PATCH 05/12] qt/mlbasemodel: Add 'getData' function for QModelIndex
Benjamin Arnaud
benjamin.arnaud at videolabs.io
Wed Apr 14 08:05:52 UTC 2021
---
modules/gui/qt/medialibrary/mlbasemodel.cpp | 21 +++++++++++++++++----
modules/gui/qt/medialibrary/mlbasemodel.hpp | 3 ++-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.cpp b/modules/gui/qt/medialibrary/mlbasemodel.cpp
index c3d00d65cb..5af3cd3916 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.cpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.cpp
@@ -52,16 +52,29 @@ void MLBaseModel::sortByColumn(QByteArray name, Qt::SortOrder order)
endResetModel();
}
-QMap<QString, QVariant> MLBaseModel::getDataAt(int idx)
+//-------------------------------------------------------------------------------------------------
+
+/* Q_INVOKABLE */ QMap<QString, QVariant> MLBaseModel::getDataAt(const QModelIndex & index)
{
QMap<QString, QVariant> dataDict;
- QHash<int,QByteArray> roles = roleNames();
- for (auto role: roles.keys()) {
- dataDict[roles[role]] = data(index(idx), role);
+
+ QHash<int, QByteArray> roles = roleNames();
+
+ for (int role: roles.keys())
+ {
+ dataDict[roles[role]] = data(index, role);
}
+
return dataDict;
}
+/* Q_INVOKABLE */ QMap<QString, QVariant> MLBaseModel::getDataAt(int idx)
+{
+ return getDataAt(index(idx));
+}
+
+//-------------------------------------------------------------------------------------------------
+
void MLBaseModel::onResetRequested()
{
beginResetModel();
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp b/modules/gui/qt/medialibrary/mlbasemodel.hpp
index 349a75a3fc..2c54681a45 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -74,7 +74,8 @@ public: // Interface
Q_INVOKABLE virtual QVariantList getItemsForIndexes(const QModelIndexList & indexes) const;
- Q_INVOKABLE QMap<QString, QVariant> getDataAt(int index);
+ Q_INVOKABLE QMap<QString, QVariant> getDataAt(const QModelIndex & index);
+ Q_INVOKABLE QMap<QString, QVariant> getDataAt(int idx);
signals:
void parentIdChanged();
--
2.25.1
More information about the vlc-devel
mailing list