Skip to content

Commit

Permalink
Remove RecursiveProxyModelBase
Browse files Browse the repository at this point in the history
We use QSortFilterProxyModel directly now
  • Loading branch information
Waqar144 authored and Allen Winter committed Dec 26, 2023
1 parent 31a3f84 commit 0d4bc1d
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 128 deletions.
2 changes: 0 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ set(gammaray_common_srcs
remoteviewframe.cpp
transferimage.cpp
commonutils.cpp
recursiveproxymodelbase.cpp
)

add_library(
Expand Down Expand Up @@ -145,7 +144,6 @@ if(NOT GAMMARAY_PROBE_ONLY_BUILD)
translator.h
commonutils.h
favoriteobjectinterface.h
recursiveproxymodelbase.h
)

ecm_generate_pri_file(
Expand Down
8 changes: 4 additions & 4 deletions common/objectidfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using namespace GammaRay;

ObjectIdsFilterProxyModel::ObjectIdsFilterProxyModel(QObject *parent)
: RecursiveProxyModelBase(parent)
: QSortFilterProxyModel(parent)
{
}

Expand All @@ -41,11 +41,11 @@ void ObjectIdsFilterProxyModel::setIds(const GammaRay::ObjectIds &ids)
invalidateFilter();
}

bool ObjectIdsFilterProxyModel::acceptRow(int source_row, const QModelIndex &source_parent) const
bool ObjectIdsFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
// shortcut for the common case, the object id stuff below allocates memory and does expensive model lookups
if (m_ids.isEmpty()) {
return RecursiveProxyModelBase::acceptRow(source_row, source_parent);
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}

const QModelIndex source_index = sourceModel()->index(source_row, 0, source_parent);
Expand All @@ -58,7 +58,7 @@ bool ObjectIdsFilterProxyModel::acceptRow(int source_row, const QModelIndex &sou
return false;
}

return RecursiveProxyModelBase::acceptRow(source_row, source_parent);
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}

bool ObjectIdsFilterProxyModel::filterAcceptsObjectId(const GammaRay::ObjectId &id) const
Expand Down
6 changes: 3 additions & 3 deletions common/objectidfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "gammaray_common_export.h"

#include <common/objectid.h>
#include <common/recursiveproxymodelbase.h>
#include <QSortFilterProxyModel>

