diff options
author | hjk <hjk@qt.io> | 2023-11-21 17:53:46 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2023-11-21 17:31:04 +0000 |
commit | 6b7d25074419303f71c08aab49cc5a8660ee9880 (patch) | |
tree | 60b04ef6d37a32b724387c02447a8b95a671734f /src/plugins/perfprofiler | |
parent | da0f308bea85d5321153749d938c8f38b9a4ee25 (diff) |
PerfProfiler: Simplify StatisticView setup
Change-Id: Ie067025c1b9aec93c5f6a5baf68dbb616a066bcb
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/perfprofiler')
5 files changed, 19 insertions, 21 deletions
diff --git a/src/plugins/perfprofiler/perfprofilerstatisticsmodel.cpp b/src/plugins/perfprofiler/perfprofilerstatisticsmodel.cpp index 112252923f5..9c622331452 100644 --- a/src/plugins/perfprofiler/perfprofilerstatisticsmodel.cpp +++ b/src/plugins/perfprofiler/perfprofilerstatisticsmodel.cpp @@ -150,7 +150,7 @@ QByteArray PerfProfilerStatisticsMainModel::metaInfo( int typeId, PerfProfilerStatisticsModel::Column column) const { // Need to look up stuff from tracemanager - PerfProfilerTraceManager *manager = static_cast<PerfProfilerTraceManager *>(QObject::parent()); + PerfProfilerTraceManager *manager = &traceManager(); switch (column) { case BinaryLocation: case Function: { @@ -174,9 +174,7 @@ QByteArray PerfProfilerStatisticsMainModel::metaInfo( quint64 PerfProfilerStatisticsMainModel::address(int typeId) const { - PerfProfilerTraceManager *manager = - static_cast<PerfProfilerTraceManager *>(QObject::parent()); - return manager->location(typeId).address; + return traceManager().location(typeId).address; } void PerfProfilerStatisticsMainModel::initialize() @@ -318,14 +316,14 @@ int PerfProfilerStatisticsMainModel::rowForTypeId(int typeId) const return m_backwardIndex[static_cast<int>(it - m_data.begin())]; } -PerfProfilerStatisticsMainModel::PerfProfilerStatisticsMainModel(PerfProfilerTraceManager *parent) : +PerfProfilerStatisticsMainModel::PerfProfilerStatisticsMainModel(QObject *parent) : PerfProfilerStatisticsModel(Main, parent), m_startTime(std::numeric_limits<qint64>::min()), m_endTime(std::numeric_limits<qint64>::max()), m_totalSamples(0) { m_children = new PerfProfilerStatisticsRelativesModel(Children, this); m_parents = new PerfProfilerStatisticsRelativesModel(Parents, this); PerfProfilerStatisticsData *data = new PerfProfilerStatisticsData; - parent->registerFeatures(PerfEventType::attributeFeatures(), + traceManager().registerFeatures(PerfEventType::attributeFeatures(), std::bind(&PerfProfilerStatisticsData::loadEvent, data, std::placeholders::_1, std::placeholders::_2), std::bind(&PerfProfilerStatisticsMainModel::initialize, this), diff --git a/src/plugins/perfprofiler/perfprofilerstatisticsmodel.h b/src/plugins/perfprofiler/perfprofilerstatisticsmodel.h index 2913fcddeaf..5f5bd756125 100644 --- a/src/plugins/perfprofiler/perfprofilerstatisticsmodel.h +++ b/src/plugins/perfprofiler/perfprofilerstatisticsmodel.h @@ -55,10 +55,12 @@ protected: }; class PerfProfilerStatisticsRelativesModel; -class PerfProfilerStatisticsMainModel : public PerfProfilerStatisticsModel { + +class PerfProfilerStatisticsMainModel : public PerfProfilerStatisticsModel +{ Q_OBJECT public: - PerfProfilerStatisticsMainModel(PerfProfilerTraceManager *parent); + PerfProfilerStatisticsMainModel(QObject *parent); ~PerfProfilerStatisticsMainModel() override; PerfProfilerStatisticsRelativesModel *children() const { return m_children; } PerfProfilerStatisticsRelativesModel *parents() const { return m_parents; } diff --git a/src/plugins/perfprofiler/perfprofilerstatisticsview.cpp b/src/plugins/perfprofiler/perfprofilerstatisticsview.cpp index aed78ee711c..701308d3744 100644 --- a/src/plugins/perfprofiler/perfprofilerstatisticsview.cpp +++ b/src/plugins/perfprofiler/perfprofilerstatisticsview.cpp @@ -7,6 +7,8 @@ #include <coreplugin/minisplitter.h> +#include <utils/basetreeview.h> + #include <QApplication> #include <QClipboard> #include <QStyledItemDelegate> @@ -40,8 +42,7 @@ public: } }; -PerfProfilerStatisticsView::PerfProfilerStatisticsView(QWidget *parent, PerfProfilerTool *tool) : - QWidget(parent) +PerfProfilerStatisticsView::PerfProfilerStatisticsView() { setObjectName(QLatin1String("PerfProfilerStatisticsView")); @@ -67,8 +68,7 @@ PerfProfilerStatisticsView::PerfProfilerStatisticsView(QWidget *parent, PerfProf groupLayout->addWidget(splitterVertical); setLayout(groupLayout); - PerfProfilerTraceManager *manager = &traceManager(); - PerfProfilerStatisticsMainModel *mainModel = new PerfProfilerStatisticsMainModel(manager); + auto mainModel = new PerfProfilerStatisticsMainModel(this); PerfProfilerStatisticsRelativesModel *children = mainModel->children(); PerfProfilerStatisticsRelativesModel *parents = mainModel->parents(); @@ -77,11 +77,11 @@ PerfProfilerStatisticsView::PerfProfilerStatisticsView(QWidget *parent, PerfProf m_childrenView->setModel(children); m_parentsView->setModel(parents); - auto propagateSelection = [this, manager, children, parents](int locationId){ + auto propagateSelection = [this, children, parents](int locationId) { children->selectByTypeId(locationId); parents->selectByTypeId(locationId); - const PerfEventType::Location &location = manager->location(locationId); - const QByteArray &file = manager->string(location.file); + const PerfEventType::Location &location = traceManager().location(locationId); + const QByteArray &file = traceManager().string(location.file); if (!file.isEmpty()) emit gotoSourceLocation(QString::fromUtf8(file), location.line, location.column); emit typeSelected(locationId); diff --git a/src/plugins/perfprofiler/perfprofilerstatisticsview.h b/src/plugins/perfprofiler/perfprofilerstatisticsview.h index 1ae041731a8..58c80499b80 100644 --- a/src/plugins/perfprofiler/perfprofilerstatisticsview.h +++ b/src/plugins/perfprofiler/perfprofilerstatisticsview.h @@ -5,22 +5,20 @@ #include "perftimelinemodel.h" -#include <utils/basetreeview.h> - #include <QWidget> namespace PerfProfiler { namespace Internal { -class PerfProfilerStatisticsMainModel; -class PerfProfilerTool; class StatisticsView; class PerfProfilerStatisticsView : public QWidget { Q_OBJECT + public: - PerfProfilerStatisticsView(QWidget *parent, PerfProfilerTool *tool); + PerfProfilerStatisticsView(); + bool focusedTableHasValidSelection() const; void selectByTypeId(int symbol); diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp index a9cf1a632f1..e06adb88b7d 100644 --- a/src/plugins/perfprofiler/perfprofilertool.cpp +++ b/src/plugins/perfprofiler/perfprofilertool.cpp @@ -176,7 +176,7 @@ void PerfProfilerTool::createViews() connect(m_traceView, &PerfProfilerTraceView::gotoSourceLocation, this, &PerfProfilerTool::gotoSourceLocation); - m_statisticsView = new PerfProfilerStatisticsView(nullptr, this); + m_statisticsView = new PerfProfilerStatisticsView; m_statisticsView->setWindowTitle(Tr::tr("Statistics")); m_flameGraphView = new PerfProfilerFlameGraphView(nullptr, this); |