99#include " resultstopdownpage.h"
1010#include " ui_resultstopdownpage.h"
1111
12+ #include " data.h"
1213#include " parsers/perf/perfparser.h"
1314#include " resultsutil.h"
1415
1819ResultsTopDownPage::ResultsTopDownPage (FilterAndZoomStack* filterStack, PerfParser* parser,
1920 CostContextMenu* contextMenu, QWidget* parent)
2021 : QWidget(parent)
22+ , m_model(new TopDownModel(this ))
2123 , ui(new Ui::ResultsTopDownPage)
2224{
2325 ui->setupUi (this );
2426
25- auto topDownCostModel = new TopDownModel (this );
26- ResultsUtil::setupTreeView (ui->topDownTreeView , contextMenu, ui->topDownSearch , topDownCostModel);
27- ResultsUtil::setupCostDelegate (topDownCostModel, ui->topDownTreeView );
28- ResultsUtil::setupContextMenu (ui->topDownTreeView , contextMenu, topDownCostModel, filterStack, this );
29-
30- connect (parser, &PerfParser::topDownDataAvailable, this ,
31- [this , topDownCostModel](const Data::TopDownResults& data) {
32- topDownCostModel->setData (data);
33- ResultsUtil::hideEmptyColumns (data.inclusiveCosts , ui->topDownTreeView , TopDownModel::NUM_BASE_COLUMNS);
34-
35- ResultsUtil::hideEmptyColumns (data.selfCosts , ui->topDownTreeView ,
36- TopDownModel::NUM_BASE_COLUMNS + data.inclusiveCosts .numTypes ());
37- ResultsUtil::hideTracepointColumns (data.selfCosts , ui->topDownTreeView ,
38- TopDownModel::NUM_BASE_COLUMNS + data.inclusiveCosts .numTypes ());
39-
40- // hide self cost columns for sched:sched_switch and off-CPU
41- // quasi all rows will have a cost of 0%, and only the leaves will show
42- // a non-zero value that is equal to the inclusive cost then
43- const auto costs = data.inclusiveCosts .numTypes ();
44- const auto schedSwitchName = QLatin1String (" sched:sched_switch" );
45- const auto offCpuName = PerfParser::tr (" off-CPU Time" );
46- for (int i = 0 ; i < costs; ++i) {
47- const auto typeName = data.inclusiveCosts .typeName (i);
48- if (typeName == schedSwitchName || typeName == offCpuName) {
49- ui->topDownTreeView ->hideColumn (topDownCostModel->selfCostColumn (i));
50- }
51- }
52- });
27+ ResultsUtil::setupTreeViewDiff (ui->topDownTreeView , contextMenu, ui->topDownSearch , m_model);
28+ ResultsUtil::setupCostDelegate (m_model, ui->topDownTreeView );
29+ ResultsUtil::setupContextMenu (ui->topDownTreeView , contextMenu, m_model, filterStack, this );
30+
31+ if (parser)
32+ connect (parser, &PerfParser::topDownDataAvailable, this , &ResultsTopDownPage::setTopDownResults);
5333
5434 ResultsUtil::setupResultsAggregation (ui->costAggregationComboBox );
5535}
@@ -60,3 +40,28 @@ void ResultsTopDownPage::clear()
6040{
6141 ui->topDownSearch ->setText ({});
6242}
43+
44+ void ResultsTopDownPage::setTopDownResults (const Data::TopDownResults& data)
45+ {
46+ m_model->setData (data);
47+ ResultsUtil::hideEmptyColumns (data.inclusiveCosts , ui->topDownTreeView , TopDownModel::NUM_BASE_COLUMNS);
48+
49+ ResultsUtil::hideEmptyColumns (data.selfCosts , ui->topDownTreeView ,
50+ TopDownModel::NUM_BASE_COLUMNS + data.inclusiveCosts .numTypes ());
51+ ResultsUtil::hideTracepointColumns (data.selfCosts , ui->topDownTreeView ,
52+ TopDownModel::NUM_BASE_COLUMNS + data.inclusiveCosts .numTypes ());
53+
54+ // hide self cost columns for sched:sched_switch and off-CPU
55+ // quasi all rows will have a cost of 0%, and only the leaves will show
56+ // a non-zero value that is equal to the inclusive cost then
57+ const auto costs = data.inclusiveCosts .numTypes ();
58+ const auto schedSwitchName = QLatin1String (" sched:sched_switch" );
59+ const auto offCpuName = PerfParser::tr (" off-CPU Time" );
60+ for (int i = 0 ; i < costs; ++i) {
61+ const auto typeName = data.inclusiveCosts .typeName (i);
62+ // use contains to also work in diff view
63+ if (typeName.contains (schedSwitchName) || typeName.contains (offCpuName)) {
64+ ui->topDownTreeView ->hideColumn (m_model->selfCostColumn (i));
65+ }
66+ }
67+ }
0 commit comments