##// END OF EJS Templates
compile fix.
compile fix.

File last commit:

r454:06980850b7dd
r489:5265eca1c291
Show More
piepresenter.cpp
154 lines | 4.2 KiB | text/x-c | CppLexer
Jani Honkonen
Add _p to pie internal headers
r353 #include "piepresenter_p.h"
#include "pieslice_p.h"
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 #include "qpieslice.h"
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 #include "qpieseries.h"
Jani Honkonen
Pie chart refactoring
r142 #include <QDebug>
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 #include <QPainter>
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Jani Honkonen
Refactoring piechart API (and internals)
r174 PiePresenter::PiePresenter(QGraphicsItem *parent, QPieSeries *series)
:ChartItem(parent),
m_series(series)
Jani Honkonen
Pie chart refactoring
r142 {
Q_ASSERT(series);
Jani Honkonen
Refactoring piechart API (and internals)
r174 connect(series, SIGNAL(changed(const QPieSeries::ChangeSet&)), this, SLOT(handleSeriesChanged(const QPieSeries::ChangeSet&)));
Jani Honkonen
Make pie work better with chartwidgettest
r163 connect(series, SIGNAL(sizeFactorChanged()), this, SLOT(updateGeometry()));
connect(series, SIGNAL(positionChanged()), this, SLOT(updateGeometry()));
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
if (m_series->count()) {
QPieSeries::ChangeSet changeSet;
changeSet.appendAdded(m_series->m_slices);
handleSeriesChanged(changeSet);
}
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 PiePresenter::~PiePresenter()
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Refactoring piechart API (and internals)
r174 // slices deleted automatically through QGraphicsItem
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 void PiePresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Refactoring piechart API (and internals)
r174 // TODO: paint shadows for all components
// - get paths from items & merge & offset and draw with shadow color?
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 //painter->setBrush(QBrush(Qt::red));
//painter->drawRect(m_debugRect);
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
void PiePresenter::handleSeriesChanged(const QPieSeries::ChangeSet& changeSet)
{
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 //qDebug() << "PiePresenter::handleSeriesChanged()";
//qDebug() << " added : " << changeSet.added();
//qDebug() << " changed: " << changeSet.changed();
//qDebug() << " removed: " << changeSet.removed();
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 foreach (QPieSlice* s, changeSet.added())
addSlice(s);
foreach (QPieSlice* s, changeSet.changed())
updateSlice(s);
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 foreach (QPieSlice* s, changeSet.removed())
deleteSlice(s);
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 // every change possibly changes the actual pie size
updateGeometry();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void PiePresenter::handleDomainChanged(const Domain& domain)
{
// TODO
}
void PiePresenter::handleGeometryChanged(const QRectF& rect)
{
m_rect = rect;
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 prepareGeometryChange();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 updateGeometry();
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 void PiePresenter::updateGeometry()
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 if (!m_rect.isValid() || m_rect.isEmpty())
return;
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // find pie center coordinates
QPointF center;
center.setX(m_rect.left() + (m_rect.width() * m_series->m_hPositionFactor));
center.setY(m_rect.top() + (m_rect.height() * m_series->m_vPositionFactor));
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // find maximum radius for pie
qreal radius = m_rect.height() / 2;
if (m_rect.width() < m_rect.height())
radius = m_rect.width() / 2;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 // apply size factor
radius *= m_series->m_pieSizeFactor;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 // update slices
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 if (m_pieCenter != center || m_pieRadius != radius) {
m_pieCenter = center;
m_pieRadius = radius;
//qDebug() << "PiePresenter::updateGeometry()" << m_rect << m_pieCenter << m_pieRadius;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 foreach (PieSlice* s, m_slices.values()) {
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 s->setPieCenterAndRadius(center, radius);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 s->updateGeometry();
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 s->update();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437
update();
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void PiePresenter::addSlice(QPieSlice* sliceData)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 //qDebug() << "PiePresenter::addSlice()" << sliceData;
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 if (m_slices.keys().contains(sliceData)) {
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 Q_ASSERT(0); // TODO: how to handle this nicely?
Jani Honkonen
Refactoring piechart API (and internals)
r174 return;
}
// create slice
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 PieSlice *slice = new PieSlice(this);
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 slice->setPieCenterAndRadius(m_pieCenter, m_pieRadius);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 slice->updateData(sliceData);
Jani Honkonen
Fix issue with pie label not drawn correctly when first created
r209 slice->updateGeometry();
slice->update();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 m_slices.insert(sliceData, slice);
// connect signals
connect(slice, SIGNAL(clicked()), sliceData, SIGNAL(clicked()));
connect(slice, SIGNAL(hoverEnter()), sliceData, SIGNAL(hoverEnter()));
connect(slice, SIGNAL(hoverLeave()), sliceData, SIGNAL(hoverLeave()));
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 void PiePresenter::updateSlice(QPieSlice* sliceData)
{
//qDebug() << "PiePresenter::updateSlice()" << sliceData;
if (!m_slices.contains(sliceData)) {
Q_ASSERT(0); // TODO: how to handle this nicely?
return;
}
m_slices[sliceData]->updateData(sliceData);
}
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void PiePresenter::deleteSlice(QPieSlice* sliceData)
Jani Honkonen
Refactoring piechart API (and internals)
r174 {
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 //qDebug() << "PiePresenter::deleteSlice()" << sliceData;
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 if (!m_slices.contains(sliceData)) {
Q_ASSERT(0); // TODO: how to handle this nicely?
return;
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289
delete m_slices.take(sliceData);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add _p to pie internal headers
r353 #include "moc_piepresenter_p.cpp"
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_END_NAMESPACE