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>
This commit is contained in:
Berthold Stoeger 2021-01-13 15:17:54 +01:00 committed by bstoeger
parent d7878dad36
commit 785d5189f6
8 changed files with 53 additions and 58 deletions

View file

@ -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