From 01accbfa3e478062aec5afd14a05c93e0c189510 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 18 Jan 2021 12:47:24 +0100 Subject: statistics: replace chart title by QSG node This one is trivial, since everything is there already: Replace the QGraphicsSimpleTextItem with a ChartTextItem. Only few functions have to be renamed. Signed-off-by: Berthold Stoeger --- stats/statsview.cpp | 11 +++++------ stats/statsview.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'stats') diff --git a/stats/statsview.cpp b/stats/statsview.cpp index 5acf3ecaf..efb530e45 100644 --- a/stats/statsview.cpp +++ b/stats/statsview.cpp @@ -211,7 +211,7 @@ void StatsView::plotAreaChanged(const QSizeF &s) const double minSize = 30.0; if (title) - top += title->boundingRect().height() + titleBorder; + top += title->getRect().height() + titleBorder; // Currently, we only have either none, or an x- and a y-axis std::pair horizontalSpace{ 0.0, 0.0 }; if (xAxis) { @@ -310,17 +310,16 @@ void StatsView::setTitle(const QString &s) title.reset(); return; } - title = createItemPtr(&scene, s); - title->setFont(titleFont); + title = createChartItem(ChartZValue::Legend, titleFont, s); + title->setColor(darkLabelColor); } void StatsView::updateTitlePos() { if (!title) return; - QRectF rect = scene.sceneRect(); - title->setPos(sceneBorder + (rect.width() - title->boundingRect().width()) / 2.0, - sceneBorder); + title->setPos(QPointF(round(sceneBorder + (boundingRect().width() - title->getRect().width()) / 2.0), + round(sceneBorder))); } template diff --git a/stats/statsview.h b/stats/statsview.h index 05893ad33..1736af219 100644 --- a/stats/statsview.h +++ b/stats/statsview.h @@ -16,10 +16,10 @@ struct StatsBin; struct StatsState; struct StatsVariable; -class QGraphicsSimpleTextItem; class StatsSeries; class CategoryAxis; class ChartItem; +class ChartTextItem; class CountAxis; class HistogramAxis; class HistogramMarker; @@ -130,7 +130,7 @@ private: std::unique_ptr legend; std::vector> quartileMarkers; std::vector> histogramMarkers; - std::unique_ptr title; + std::unique_ptr title; std::unique_ptr regressionItem; StatsSeries *highlightedSeries; StatsAxis *xAxis, *yAxis; -- cgit v1.2.3-70-g09d2