2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "piechart.h"
|
|
|
|
#include "pieslice.h"
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
PieChart::PieChart(QQuickItem *parent)
|
|
|
|
: QQuickItem(parent)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PieChart::name() const
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PieChart::setName(const QString &name)
|
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
}
|
|
|
|
|
2012-03-05 01:39:24 +00:00
|
|
|
QQmlListProperty<PieSlice> PieChart::slices()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2019-11-25 15:10:04 +00:00
|
|
|
return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr,
|
|
|
|
nullptr, nullptr, nullptr, nullptr);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 01:39:24 +00:00
|
|
|
void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
PieChart *chart = qobject_cast<PieChart *>(list->object);
|
|
|
|
if (chart) {
|
|
|
|
slice->setParentItem(chart);
|
|
|
|
chart->m_slices.append(slice);
|
|
|
|
}
|
|
|
|
}
|