##// END OF EJS Templates
Use light outline color instead of dark for bar, area and scatter
Use light outline color instead of dark for bar, area and scatter

File last commit:

r638:61d3ed85e2c1
r653:f4e416c6727f
Show More
qpieseries.cpp
604 lines | 15.8 KiB | text/x-c | CppLexer
Jani Honkonen
Pie chart refactoring
r142 #include "qpieseries.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
Pie chart refactoring
r142 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Jani Honkonen
More documentation for pie
r320 /*!
\class QPieSeries
\brief Pie series API for QtCommercial Charts
The pie series defines a pie chart which consists of pie slices which are QPieSlice objects.
The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices.
Jani Honkonen
Review corrections for pie
r386 The actual slice size is determined by that relative value.
Jani Honkonen
More documentation for pie
r320
Jani Honkonen
Review corrections for pie
r386 By default the pie is defined as a full pie but it can be a partial pie.
Jani Honkonen
More documentation for pie
r320 This can be done by setting a starting angle and angle span to the series.
*/
Jani Honkonen
Add documentation to pie
r314 /*!
Constructs a series object which is a child of \a parent.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 QPieSeries::QPieSeries(QObject *parent) :
Michal Klocek
Rename QChartSeries to QSeries
r360 QSeries(parent),
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 m_pieRelativeHorPos(0.5),
m_pieRelativeVerPos(0.5),
m_pieRelativeSize(0.7),
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 m_pieStartAngle(0),
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 m_pieEndAngle(360),
m_total(0)
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 {
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
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
Add documentation to pie
r314 /*!
Destroys the object. Note that adding series to QChart transfers the ownership to the chart.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 QPieSeries::~QPieSeries()
{
Jani Honkonen
Fix a major memory leak
r204
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
More documentation for pie
r320 Returns QChartSeries::SeriesTypePie.
Jani Honkonen
Add documentation to pie
r314 */
Michal Klocek
Rename QChartSeries to QSeries
r360 QSeries::QSeriesType QPieSeries::type() const
Jani Honkonen
Add documentation to pie
r314 {
Michal Klocek
Rename QChartSeries to QSeries
r360 return QSeries::SeriesTypePie;
Jani Honkonen
Add documentation to pie
r314 }
/*!
Jani Honkonen
QPieSeries::set() -> replace()
r354 Sets an array of \a slices to the series replacing the existing slices.
Jani Honkonen
Add documentation to pie
r314 Slice ownership is passed to the series.
*/
Jani Honkonen
QPieSeries::set() -> replace()
r354 void QPieSeries::replace(QList<QPieSlice*> slices)
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 clear();
add(slices);
}
Jani Honkonen
Make pie work better with chartwidgettest
r163
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
Update pie doc
r345 Adds an array of \a slices to the series.
Jani Honkonen
Add documentation to pie
r314 Slice ownership is passed to the series.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::add(QList<QPieSlice*> slices)
{
foreach (QPieSlice* s, slices) {
s->setParent(this);
m_slices << s;
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
Jani Honkonen
Refactoring piechart API (and internals)
r174 updateDerivativeData();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 foreach (QPieSlice* s, slices) {
connect(s, SIGNAL(changed()), this, SLOT(sliceChanged()));
connect(s, SIGNAL(clicked()), this, SLOT(sliceClicked()));
connect(s, SIGNAL(hoverEnter()), this, SLOT(sliceHoverEnter()));
connect(s, SIGNAL(hoverLeave()), this, SLOT(sliceHoverLeave()));
}
Jani Honkonen
Refactoring pie series and animations.
r621 emit added(slices);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add documentation to pie
r314 /*!
Adds a single \a slice to the series.
Slice ownership is passed to the series.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::add(QPieSlice* slice)
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 add(QList<QPieSlice*>() << slice);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Update pie series doc
r415 /*!
Adds a single \a slice to the series and returns a reference to the series.
Slice ownership is passed to the series.
*/
Jani Honkonen
Add drilldown example for piechart
r406 QPieSeries& QPieSeries::operator << (QPieSlice* slice)
{
add(slice);
return *this;
}
Jani Honkonen
Add documentation to pie
r314
/*!
Adds a single slice to the series with give \a value and \a name.
Slice ownership is passed to the series.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 QPieSlice* QPieSeries::add(qreal value, QString name)
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 QPieSlice* slice = new QPieSlice(value, name);
add(slice);
return slice;
}
Jani Honkonen
Refactoring piechart API (and internals)
r174
Marek Rosa
Added insert pie slice function to QPieSeries
r604 void QPieSeries::insert(int i, QPieSlice* slice)
{
Q_ASSERT(i <= m_slices.count());
slice->setParent(this);
m_slices.insert(i, slice);
updateDerivativeData();
connect(slice, SIGNAL(changed()), this, SLOT(sliceChanged()));
connect(slice, SIGNAL(clicked()), this, SLOT(sliceClicked()));
connect(slice, SIGNAL(hoverEnter()), this, SLOT(sliceHoverEnter()));
connect(slice, SIGNAL(hoverLeave()), this, SLOT(sliceHoverLeave()));
Jani Honkonen
Refactoring pie series and animations.
r621 emit added(QList<QPieSlice*>() << slice);
Marek Rosa
Added insert pie slice function to QPieSeries
r604 }
Jani Honkonen
Add documentation to pie
r314 /*!
Removes a single \a slice from the series and deletes the slice.
Jani Honkonen
More documentation for pie
r320
Jani Honkonen
Add documentation to pie
r314 Do not reference this pointer after this call.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::remove(QPieSlice* slice)
{
if (!m_slices.removeOne(slice)) {
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 should this be reported?
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 return;
}
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 updateDerivativeData();
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Refactoring pie series and animations.
r621 emit removed(QList<QPieSlice*>() << slice);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 delete slice;
slice = NULL;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add documentation to pie
r314 /*!
Clears all slices from the series.
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::clear()
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.count() == 0)
return;
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Refactoring pie series and animations.
r621 QList<QPieSlice*> slices = m_slices;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 foreach (QPieSlice* s, m_slices) {
m_slices.removeOne(s);
delete s;
}
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 updateDerivativeData();
Jani Honkonen
Refactoring pie series and animations.
r621
emit removed(slices);
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add documentation to pie
r314 /*!
Counts the number of the slices in this series.
*/
int QPieSeries::count() const
{
return m_slices.count();
}
Jani Honkonen
Refactoring pie series and animations.
r621 /*!
Returns true is the series is empty.
*/
bool QPieSeries::isEmpty() const
{
return m_slices.isEmpty();
}
Jani Honkonen
Add documentation to pie
r314 /*!
Returns a list of slices that belong to this series.
*/
QList<QPieSlice*> QPieSeries::slices() const
{
return m_slices;
}
/*!
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 Sets the center position of the pie by \a relativeHorizontalPosition and \a relativeVerticalPosition.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
The factors are relative to the chart rectangle where:
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \a relativeHorizontalPosition 0.0 means the absolute left.
\a relativeHorizontalPosition 1.0 means the absolute right.
\a relativeVerticalPosition 0.0 means the absolute top.
\a relativeVerticalPosition 1.0 means the absolute bottom.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 By default both values are 0.5 which puts the pie in the middle of the chart rectangle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa pieHorizontalPosition(), pieVerticalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 void QPieSeries::setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (relativeHorizontalPosition < 0.0 || relativeHorizontalPosition > 1.0 ||
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 relativeVerticalPosition < 0.0 || relativeVerticalPosition > 1.0)
Jani Honkonen
Make pie work better with chartwidgettest
r163 return;
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (m_pieRelativeHorPos != relativeHorizontalPosition || m_pieRelativeVerPos != relativeVerticalPosition) {
m_pieRelativeHorPos = relativeHorizontalPosition;
m_pieRelativeVerPos = relativeVerticalPosition;
Jani Honkonen
Refactoring pie series and animations.
r621 emit piePositionChanged();
Jani Honkonen
Make pie work better with chartwidgettest
r163 }
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 Gets the horizontal position of the pie.
Jani Honkonen
Add documentation to pie
r314
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 The returned value is relative to the chart rectangle where:
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 0.0 means the absolute left.
1.0 means the absolute right.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 By default it is 0.5 which puts the pie in the horizontal middle of the chart rectangle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa setPiePosition(), pieVerticalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 qreal QPieSeries::pieHorizontalPosition() const
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 return m_pieRelativeHorPos;
Jani Honkonen
Pie chart refactoring
r142 }
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 Gets the vertical position position of the pie.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 The returned value is relative to the chart rectangle where:
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 0.0 means the absolute top.
1.0 means the absolute bottom.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 By default it is 0.5 which puts the pie in the vertical middle of the chart rectangle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa setPiePosition(), pieHorizontalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 qreal QPieSeries::pieVerticalPosition() const
Jani Honkonen
Add documentation to pie
r314 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 return m_pieRelativeVerPos;
Jani Honkonen
Add documentation to pie
r314 }
/*!
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 Sets the relative size of the pie.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 The \a relativeSize is defined so that the 1.0 is the maximum that can fit the given chart rectangle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Default value is 0.7.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa pieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition()
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 void QPieSeries::setPieSize(qreal relativeSize)
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (relativeSize < 0.0 || relativeSize > 1.0)
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 return;
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (m_pieRelativeSize != relativeSize) {
m_pieRelativeSize = relativeSize;
Jani Honkonen
Refactoring pie series and animations.
r621 emit pieSizeChanged();
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 }
}
Jani Honkonen
Add documentation to pie
r314
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 /*!
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 Gets the relative size of the pie.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 The size is defined so that the 1.0 is the maximum that can fit the given chart rectangle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Default value is 0.7.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa setPieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition()
Jani Honkonen
Add documentation to pie
r314 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 qreal QPieSeries::pieSize() const
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 return m_pieRelativeSize;
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 /*!
Sets the end angle of the pie.
Full pie is 360 degrees where 0 degrees is at 12 a'clock.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \a angle must be less than pie end angle. Default value is 0.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa pieStartAngle(), pieEndAngle(), setPieEndAngle()
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 void QPieSeries::setPieStartAngle(qreal angle)
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (angle >= 0 && angle <= 360 && angle != m_pieStartAngle && angle <= m_pieEndAngle) {
m_pieStartAngle = angle;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 updateDerivativeData();
}
}
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 /*!
Gets the start angle of the pie.
Full pie is 360 degrees where 0 degrees is at 12 a'clock. Default value is 360.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa setPieStartAngle(), pieEndAngle(), setPieEndAngle()
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 qreal QPieSeries::pieStartAngle() const
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 {
return m_pieStartAngle;
}
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 /*!
Sets the end angle of the pie.
Full pie is 360 degrees where 0 degrees is at 12 a'clock.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \a angle must be greater than start angle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa pieEndAngle(), pieStartAngle(), setPieStartAngle()
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 void QPieSeries::setPieEndAngle(qreal angle)
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 {
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 if (angle >= 0 && angle <= 360 && angle != m_pieEndAngle && angle >= m_pieStartAngle) {
m_pieEndAngle = angle;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 updateDerivativeData();
}
}
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 /*!
Returns the end angle of the pie.
Full pie is 360 degrees where 0 degrees is at 12 a'clock.
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle()
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454 */
Jani Honkonen
Renamed the "factor" stuff from pie series API.
r498 qreal QPieSeries::pieEndAngle() const
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 {
return m_pieEndAngle;
}
Jani Honkonen
Add documentation to pie
r314 /*!
Sets the all the slice labels \a visible or invisible.
\sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible()
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::setLabelsVisible(bool visible)
{
foreach (QPieSlice* s, m_slices)
s->setLabelVisible(visible);
}
Jani Honkonen
Add drilldown example for piechart
r406 /*!
Returns the sum of all slice values in this series.
\sa QPieSlice::value(), QPieSlice::setValue()
*/
qreal QPieSeries::total() const
{
return m_total;
}
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566 \fn void QPieSeries::changed()
Jani Honkonen
Add documentation to pie
r314
This signal emitted when something has changed in the series.
\sa QPieSeries::ChangeSet, QPieSlice::changed()
*/
/*!
\fn void QPieSeries::clicked(QPieSlice* slice)
This signal is emitted when a \a slice has been clicked.
\sa QPieSlice::clicked()
*/
/*!
\fn void QPieSeries::hoverEnter(QPieSlice* slice)
This signal is emitted when user has hovered over a \a slice.
\sa QPieSlice::hoverEnter()
*/
/*!
\fn void QPieSeries::hoverLeave(QPieSlice* slice)
This signal is emitted when user has hovered away from a \a slice.
\sa QPieSlice::hoverLeave()
*/
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 void QPieSeries::sliceChanged()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
updateDerivativeData();
}
void QPieSeries::sliceClicked()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
emit clicked(slice);
}
void QPieSeries::sliceHoverEnter()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
emit hoverEnter(slice);
}
void QPieSeries::sliceHoverLeave()
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 QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
emit hoverLeave(slice);
}
Jani Honkonen
Refactoring piechart API (and internals)
r174 void QPieSeries::updateDerivativeData()
{
m_total = 0;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 // nothing to do?
if (m_slices.count() == 0)
return;
// calculate total
foreach (QPieSlice* s, m_slices)
m_total += s->value();
Jani Honkonen
Refactoring pie series and animations.
r621 // nothing to show..
if (m_total == 0)
return;
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 // update slice attributes
qreal sliceAngle = m_pieStartAngle;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 qreal pieSpan = m_pieEndAngle - m_pieStartAngle;
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 QVector<QPieSlice*> changed;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 foreach (QPieSlice* s, m_slices) {
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 bool isChanged = false;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203
qreal percentage = s->value() / m_total;
if (s->m_percentage != percentage) {
s->m_percentage = percentage;
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 isChanged = true;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 qreal sliceSpan = pieSpan * percentage;
Jani Honkonen
Make pie fit better inside its given rectangle. Label texts still go outside. Needs a bit more work...
r289 if (s->m_angleSpan != sliceSpan) {
s->m_angleSpan = sliceSpan;
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 isChanged = true;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
QPieSlice: angle() -> startAngle(), angleSpan() -> endAngle()
r355 if (s->m_startAngle != sliceAngle) {
s->m_startAngle = sliceAngle;
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 isChanged = true;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
sliceAngle += sliceSpan;
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 if (isChanged)
changed << s;
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618
Jani Honkonen
Refactoring pie series and animations.
r621 // emit signals
Jani Honkonen
Add animations to pie. Works but has some visual issues when adding slices.
r618 foreach (QPieSlice* s, changed)
emit s->changed();
Jani Honkonen
Refactoring piechart API (and internals)
r174 }
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 bool QPieSeries::setModel(QAbstractItemModel* model)
{
// disconnect signals from old model
if(m_model)
{
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 disconnect(m_model, 0, this, 0);
m_mapValues = -1;
m_mapLabels = -1;
m_mapOrientation = Qt::Vertical;
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // set new model
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 if(model)
{
m_model = model;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 return true;
}
else
{
m_model = NULL;
return false;
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
}
void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation)
{
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 if (m_model == NULL)
return;
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 m_mapValues = modelValuesLine;
m_mapLabels = modelLabelsLine;
m_mapOrientation = orientation;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // connect the signals
if (m_mapOrientation == Qt::Vertical)
{
connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
}
else
{
connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
}
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // create the initial slices set
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 if (m_mapOrientation == Qt::Vertical)
for (int i = 0; i < m_model->rowCount(); i++)
add(m_model->data(m_model->index(i, m_mapValues), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(i, m_mapLabels), Qt::DisplayRole).toString());
else
for (int i = 0; i < m_model->columnCount(); i++)
add(m_model->data(m_model->index(m_mapValues, i), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(m_mapLabels, i), Qt::DisplayRole).toString());
}
void QPieSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(bottomRight)
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 if (m_mapOrientation == Qt::Vertical)
Marek Rosa
Added insert pie slice function to QPieSeries
r604 {
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 // slices().at(topLeft.row())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble());
if (topLeft.column() == m_mapValues)
Marek Rosa
QPieSeries: label value is now also updated when the same row/column of the model is mapped for values and labels
r638 if (m_mapValues == m_mapLabels)
{
slices().at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble());
slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
}
else
{
slices().at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble());
}
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 else if (topLeft.column() == m_mapLabels)
slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
Marek Rosa
Added insert pie slice function to QPieSeries
r604 }
else
{
// slices().at(topLeft.column())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble());
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 if (topLeft.row() == m_mapValues)
Marek Rosa
QPieSeries: label value is now also updated when the same row/column of the model is mapped for values and labels
r638 if (m_mapValues == m_mapLabels)
{
slices().at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble());
slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
}
else
{
slices().at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble());
}
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 else if (topLeft.row() == m_mapLabels)
Marek Rosa
Added insert pie slice function to QPieSeries
r604 slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
}
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
void QPieSeries::modelDataAdded(QModelIndex parent, int start, int end)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(parent)
Q_UNUSED(end)
Marek Rosa
Added insert pie slice function to QPieSeries
r604 QPieSlice* newSlice = new QPieSlice;
newSlice->setLabelVisible(true);
if (m_mapOrientation == Qt::Vertical)
{
newSlice->setValue(m_model->data(m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble());
newSlice->setLabel(m_model->data(m_model->index(start, m_mapLabels), Qt::DisplayRole).toString());
}
else
{
newSlice->setValue(m_model->data(m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble());
newSlice->setLabel(m_model->data(m_model->index(m_mapLabels, start), Qt::DisplayRole).toString());
}
insert(start, newSlice);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
void QPieSeries::modelDataRemoved(QModelIndex parent, int start, int end)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(parent)
Q_UNUSED(end)
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 remove(slices().at(start));
}
Jani Honkonen
Pie chart refactoring
r142 #include "moc_qpieseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE