[vlc-devel] [PATCH] qt: mlbasemodel: remove usage of QObject in get()

Alexandre Janniaux ajanni at videolabs.io
Wed Oct 9 14:33:15 CEST 2019


get() in never used in QML nor in the mlbasemodel class and can be
replaced by a call to index() in the interface.
Non-QObject entries would have lower memory footprint and help reuse
code across different models.

See https://doc.qt.io/qt-5/qabstractitemmodel.html#index.
---
 modules/gui/qt/components/mediacenter/mlbasemodel.hpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/modules/gui/qt/components/mediacenter/mlbasemodel.hpp b/modules/gui/qt/components/mediacenter/mlbasemodel.hpp
index 8bb273075a7..7b273e4810f 100644
--- a/modules/gui/qt/components/mediacenter/mlbasemodel.hpp
+++ b/modules/gui/qt/components/mediacenter/mlbasemodel.hpp
@@ -44,8 +44,6 @@ public:
 
     Q_INVOKABLE void sortByColumn(QByteArray name, Qt::SortOrder order);
 
-    Q_INVOKABLE virtual QObject *get(unsigned int idx) const = 0;
-
     Q_PROPERTY( MLParentId parentId READ parentId WRITE setParentId NOTIFY parentIdChanged RESET unsetParentId )
     Q_PROPERTY( MCMediaLib* ml READ ml WRITE setMl )
     Q_PROPERTY( unsigned int maxItems MEMBER m_nb_max_items )
@@ -147,7 +145,7 @@ public:
         return m_total_count;
     }
 
-    QObject* get(unsigned int idx) const override
+    virtual T* get(unsigned int idx) const
     {
         vlc_mutex_locker lock( &m_item_lock );
         T* obj = item( idx );
-- 
2.23.0



More information about the vlc-devel mailing list