##// END OF EJS Templates
integrating bar charts to test app.. crashes for now
integrating bar charts to test app.. crashes for now

File last commit:

r163:daab1c215b03
r164:8e580b305fe6
Show More
qpieseries.cpp
109 lines | 2.1 KiB | text/x-c | CppLexer
Jani Honkonen
Pie chart refactoring
r142 #include "qpieseries.h"
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 #include "piepresenter.h"
Jani Honkonen
Pie chart refactoring
r142 #include "pieslice.h"
#include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
QPieSeries::QPieSeries(QObject *parent) :
QChartSeries(parent),
m_sizeFactor(1.0),
m_position(PiePositionMaximized)
{
}
QPieSeries::~QPieSeries()
{
}
Jani Honkonen
Make pie work better with chartwidgettest
r163 bool QPieSeries::setData(QList<qreal> data)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Make pie work better with chartwidgettest
r163 QList<QPieSlice> slices;
foreach (int value, data)
slices << QPieSlice(value, QString::number(value));
return set(slices);
}
bool QPieSeries::set(QList<QPieSlice> slices)
{
if (!slices.count())
return false;
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 PieChangeSet changeSet;
for (int i=slices.count(); i<m_slices.count(); i++)
changeSet.m_removed << i;
for (int i=0; i<slices.count(); i++) {
if (i < m_slices.count())
changeSet.m_changed << i;
else
changeSet.m_added << i;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
m_slices = slices;
emit changed(changeSet);
Jani Honkonen
Make pie work better with chartwidgettest
r163 return true;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Make pie work better with chartwidgettest
r163 bool QPieSeries::add(QList<QPieSlice> slices)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Make pie work better with chartwidgettest
r163 if (!slices.count())
return false;
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 PieChangeSet changeSet;
for (int i=0; i<slices.count(); i++)
changeSet.m_added << m_slices.count() + i;
Jani Honkonen
Pie chart refactoring
r142 m_slices += slices;
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 emit changed(changeSet);
Jani Honkonen
Make pie work better with chartwidgettest
r163 return true;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Make pie work better with chartwidgettest
r163 bool QPieSeries::add(QPieSlice slice)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Make pie work better with chartwidgettest
r163 return add(QList<QPieSlice>() << slice);
Jani Honkonen
Pie chart refactoring
r142 }
QPieSlice QPieSeries::slice(int index) const
{
if ((index >= 0) && (index < m_slices.count()))
return m_slices.at(index);
return QPieSlice();
}
bool QPieSeries::update(int index, QPieSlice slice)
{
if ((index >= 0) && (index < m_slices.count())) {
m_slices[index] = slice;
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 PieChangeSet changeSet;
changeSet.m_changed << index;
emit changed(changeSet);
Jani Honkonen
Pie chart refactoring
r142 return true;
}
return false;
}
void QPieSeries::setSizeFactor(qreal factor)
{
Jani Honkonen
Make pie work better with chartwidgettest
r163 if (factor < 0.0)
return;
if (m_sizeFactor != factor) {
Jani Honkonen
Pie chart refactoring
r142 m_sizeFactor = factor;
Jani Honkonen
Make pie work better with chartwidgettest
r163 emit sizeFactorChanged();
}
Jani Honkonen
Pie chart refactoring
r142 }
void QPieSeries::setPosition(PiePosition position)
{
Jani Honkonen
Make pie work better with chartwidgettest
r163 if (m_position != position) {
m_position = position;
emit positionChanged();
}
Jani Honkonen
Pie chart refactoring
r142 }
#include "moc_qpieseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE