summaryrefslogtreecommitdiffstats
path: root/stats/statsview.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-13 15:17:54 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-01-20 08:47:18 +0100
commit785d5189f617bab7d5dde668563fc4889e46f695 (patch)
tree67a3d41998725d77aadc98c1d57de4a0c7f459d8 /stats/statsview.h
parentd7878dad36e176ef0e2e1c54db891e115d29b489 (diff)
downloadsubsurface-785d5189f617bab7d5dde668563fc4889e46f695.tar.gz
statistics: turn infobox into a QSGNode
A small step in converting from QGraphicsScene to QQuickItem. This is the second item to be converted (after the legend) and for now items are drawn in order of creation, which means that the infobox is on top of the legend. This will have to be made deterministic in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/statsview.h')
-rw-r--r--stats/statsview.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/stats/statsview.h b/stats/statsview.h
index 8270c237f..62fb246cd 100644
--- a/stats/statsview.h
+++ b/stats/statsview.h
@@ -52,6 +52,9 @@ public:
QSizeF size() const;
void addQSGNode(QSGNode *node, int z); // Must only be called in render thread!
void unregisterChartItem(const ChartItem *item);
+ template <typename T, class... Args>
+ std::unique_ptr<T> createChartItem(Args&&... args);
+
private slots:
void replotIfVisible();
private:
@@ -109,9 +112,6 @@ private:
template <typename T, class... Args>
T *createAxis(const QString &title, Args&&... args);
- template <typename T, class... Args>
- std::unique_ptr<T> createChartItem(Args&&... args);
-
template<typename T>
CategoryAxis *createCategoryAxis(const QString &title, const StatsBinner &binner,
const std::vector<T> &bins, bool isHorizontal);
@@ -179,4 +179,14 @@ private:
QSGImageNode *rootNode;
};
+// This implementation detail must be known to users of the class.
+// Perhaps move it into a statsview_impl.h file.
+template <typename T, class... Args>
+std::unique_ptr<T> StatsView::createChartItem(Args&&... args)
+{
+ std::unique_ptr<T> res(new T(*this, std::forward<Args>(args)...));
+ items.push_back(res.get());
+ return res;
+}
+
#endif