namespace GammaRay {

Expand All @@ -26,7 +26,7 @@ namespace GammaRay {
*
* Filter in and sort according to the objects list.
*/
class GAMMARAY_COMMON_EXPORT ObjectIdsFilterProxyModel : public RecursiveProxyModelBase
class GAMMARAY_COMMON_EXPORT ObjectIdsFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT

Expand All @@ -50,7 +50,7 @@ class GAMMARAY_COMMON_EXPORT ObjectIdsFilterProxyModel : public RecursiveProxyMo
* @return true if the item in the row can be included in the model;
* otherwise returns false.
*/
bool acceptRow(int source_row, const QModelIndex &source_parent) const override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;

/**
* Determines if the specified ObjectID can be included in the model.
Expand Down
27 changes: 0 additions & 27 deletions common/recursiveproxymodelbase.cpp

This file was deleted.

41 changes: 0 additions & 41 deletions common/recursiveproxymodelbase.h

This file was deleted.

4 changes: 2 additions & 2 deletions core/tools/metaobjectbrowser/metaobjectbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <common/objectbroker.h>
#include <common/metatypedeclarations.h>
#include <common/tools/metaobjectbrowser/qmetaobjectmodel.h>
#include <common/recursiveproxymodelbase.h>

#include <QDebug>
#include <QSortFilterProxyModel>
#include <QItemSelectionModel>

using namespace GammaRay;
Expand All @@ -37,7 +37,7 @@ MetaObjectBrowser::MetaObjectBrowser(Probe *probe, QObject *parent)
, m_motm(new MetaObjectTreeModel(this))
, m_model(nullptr)
{
auto model = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto model = new ServerProxyModel<QSortFilterProxyModel>(this);
model->addRole(QMetaObjectModel::MetaObjectIssues);
model->addRole(QMetaObjectModel::MetaObjectInvalid);
model->setSourceModel(m_motm);
Expand Down
3 changes: 1 addition & 2 deletions core/tools/objectinspector/objectinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <core/problemcollector.h>
#include <core/util.h>
#include <remote/serverproxymodel.h>
#include <common/recursiveproxymodelbase.h>

#include <QCoreApplication>
#include <QItemSelectionModel>
Expand All @@ -52,7 +51,7 @@ ObjectInspector::ObjectInspector(Probe *probe, QObject *parent)
"com.kdab.GammaRay.ObjectInspector"),
this);

auto proxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto proxy = new ServerProxyModel<QSortFilterProxyModel>(this);
proxy->setSourceModel(probe->objectTreeModel());
probe->registerModel(QStringLiteral("com.kdab.GammaRay.ObjectInspectorTree"), proxy);

Expand Down
6 changes: 3 additions & 3 deletions core/tools/resourcebrowser/resourcefiltermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
using namespace GammaRay;

ResourceFilterModel::ResourceFilterModel(QObject *parent)
: RecursiveProxyModelBase(parent)
: QSortFilterProxyModel(parent)
{
}

bool ResourceFilterModel::acceptRow(int source_row, const QModelIndex &source_parent) const
bool ResourceFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
const QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
const QString path = index.data(ResourceModel::FilePathRole).toString();
if (path == QLatin1String(":/gammaray") || path.startsWith(QLatin1String(":/gammaray/")))
return false;
return RecursiveProxyModelBase::acceptRow(source_row, source_parent);
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
6 changes: 3 additions & 3 deletions core/tools/resourcebrowser/resourcefiltermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#ifndef GAMMARAY_RESOURCEBROWSER_RESOURCEFILTERMODEL_H
#define GAMMARAY_RESOURCEBROWSER_RESOURCEFILTERMODEL_H

#include <common/recursiveproxymodelbase.h>
#include <QSortFilterProxyModel>

namespace GammaRay {
class ResourceFilterModel : public RecursiveProxyModelBase
class ResourceFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit ResourceFilterModel(QObject *parent = nullptr);
bool acceptRow(int source_row, const QModelIndex &source_parent) const override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
};
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/mimetypes/mimetypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#include "mimetypes.h"
#include "mimetypesmodel.h"

#include <common/recursiveproxymodelbase.h>
#include <QSortFilterProxyModel>

using namespace GammaRay;

MimeTypes::MimeTypes(Probe *probe, QObject *parent)
: QObject(parent)
{
auto model = new MimeTypesModel(this);
auto proxy = new RecursiveProxyModelBase(this);
auto proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(model);
probe->registerModel(QStringLiteral("com.kdab.GammaRay.MimeTypeModel"), proxy);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/modelinspector/modelinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

#include <core/remote/serverproxymodel.h>
#include <common/objectbroker.h>
#include <common/recursiveproxymodelbase.h>

#include <QDebug>
#include <QItemSelectionModel>
#include <QSortFilterProxyModel>

using namespace GammaRay;

Expand All @@ -40,7 +40,7 @@ ModelInspector::ModelInspector(Probe *probe, QObject *parent)
connect(probe, &Probe::objectCreated, modelModelSource, &ModelModel::objectAdded);
connect(probe, &Probe::objectDestroyed, modelModelSource, &ModelModel::objectRemoved);

auto modelModelProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto modelModelProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
modelModelProxy->setSourceModel(modelModelSource);
m_modelModel = modelModelProxy;
probe->registerModel(QStringLiteral("com.kdab.GammaRay.ModelModel"), m_modelModel);
Expand Down
6 changes: 3 additions & 3 deletions plugins/qt3dinspector/3dinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include <common/modelevent.h>
#include <common/objectbroker.h>
#include <common/recursiveproxymodelbase.h>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <Qt3DCore/QAttribute>
Expand Down Expand Up @@ -69,6 +68,7 @@ namespace Qt3DGeometry = Qt3DRender;
#include <QDebug>
#include <QItemSelection>
#include <QItemSelectionModel>
#include <QSortFilterProxyModel>

using namespace GammaRay;

Expand Down Expand Up @@ -104,7 +104,7 @@ Qt3DInspector::Qt3DInspector(Probe *probe, QObject *parent)
connect(probe, &Probe::objectCreated, m_entityModel, &Qt3DEntityTreeModel::objectCreated);
connect(probe, &Probe::objectDestroyed, m_entityModel, &Qt3DEntityTreeModel::objectDestroyed);
connect(probe, &Probe::objectReparented, m_entityModel, &Qt3DEntityTreeModel::objectReparented);
auto entityProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto entityProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
entityProxy->setSourceModel(m_entityModel);
probe->registerModel(QStringLiteral("com.kdab.GammaRay.Qt3DInspector.sceneModel"), entityProxy);
m_entitySelectionModel = ObjectBroker::selectionModel(entityProxy);
Expand All @@ -114,7 +114,7 @@ Qt3DInspector::Qt3DInspector(Probe *probe, QObject *parent)
connect(probe, &Probe::objectCreated, m_frameGraphModel, &FrameGraphModel::objectCreated);
connect(probe, &Probe::objectDestroyed, m_frameGraphModel, &FrameGraphModel::objectDestroyed);
connect(probe, &Probe::objectReparented, m_frameGraphModel, &FrameGraphModel::objectReparented);
auto frameGraphProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto frameGraphProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
frameGraphProxy->setSourceModel(m_frameGraphModel);
probe->registerModel(QStringLiteral(
"com.kdab.GammaRay.Qt3DInspector.frameGraphModel"),
Expand Down
6 changes: 3 additions & 3 deletions plugins/quickinspector/quickinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <common/probecontrollerinterface.h>
#include <common/problem.h>
#include <common/remoteviewframe.h>
#include <common/recursiveproxymodelbase.h>

#include <core/enumrepositoryserver.h>
#include <core/metaenum.h>
Expand Down Expand Up @@ -75,6 +74,7 @@
#include <QMatrix4x4>
#include <QCoreApplication>
#include <QMutexLocker>
#include <QSortFilterProxyModel>

#include <QSGRenderNode>
#include <QSGRendererInterface>
Expand Down Expand Up @@ -363,7 +363,7 @@ QuickInspector::QuickInspector(Probe *probe, QObject *parent)
m_windowModel = proxy;
probe->registerModel(QStringLiteral("com.kdab.GammaRay.QuickWindowModel"), m_windowModel);

auto filterProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto filterProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
filterProxy->setSourceModel(m_itemModel);
filterProxy->addRole(ObjectModel::ObjectIdRole);
probe->registerModel(QStringLiteral("com.kdab.GammaRay.QuickItemModel"), filterProxy);
Expand All @@ -383,7 +383,7 @@ QuickInspector::QuickInspector(Probe *probe, QObject *parent)
connect(m_itemSelectionModel, &QItemSelectionModel::selectionChanged,
this, &QuickInspector::itemSelectionChanged);

auto sgFilterProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto sgFilterProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
sgFilterProxy->setSourceModel(m_sgModel);
probe->registerModel(QStringLiteral("com.kdab.GammaRay.QuickSceneGraphModel"), sgFilterProxy);

Expand Down
4 changes: 2 additions & 2 deletions plugins/sceneinspector/sceneinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <common/endpoint.h>
#include <common/metatypedeclarations.h>
#include <common/objectmodel.h>
#include <common/recursiveproxymodelbase.h>

#include <QGraphicsEffect>
#include <QGraphicsItem>
Expand All @@ -42,6 +41,7 @@
#include <QGraphicsView>
#include <QItemSelectionModel>
#include <QTextDocument>
#include <QSortFilterProxyModel>

#include <iostream>

Expand Down Expand Up @@ -90,7 +90,7 @@ SceneInspector::SceneInspector(Probe *probe, QObject *parent)
this, &SceneInspector::sceneSelected);

m_sceneModel = new SceneModel(this);
auto sceneProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto sceneProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
sceneProxy->setSourceModel(m_sceneModel);
sceneProxy->addRole(ObjectModel::ObjectIdRole);
probe->registerModel(QStringLiteral("com.kdab.GammaRay.SceneGraphModel"), sceneProxy);
Expand Down
4 changes: 2 additions & 2 deletions plugins/widgetinspector/widgetinspectorserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "common/paths.h"
#include <common/probecontrollerinterface.h>
#include <common/remoteviewframe.h>
#include <common/recursiveproxymodelbase.h>

#include <QAction>
#include <QAbstractItemView>
Expand Down Expand Up @@ -71,6 +70,7 @@
#include <QStyle>
#include <QToolButton>
#include <QWindow>
#include <QSortFilterProxyModel>

#include <iostream>

Expand Down Expand Up @@ -111,7 +111,7 @@ WidgetInspectorServer::WidgetInspectorServer(Probe *probe, QObject *parent)
auto *widgetFilterProxy = new WidgetTreeModel(this);
widgetFilterProxy->setSourceModel(probe->objectTreeModel());

auto widgetSearchProxy = new ServerProxyModel<RecursiveProxyModelBase>(this);
auto widgetSearchProxy = new ServerProxyModel<QSortFilterProxyModel>(this);
widgetSearchProxy->setSourceModel(widgetFilterProxy);
widgetSearchProxy->addRole(ObjectModel::ObjectIdRole);

Expand Down
Loading

0 comments on commit 0d4bc1d

Please sign in to comment.