ChartWidget::~ChartWidget() = default;
-void ChartWidget::setModel(ChartModel* model)
+void ChartWidget::setModel(ChartModel* model, bool minimalMode)
{
auto* coordinatePlane = dynamic_cast<CartesianCoordinatePlane*>(m_chart->coordinatePlane());
Q_ASSERT(coordinatePlane);
delete diagram;
}
+ if (minimalMode) {
+ KChart::GridAttributes grid;
+ grid.setSubGridVisible(false);
+ coordinatePlane->setGlobalGridAttributes(grid);
+ }
+
+ switch (model->type()) {
+ case ChartModel::Consumed:
+ setToolTip(i18n("<qt>Shows the heap memory consumption over time.</qt>"));
+ break;
+ case ChartModel::Allocated:
+ setToolTip(i18n("<qt>Displays total memory allocated over time. "
+ "This value ignores deallocations and just measures heap allocation throughput.</qt>"));
+ break;
+ case ChartModel::Allocations:
+ setToolTip(i18n("<qt>Shows number of memory allocations over time.</qt>"));
+ break;
+ case ChartModel::Temporary:
+ setToolTip(i18n("<qt>Shows number of temporary memory allocations over time. "
+ "A temporary allocation is one that is followed immediately by its "
+ "corresponding deallocation, without other allocations happening in-between.</qt>"));
+ break;
+ }
+
{
auto totalPlotter = new Plotter(this);
totalPlotter->setAntiAliasing(true);
bottomAxis->setTextAttributes(axisTextAttributes);
auto axisTitleTextAttributes = bottomAxis->titleTextAttributes();
axisTitleTextAttributes.setPen(foreground);
+ auto fontSize = axisTitleTextAttributes.fontSize();
+ fontSize.setCalculationMode(KChartEnums::MeasureCalculationModeAbsolute);
+ if (minimalMode) {
+ fontSize.setValue(font().pointSizeF() - 2);
+ } else {
+ fontSize.setValue(font().pointSizeF() + 2);
+ }
+ axisTitleTextAttributes.setFontSize(fontSize);
bottomAxis->setTitleTextAttributes(axisTitleTextAttributes);
bottomAxis->setTitleText(model->headerData(0).toString());
bottomAxis->setPosition(CartesianAxis::Bottom);
plotter->setModel(proxy);
coordinatePlane->addDiagram(plotter);
}
+}
+QSize ChartWidget::sizeHint() const
+{
+ return {400, 50};
}
#include "chartwidget.moc"
explicit ChartWidget(QWidget* parent = nullptr);
virtual ~ChartWidget();
- void setModel(ChartModel* model);
+ void setModel(ChartModel* model, bool minimalMode = false);
+
+ QSize sizeHint() const override;
private:
KChart::Chart* m_chart;
auto consumedModel = new ChartModel(ChartModel::Consumed, this);
m_ui->consumedTab->setModel(consumedModel);
+ m_ui->consumedGraph->setModel(consumedModel, true);
auto allocationsModel = new ChartModel(ChartModel::Allocations, this);
m_ui->allocationsTab->setModel(allocationsModel);
+ m_ui->allocationsGraph->setModel(allocationsModel, true);
auto allocatedModel = new ChartModel(ChartModel::Allocated, this);
m_ui->allocatedTab->setModel(allocatedModel);
auto temporaryModel = new ChartModel(ChartModel::Temporary, this);
m_ui->temporaryTab->setModel(temporaryModel);
+ m_ui->temporaryGraph->setModel(temporaryModel, true);
auto sizeHistogramModel = new HistogramModel(this);
m_ui->sizesTab->setModel(sizeHistogramModel);
this, [=] (const ChartData& data) {
consumedModel->resetData(data);
m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->consumedTab), true);
+ m_ui->graphDock->setVisible(true);
+ m_ui->consumedGraph->setVisible(true);
});
connect(m_parser, &Parser::allocatedChartDataAvailable,
this, [=] (const ChartData& data) {
this, [=] (const ChartData& data) {
allocationsModel->resetData(data);
m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->allocationsTab), true);
+ m_ui->graphDock->setVisible(true);
+ m_ui->allocationsGraph->setVisible(true);
});
connect(m_parser, &Parser::temporaryChartDataAvailable,
this, [=] (const ChartData& data) {
temporaryModel->resetData(data);
m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->temporaryTab), true);
+ m_ui->graphDock->setVisible(true);
+ m_ui->temporaryGraph->setVisible(true);
});
connect(m_parser, &Parser::sizeHistogramDataAvailable,
this, [=] (const HistogramData& data) {
this, [tabChanged] () { tabChanged(0); });
m_ui->stacksDock->setVisible(false);
- m_ui->stacksDock->setFeatures(QDockWidget::DockWidgetMovable);
+ m_ui->graphDock->setVisible(false);
+ m_ui->consumedGraph->setVisible(false);
+ m_ui->allocationsGraph->setVisible(false);
+ m_ui->temporaryGraph->setVisible(false);
}
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_6">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
<item>
<widget class="KMessageWidget" name="messages">
<property name="messageType">
</widget>
<widget class="QWidget" name="resultsPage">
<layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
</layout>
</widget>
<widget class="QDockWidget" name="stacksDock">
+ <property name="features">
+ <set>QDockWidget::NoDockWidgetFeatures</set>
+ </property>
<property name="windowTitle">
<string>S&tacks</string>
</property>
</layout>
</widget>
</widget>
+ <widget class="QDockWidget" name="graphDock">
+ <property name="toolTip">
+ <string>Shows the heap memory consumption over time.</string>
+ </property>
+ <property name="features">
+ <set>QDockWidget::AllDockWidgetFeatures</set>
+ </property>
+ <property name="windowTitle">
+ <string>&Graphs</string>
+ </property>
+ <attribute name="dockWidgetArea">
+ <number>8</number>
+ </attribute>
+ <widget class="QWidget" name="graphs">
+ <layout class="QVBoxLayout" name="verticalLayout_14">
+ <item>
+ <widget class="ChartWidget" name="consumedGraph" native="true"/>
+ </item>
+ <item>
+ <widget class="ChartWidget" name="allocationsGraph" native="true"/>
+ </item>
+ <item>
+ <widget class="ChartWidget" name="temporaryGraph" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
</widget>
<customwidgets>
<customwidget>