summaryrefslogtreecommitdiffstats
path: root/stats/statshelper.h
blob: 0ea39763d8c6e01f181dbc7b661b470bb4524c9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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