##// END OF EJS Templates
Removed unintentional .pro file messages
Removed unintentional .pro file messages

File last commit:

r928:93cb42d22fe1
r931:2621e0cb526a
Show More
qpieseries.cpp
751 lines | 19.7 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Jani Honkonen
Pie chart refactoring
r142 #include "qpieseries.h"
Jani Honkonen
Adding PIMPL to pie
r669 #include "qpieseriesprivate_p.h"
Jani Honkonen
Refactoring QPieSlice private implementation. Removes the useless QPieSlicePrivate layer and uses PieSliceData directly.
r818 #include "qpieslice.h"
#include "pieslicedata_p.h"
Marek Rosa
Fixed: QAbstractItemModel could be forward declaration
r862 #include <QAbstractItemModel>
Jani Honkonen
Pie chart refactoring
r142 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Jani Honkonen
Adding PIMPL to pie
r669 QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent)
:QObject(parent),
q_ptr(parent),
m_pieRelativeHorPos(0.5),
m_pieRelativeVerPos(0.5),
m_pieRelativeSize(0.7),
m_pieStartAngle(0),
m_pieEndAngle(360),
Jani Honkonen
Missing member initialization in QPieSeriesPrivate
r797 m_total(0),
m_mapValues(0),
m_mapLabels(0),
m_mapOrientation(Qt::Horizontal)
Jani Honkonen
Adding PIMPL to pie
r669 {
}
QPieSeriesPrivate::~QPieSeriesPrivate()
{
}
void QPieSeriesPrivate::updateDerivativeData()
{
m_total = 0;
// nothing to do?
if (m_slices.count() == 0)
return;
// calculate total
foreach (QPieSlice* s, m_slices)
m_total += s->value();
// nothing to show..
Jani Honkonen
Fix issues with comparing equality of floating values in pie
r765 if (qFuzzyIsNull(m_total))
Jani Honkonen
Adding PIMPL to pie
r669 return;
// update slice attributes
qreal sliceAngle = m_pieStartAngle;
qreal pieSpan = m_pieEndAngle - m_pieStartAngle;
QVector<QPieSlice*> changed;
foreach (QPieSlice* s, m_slices) {
Jani Honkonen
Polish QPieSlice API by removing the DataPtr stuff
r822 PieSliceData data = PieSliceData::data(s);
Jani Honkonen
Fix issues with comparing equality of floating values in pie
r765 data.m_percentage = s->value() / m_total;
data.m_angleSpan = pieSpan * data.m_percentage;
data.m_startAngle = sliceAngle;
sliceAngle += data.m_angleSpan;
Jani Honkonen
Adding PIMPL to pie
r669
Jani Honkonen
Polish QPieSlice API by removing the DataPtr stuff
r822 if (PieSliceData::data(s) != data) {
PieSliceData::data(s) = data;
Jani Honkonen
Adding PIMPL to pie
r669 changed << s;
Jani Honkonen
Fix issues with comparing equality of floating values in pie
r765 }
Jani Honkonen
Adding PIMPL to pie
r669 }
// emit signals
foreach (QPieSlice* s, changed)
Jani Honkonen
Polish QPieSlice API by removing the DataPtr stuff
r822 PieSliceData::data(s).emitChangedSignal(s);
Jani Honkonen
Adding PIMPL to pie
r669 }
void QPieSeriesPrivate::sliceChanged()
{
Michal Klocek
Release compilation fixes
r689 Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender())));
Jani Honkonen
Adding PIMPL to pie
r669 updateDerivativeData();
}
Jani Honkonen
Add mousebuttons to pie clicked signals
r707 void QPieSeriesPrivate::sliceClicked(Qt::MouseButtons buttons)
Jani Honkonen
Adding PIMPL to pie
r669 {
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
Q_Q(QPieSeries);
Jani Honkonen
Add mousebuttons to pie clicked signals
r707 emit q->clicked(slice, buttons);
Jani Honkonen
Adding PIMPL to pie
r669 }
void QPieSeriesPrivate::sliceHoverEnter()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
Q_Q(QPieSeries);
emit q->hoverEnter(slice);
}
void QPieSeriesPrivate::sliceHoverLeave()
{
QPieSlice* slice = qobject_cast<QPieSlice *>(sender());
Q_ASSERT(m_slices.contains(slice));
Q_Q(QPieSeries);
emit q->hoverLeave(slice);
}
void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
{
Q_UNUSED(bottomRight)
Q_Q(QPieSeries);
if (m_mapOrientation == Qt::Vertical)
{
if (topLeft.column() == m_mapValues)
if (m_mapValues == m_mapLabels)
{
m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble());
m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString());
}
else
{
m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble());
}
else if (topLeft.column() == m_mapLabels)
m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString());
}
else
{
if (topLeft.row() == m_mapValues)
if (m_mapValues == m_mapLabels)
{
m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble());
m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString());
}
else
{
m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble());
}
else if (topLeft.row() == m_mapLabels)
m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString());
}
}
void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end)
{
Q_UNUSED(parent)
Q_UNUSED(end)
Q_Q(QPieSeries);
QPieSlice* newSlice = new QPieSlice;
newSlice->setLabelVisible(true);
if (m_mapOrientation == Qt::Vertical)
{
newSlice->setValue(q->m_model->data(q->m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble());
newSlice->setLabel(q->m_model->data(q->m_model->index(start, m_mapLabels), Qt::DisplayRole).toString());
}
else
{
newSlice->setValue(q->m_model->data(q->m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble());
newSlice->setLabel(q->m_model->data(q->m_model->index(m_mapLabels, start), Qt::DisplayRole).toString());
}
q->insert(start, newSlice);
}
void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end)
{
Q_UNUSED(parent)
Q_UNUSED(end)
Q_Q(QPieSeries);
q->remove(m_slices.at(start));
}
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 bool QPieSeriesPrivate::setRealValue(qreal &value, qreal newValue, qreal max, qreal min)
{
// Remove rounding errors
qreal roundedValue = newValue;
if (qFuzzyIsNull(min) && qFuzzyIsNull(newValue))
roundedValue = 0.0;
else if (qFuzzyCompare(newValue, max))
roundedValue = max;
else if (qFuzzyCompare(newValue, min))
roundedValue = min;
// Check if the position is valid after removing the rounding errors
if (roundedValue < min || roundedValue > max) {
qWarning("QPieSeries: Illegal value");
return false;
}
if (!qFuzzyIsNull(value - roundedValue)) {
value = roundedValue;
return true;
}
// The change was so small it is considered a rounding error
return false;
}
Jani Honkonen
Adding PIMPL to pie
r669
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.
*/
Marek Rosa
Some more doc fixes and additions
r924 /*!
Jani Honkonen
fix QPieSeries property docs
r928 \property QPieSeries::horizontalPosition
\brief Pie horizontal position property
Marek Rosa
Some more doc fixes and additions
r924
Jani Honkonen
fix QPieSeries property docs
r928 By default horizontal position is 0.5 (center).
Marek Rosa
Some more doc fixes and additions
r924 */
Jani Honkonen
fix QPieSeries property docs
r928 /*!
\property QPieSeries::verticalPosition
\brief Pie vertical position property
By default vertical position is 0.5 (center)
*/
/*!
\property QPieSeries::size
\brief Pie size property
By default size is 0.7.
*/
/*!
\property QPieSeries::startAngle
\brief Pie start angle.
Starting angle of the pie. Default is 0.
*/
/*!
\property QPieSeries::endAngle
\brief Pie end angle.
Ending angle of the pie. Default is 360.
*/
Marek Rosa
Some more doc fixes and additions
r924
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
Adding PIMPL to pie
r669 d_ptr(new QPieSeriesPrivate(this))
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
Adding PIMPL to pie
r669 // NOTE: d_prt destroyed by QObject
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();
Jani Honkonen
rename functions add() -> append()
r796 append(slices);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
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
rename functions add() -> append()
r796 void QPieSeries::append(QList<QPieSlice*> slices)
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
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) {
s->setParent(this);
Jani Honkonen
Adding PIMPL to pie
r669 d->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
Adding PIMPL to pie
r669 d->updateDerivativeData();
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 foreach (QPieSlice* s, slices) {
Jani Honkonen
Adding PIMPL to pie
r669 connect(s, SIGNAL(changed()), d, SLOT(sliceChanged()));
Jani Honkonen
Add mousebuttons to pie clicked signals
r707 connect(s, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons)));
Jani Honkonen
Adding PIMPL to pie
r669 connect(s, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter()));
connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave()));
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
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
rename functions add() -> append()
r796 void QPieSeries::append(QPieSlice* slice)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
rename functions add() -> append()
r796 append(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)
{
Jani Honkonen
rename functions add() -> append()
r796 append(slice);
Jani Honkonen
Add drilldown example for piechart
r406 return *this;
}
Jani Honkonen
Add documentation to pie
r314
/*!
Jani Honkonen
Doc fixes for pie
r809 Appends a single slice to the series with give \a value and \a name.
Jani Honkonen
Add documentation to pie
r314 Slice ownership is passed to the series.
*/
Jani Honkonen
rename functions add() -> append()
r796 QPieSlice* QPieSeries::append(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);
Jani Honkonen
rename functions add() -> append()
r796 append(slice);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 return slice;
}
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Doc fixes for pie
r809 /*!
Inserts a single \a slice to the series before the slice at \a index position.
Slice ownership is passed to the series.
*/
void QPieSeries::insert(int index, QPieSlice* slice)
Marek Rosa
Added insert pie slice function to QPieSeries
r604 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Jani Honkonen
Doc fixes for pie
r809 Q_ASSERT(index <= d->m_slices.count());
Marek Rosa
Added insert pie slice function to QPieSeries
r604 slice->setParent(this);
Jani Honkonen
Doc fixes for pie
r809 d->m_slices.insert(index, slice);
Marek Rosa
Added insert pie slice function to QPieSeries
r604
Jani Honkonen
Adding PIMPL to pie
r669 d->updateDerivativeData();
Marek Rosa
Added insert pie slice function to QPieSeries
r604
Jani Honkonen
Adding PIMPL to pie
r669 connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged()));
Jani Honkonen
missing signal/slot parameter at QPieSeries::insert()
r819 connect(slice, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons)));
Jani Honkonen
Adding PIMPL to pie
r669 connect(slice, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter()));
connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave()));
Marek Rosa
Added insert pie slice function to QPieSeries
r604
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)
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
if (!d->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
Adding PIMPL to pie
r669 d->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;
Jani Honkonen
NULL -> 0
r823 slice = 0;
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
Adding PIMPL to pie
r669 Q_D(QPieSeries);
if (d->m_slices.count() == 0)
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
Adding PIMPL to pie
r669 QList<QPieSlice*> slices = d->m_slices;
foreach (QPieSlice* s, d->m_slices) {
d->m_slices.removeOne(s);
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 delete s;
}
Jani Honkonen
Refactoring the pie for animations (no actual animations yet)
r566
Jani Honkonen
Adding PIMPL to pie
r669 d->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
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_slices.count();
Jani Honkonen
Add documentation to pie
r314 }
Jani Honkonen
Refactoring pie series and animations.
r621 /*!
Returns true is the series is empty.
*/
bool QPieSeries::isEmpty() const
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_slices.isEmpty();
Jani Honkonen
Refactoring pie series and animations.
r621 }
Jani Honkonen
Add documentation to pie
r314 /*!
Returns a list of slices that belong to this series.
*/
QList<QPieSlice*> QPieSeries::slices() const
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_slices;
Jani Honkonen
Add documentation to pie
r314 }
/*!
Marek Rosa
Some more doc fixes and additions
r924 Sets the horizontal center position of the pie to \a relativePosition. If \a relativePosition is
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 set to 0.0 the pie is drawn on the left side of the chart and if it's set to 1.0 the pie is
drawn on right side of the chart. The default value 0.5 puts the pie in the middle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 \sa setHorizontalPosition(), setPieSize()
*/
void QPieSeries::setHorizontalPosition(qreal relativePosition)
{
Q_D(QPieSeries);
if (d->setRealValue(d->m_pieRelativeHorPos, relativePosition, 1.0))
emit piePositionChanged();
}
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 /*!
Marek Rosa
Some more doc fixes and additions
r924 Sets the vertical center position of the pie to \a relativePosition. If \a relativePosition is
Jani Honkonen
fix QPieSeries property docs
r928 set to 0.0 the pie is drawn on the top of the chart and if it's set to 1.0 the pie is drawn
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 on bottom of the chart. The default value 0.5 puts the pie in the middle.
Jani Honkonen
Introducing vertical and horizontal factors to control the position of the pie.
r454
Jani Honkonen
fix QPieSeries property docs
r928 \sa verticalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 void QPieSeries::setVerticalPosition(qreal relativePosition)
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 if (d->setRealValue(d->m_pieRelativeVerPos, relativePosition, 1.0))
Jani Honkonen
Refactoring pie series and animations.
r621 emit piePositionChanged();
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
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 \sa verticalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 qreal QPieSeries::horizontalPosition() const
Jani Honkonen
Pie chart refactoring
r142 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->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
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 \sa horizontalPosition(), setPieSize()
Jani Honkonen
Add documentation to pie
r314 */
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 qreal QPieSeries::verticalPosition() const
Jani Honkonen
Add documentation to pie
r314 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->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
fix QPieSeries property docs
r928 \sa pieSize(), verticalPosition(), horizontalPosition()
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
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 if (d->setRealValue(d->m_pieRelativeSize, relativeSize, 1.0))
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
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->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
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 if (d->setRealValue(d->m_pieStartAngle, angle, d->m_pieEndAngle))
Jani Honkonen
Adding PIMPL to pie
r669 d->updateDerivativeData();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 }
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 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_pieStartAngle;
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 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
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Jani Honkonen
Fix issues with comparing equality of floating values in pie
r765
Tero Ahola
QSeries name and QPieSeries properties to QML api
r884 if (d->setRealValue(d->m_pieEndAngle, angle, 360.0, d->m_pieStartAngle))
Jani Honkonen
Adding PIMPL to pie
r669 d->updateDerivativeData();
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 /*!
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 {
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_pieEndAngle;
Jani Honkonen
Added a pie chart customization example and refactoring the pie interface.
r437 }
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)
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
foreach (QPieSlice* s, d->m_slices)
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 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
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(const QPieSeries);
return d->m_total;
Jani Honkonen
Add drilldown example for piechart
r406 }
Jani Honkonen
Add documentation to pie
r314 /*!
Jani Honkonen
Doc fixes for pie
r809 \fn void QPieSeries::clicked(QPieSlice* slice, Qt::MouseButtons buttons)
Jani Honkonen
Add documentation to pie
r314
Jani Honkonen
Doc fixes for pie
r809 This signal is emitted when a \a slice has been clicked with mouse \a buttons.
Jani Honkonen
Add documentation to pie
r314
\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
Doc fixes for pie
r809 /*!
\fn void QPieSeries::added(QList<QPieSlice*> slices)
This signal is emitted when \a slices has been added to the series.
\sa append(), insert()
*/
/*!
\fn void QPieSeries::removed(QList<QPieSlice*> slices)
This signal is emitted when \a slices has been removed from the series.
\sa remove(), clear()
*/
/*!
\fn void QPieSeries::piePositionChanged()
This signal is emitted when pie position has changed.
Marek Rosa
Various documentation fixes
r909 \sa verticalPosition(), setVerticalPosition(), horizontalPosition(), setHorizontalPosition()
Jani Honkonen
Doc fixes for pie
r809 */
/*!
\fn void QPieSeries::pieSizeChanged()
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203
Jani Honkonen
Doc fixes for pie
r809 This signal is emitted when pie size has changed.
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203
Jani Honkonen
Doc fixes for pie
r809 \sa pieSize(), setPieSize()
*/
Jani Honkonen
Refactoring piechart API (and internals)
r174
Marek Rosa
Removed few commeneted out lines and documented few funtions
r879 /*!
\fn bool QPieSeries::setModel(QAbstractItemModel *model)
Sets the \a model to be used as a data source
*/
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 bool QPieSeries::setModel(QAbstractItemModel* model)
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 // 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);
Jani Honkonen
Adding PIMPL to pie
r669 d->m_mapValues = -1;
d->m_mapLabels = -1;
d->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
{
Jani Honkonen
NULL -> 0
r823 m_model = 0;
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 false;
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
}
Marek Rosa
Added documentation for model related funtions
r900 /*!
\fn bool QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation)
Sets column/row specified by \a modelValuesLine to be used as a list of pie slice values for the pie.
Parameter \a modelValuesLine indicates the column/row where the values for the pie slices are located in the model.
Parameter \a modelLabelsLine indicates the column/row where the labels for the pie slices are located in the model.
The \a orientation paramater specifies whether the data is in columns or in rows.
*/
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)
{
Jani Honkonen
Adding PIMPL to pie
r669 Q_D(QPieSeries);
Jani Honkonen
NULL -> 0
r823 if (m_model == 0)
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;
Jani Honkonen
Adding PIMPL to pie
r669
d->m_mapValues = modelValuesLine;
d->m_mapLabels = modelLabelsLine;
d->m_mapOrientation = orientation;
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 // connect the signals
Jani Honkonen
Adding PIMPL to pie
r669 if (d->m_mapOrientation == Qt::Vertical) {
connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int)));
} else {
connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model, SIGNAL(columnsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int)));
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
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
Jani Honkonen
Adding PIMPL to pie
r669 if (d->m_mapOrientation == Qt::Vertical) {
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 for (int i = 0; i < m_model->rowCount(); i++)
Jani Honkonen
rename functions add() -> append()
r796 append(m_model->data(m_model->index(i, d->m_mapValues), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(i, d->m_mapLabels), Qt::DisplayRole).toString());
Jani Honkonen
Adding PIMPL to pie
r669 } else {
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 for (int i = 0; i < m_model->columnCount(); i++)
Jani Honkonen
rename functions add() -> append()
r796 append(m_model->data(m_model->index(d->m_mapValues, i), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(d->m_mapLabels, i), Qt::DisplayRole).toString());
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 }
Jani Honkonen
Pie chart refactoring
r142 #include "moc_qpieseries.cpp"
Jani Honkonen
Adding PIMPL to pie
r669 #include "moc_qpieseriesprivate_p.cpp"
Jani Honkonen
Pie chart refactoring
r142
QTCOMMERCIALCHART_END_NAMESPACE