diff options
Diffstat (limited to 'stats/statshelper.h')
-rw-r--r-- | stats/statshelper.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/stats/statshelper.h b/stats/statshelper.h new file mode 100644 index 000000000..0ea39763d --- /dev/null +++ b/stats/statshelper.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +// Helper functions to render the stats. Currently only +// contains a small template to create scene-items. This +// is for historical reasons to ease transition from QtCharts +// and might be removed. +#ifndef STATSHELPER_H + +#include <memory> +#include <QGraphicsScene> + +template <typename T, class... Args> +T *createItem(QGraphicsScene *scene, Args&&... args) +{ + T *res = new T(std::forward<Args>(args)...); + scene->addItem(res); + return res; +} + +template <typename T, class... Args> +std::unique_ptr<T> createItemPtr(QGraphicsScene *scene, Args&&... args) +{ + return std::unique_ptr<T>(createItem<T>(scene, std::forward<Args>(args)...)); +} + +#endif |