##// END OF EJS Templates
Add public function for axis hadnling to qchart
Add public function for axis hadnling to qchart

File last commit:

r146:6c3759bde1fd
r155:c19659d852a4
Show More
qpieseries.cpp
93 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),
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 m_piePresenter(0),
Jani Honkonen
Pie chart refactoring
r142 m_sizeFactor(1.0),
m_position(PiePositionMaximized)
{
}
QPieSeries::~QPieSeries()
{
}
void QPieSeries::set(QList<QPieSlice> slices)
{
m_slices = slices;
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 if (m_piePresenter) {
m_piePresenter->seriesChanged();
m_piePresenter->update();
Jani Honkonen
Pie chart refactoring
r142 }
}
void QPieSeries::add(QList<QPieSlice> slices)
{
m_slices += slices;
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 if (m_piePresenter) {
m_piePresenter->seriesChanged();
// TODO: m_piePresenter->seriesAppended()??
m_piePresenter->update();
Jani Honkonen
Pie chart refactoring
r142 }
}
void QPieSeries::add(QPieSlice slice)
{
add(QList<QPieSlice>() << slice);
}
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
Moved pie stuff to own .pri file and rename stuff
r146 if (m_piePresenter) {
m_piePresenter->seriesChanged();
Jani Honkonen
Pie chart refactoring
r142 // TODO: for a nice animation we need something like
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 // m_piePresenter->sliceChanged(index, oldslice, newslice)
m_piePresenter->update();
Jani Honkonen
Pie chart refactoring
r142 }
return true;
}
return false;
}
void QPieSeries::setSizeFactor(qreal factor)
{
if (factor > 0.0)
m_sizeFactor = factor;
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 if (m_piePresenter) {
m_piePresenter->resize();
m_piePresenter->update();
Jani Honkonen
Pie chart refactoring
r142 // TODO: do we have to update the parent item also?
// - potential issue: what if this function is called from the parent context?
}
}
void QPieSeries::setPosition(PiePosition position)
{
m_position = position;
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 if (m_piePresenter) {
m_piePresenter->resize();
m_piePresenter->update();
Jani Honkonen
Pie chart refactoring
r142 // TODO: do we have to update the parent item also?
// - potential issue: what if this function is called from the parent context?
}
}
#include "moc_qpieseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE