qpieslice.cpp
780 lines
| 19.2 KiB
| text/x-c
|
CppLexer
|
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$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r203 | #include "qpieslice.h" | ||
|
r1274 | #include "qpieslice_p.h" | ||
|
r203 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r314 | /*! | ||
\class QPieSlice | ||||
|
r339 | \brief Defines a slice in pie series. | ||
|
r314 | |||
|
r952 | This object defines the properties of a single slice in a QPieSeries. | ||
|
r320 | |||
|
r952 | In addition to the obvious value and label properties the user can also control | ||
the visual appearance of a slice. By modifying the visual appearance also means that | ||||
|
r1277 | the user is overriding the default appearance set by the theme. | ||
|
r952 | |||
|
r1277 | Note that if the user has customized slices and theme is changed all customizations will be lost. | ||
To enable user interaction with the pie some basic signals are provided about clicking and hovering. | ||||
|
r314 | */ | ||
|
r1470 | /*! | ||
\qmlclass PieSlice QPieSlice | ||||
PieSlice defines the properties of a single slice in a PieSeries. The element should be used | ||||
as a child for a PieSeries. For example: | ||||
\snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | ||||
An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append | ||||
method. | ||||
\snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4 | ||||
In that case you may want to use PieSeries.at or PieSeries.find to access the properties of | ||||
an individual PieSlice instance. | ||||
\snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5 | ||||
\sa PieSeries | ||||
*/ | ||||
|
r1450 | /*! | ||
\enum QPieSlice::LabelPosition | ||||
This enum describes the position of the slice label. | ||||
\value LabelOutside Label is outside the slice with an arm. | ||||
|
r1759 | \value LabelInsideHorizontal Label is centered inside the slice and laid out horizontally. | ||
\value LabelInsideTangential Label is centered inside the slice and rotated to be parallel to the tangential of the slice's arc. | ||||
|
r1731 | \value LabelInsideNormal Label is centered inside the slice rotated to be parallel to the normal of the slice's arc. | ||
|
r1450 | */ | ||
|
r314 | /*! | ||
\property QPieSlice::label | ||||
Label of the slice. | ||||
|
r1307 | \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor | ||
|
r1277 | */ | ||
|
r1470 | /*! | ||
\qmlproperty string PieSlice::label | ||||
Label (text) of the slice. | ||||
*/ | ||||
|
r1277 | |||
/*! | ||||
\fn void QPieSlice::labelChanged() | ||||
This signal emitted when the slice label has been changed. | ||||
|
r1470 | \sa label | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal PieSlice::onLabelChanged() | ||
|
r1470 | This signal emitted when the slice label has been changed. | ||
|
r1277 | \sa label | ||
|
r314 | */ | ||
/*! | ||||
\property QPieSlice::value | ||||
Value of the slice. | ||||
|
r1280 | Note that if users sets a negative value it is converted to a positive value. | ||
|
r952 | \sa percentage(), QPieSeries::sum() | ||
|
r314 | */ | ||
|
r1470 | /*! | ||
\qmlproperty real PieSlice::value | ||||
Value of the slice. Note that if users sets a negative value it is converted to a positive value. | ||||
*/ | ||||
|
r314 | |||
/*! | ||||
|
r1277 | \fn void QPieSlice::valueChanged() | ||
This signal is emitted when the slice value changes. | ||||
|
r1470 | \sa value | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal PieSlice::onValueChanged() | ||
|
r1470 | This signal is emitted when the slice value changes. | ||
|
r1277 | \sa value | ||
*/ | ||||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::labelVisible | ||
|
r1470 | Defines the visibility of slice label. By default the label is not visible. | ||
|
r1307 | \sa label, labelBrush, labelFont, labelArmLengthFactor | ||
|
r314 | */ | ||
|
r1470 | /*! | ||
\qmlproperty bool PieSlice::labelVisible | ||||
Defines the visibility of slice label. By default the label is not visible. | ||||
*/ | ||||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \fn void QPieSlice::labelVisibleChanged() | ||
This signal emitted when visibility of the slice label has changed. | ||||
|
r1470 | \sa labelVisible | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal PieSlice::onLabelVisibleChanged() | ||
|
r1470 | This signal emitted when visibility of the slice label has changed. | ||
|
r1277 | \sa labelVisible | ||
|
r314 | */ | ||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::exploded | ||
|
r1470 | If set to true the slice is "exploded" away from the pie. | ||
\sa explodeDistanceFactor | ||||
*/ | ||||
/*! | ||||
\qmlproperty bool PieSlice::exploded | ||||
If set to true the slice is "exploded" away from the pie. | ||||
|
r1277 | \sa explodeDistanceFactor | ||
|
r314 | */ | ||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::pen | ||
Pen used to draw the slice border. | ||||
|
r314 | */ | ||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \fn void QPieSlice::penChanged() | ||
This signal is emitted when the pen of the slice has changed. | ||||
\sa pen | ||||
*/ | ||||
|
r454 | |||
|
r1338 | /*! | ||
\property QPieSlice::borderColor | ||||
Color used to draw the slice border. | ||||
This is a convenience property for modifying the slice pen. | ||||
\sa pen, borderWidth | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty color PieSlice::borderColor | ||||
Color used to draw the slice border (pen color). | ||||
\sa borderWidth | ||||
*/ | ||||
|
r1338 | |||
/*! | ||||
\fn void QPieSlice::borderColorChanged() | ||||
This signal is emitted when slice border color changes. | ||||
\sa pen, borderColor | ||||
*/ | ||||
|
r1470 | /*! | ||
|
r1531 | \qmlsignal PieSlice::onBorderColorChanged() | ||
|
r1470 | This signal is emitted when slice border color changes. | ||
\sa borderColor | ||||
*/ | ||||
|
r1338 | |||
/*! | ||||
\property QPieSlice::borderWidth | ||||
Width of the slice border. | ||||
This is a convenience property for modifying the slice pen. | ||||
\sa pen, borderColor | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty int PieSlice::borderWidth | ||||
Width of the slice border. | ||||
This is a convenience property for modifying the slice pen. | ||||
\sa borderColor | ||||
*/ | ||||
|
r1338 | |||
/*! | ||||
\fn void QPieSlice::borderWidthChanged() | ||||
This signal is emitted when slice border width changes. | ||||
\sa pen, borderWidth | ||||
*/ | ||||
|
r1470 | /*! | ||
|
r1531 | \qmlsignal PieSlice::onBorderWidthChanged() | ||
|
r1470 | This signal is emitted when slice border width changes. | ||
\sa borderWidth | ||||
*/ | ||||
|
r1338 | |||
|
r1277 | /*! | ||
\property QPieSlice::brush | ||||
Brush used to draw the slice. | ||||
|
r314 | */ | ||
|
r289 | |||
|
r314 | /*! | ||
|
r1277 | \fn void QPieSlice::brushChanged() | ||
This signal is emitted when the brush of the slice has changed. | ||||
\sa brush | ||||
|
r314 | */ | ||
|
r203 | |||
|
r1338 | /*! | ||
\property QPieSlice::color | ||||
|
r1470 | Fill (brush) color of the slice. | ||
|
r1338 | This is a convenience property for modifying the slice brush. | ||
\sa brush | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty color PieSlice::color | ||||
Fill (brush) color of the slice. | ||||
*/ | ||||
|
r1338 | |||
/*! | ||||
\fn void QPieSlice::colorChanged() | ||||
This signal is emitted when slice color changes. | ||||
\sa brush | ||||
*/ | ||||
|
r1470 | /*! | ||
|
r1531 | \qmlsignal PieSlice::onColorChanged() | ||
|
r1470 | This signal is emitted when slice color changes. | ||
*/ | ||||
|
r1338 | |||
|
r314 | /*! | ||
|
r1307 | \property QPieSlice::labelBrush | ||
|
r1470 | Brush used to draw label and label arm of the slice. | ||
|
r1277 | \sa label, labelVisible, labelFont, labelArmLengthFactor | ||
|
r314 | */ | ||
|
r203 | |||
|
r314 | /*! | ||
|
r1307 | \fn void QPieSlice::labelBrushChanged() | ||
|
r1529 | This signal is emitted when the label brush of the slice has changed. | ||
|
r1307 | \sa labelBrush | ||
|
r314 | */ | ||
|
r203 | |||
|
r1338 | /*! | ||
\property QPieSlice::labelColor | ||||
Color used to draw the slice label. | ||||
This is a convenience property for modifying the slice label brush. | ||||
\sa labelBrush | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty color PieSlice::labelColor | ||||
Color used to draw the slice label. | ||||
*/ | ||||
|
r1338 | |||
/*! | ||||
\fn void QPieSlice::labelColorChanged() | ||||
This signal is emitted when slice label color changes. | ||||
|
r1470 | \sa labelColor | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal PieSlice::onLabelColorChanged() | ||
|
r1470 | This signal is emitted when slice label color changes. | ||
|
r1338 | \sa labelColor | ||
*/ | ||||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::labelFont | ||
Font used for drawing label text. | ||||
\sa label, labelVisible, labelArmLengthFactor | ||||
|
r314 | */ | ||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \fn void QPieSlice::labelFontChanged() | ||
This signal is emitted when the label font of the slice has changed. | ||||
\sa labelFont | ||||
|
r314 | */ | ||
|
r203 | |||
|
r1517 | /*! | ||
\qmlproperty Font PieSlice::labelFont | ||||
Defines the font used for slice label. | ||||
See the \l {Font} {QML Font Element} for detailed documentation. | ||||
\sa labelVisible, labelPosition | ||||
*/ | ||||
|
r1450 | /*! | ||
\property QPieSlice::labelPosition | ||||
Position of the slice label. | ||||
\sa label, labelVisible | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty LabelPosition PieSlice::labelPosition | ||||
Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside. | ||||
\sa labelVisible | ||||
*/ | ||||
|
r1450 | |||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::labelArmLengthFactor | ||
Defines the length of the label arm. | ||||
The factor is relative to pie radius. For example: | ||||
1.0 means the length is the same as the radius. | ||||
0.5 means the length is half of the radius. | ||||
|
r1470 | By default the arm length is 0.15 | ||
|
r1307 | \sa label, labelVisible, labelBrush, labelFont | ||
|
r314 | */ | ||
|
r1470 | /*! | ||
\qmlproperty real PieSlice::labelArmLengthFactor | ||||
Defines the length of the label arm. | ||||
The factor is relative to pie radius. For example: | ||||
1.0 means the length is the same as the radius. | ||||
0.5 means the length is half of the radius. | ||||
By default the arm length is 0.15 | ||||
\sa labelVisible | ||||
*/ | ||||
|
r203 | |||
|
r314 | /*! | ||
|
r1277 | \property QPieSlice::explodeDistanceFactor | ||
When the slice is exploded this factor defines how far the slice is exploded away from the pie. | ||||
|
r454 | The factor is relative to pie radius. For example: | ||
|
r1277 | 1.0 means the distance is the same as the radius. | ||
0.5 means the distance is half of the radius. | ||||
|
r1470 | By default the distance is is 0.15 | ||
\sa exploded | ||||
*/ | ||||
/*! | ||||
\qmlproperty real PieSlice::explodeDistanceFactor | ||||
When the slice is exploded this factor defines how far the slice is exploded away from the pie. | ||||
The factor is relative to pie radius. For example: | ||||
1.0 means the distance is the same as the radius. | ||||
0.5 means the distance is half of the radius. | ||||
By default the distance is is 0.15 | ||||
|
r1277 | \sa exploded | ||
|
r314 | */ | ||
|
r203 | |||
|
r1224 | /*! | ||
|
r1277 | \property QPieSlice::percentage | ||
Percentage of the slice compared to the sum of all slices in the series. | ||||
The actual value ranges from 0.0 to 1.0. | ||||
Updated automatically once the slice is added to the series. | ||||
\sa value, QPieSeries::sum | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlproperty real PieSlice::percentage | ||||
Percentage of the slice compared to the sum of all slices in the series. | ||||
The actual value ranges from 0.0 to 1.0. | ||||
Updated automatically once the slice is added to the series. | ||||
*/ | ||||
|
r1277 | |||
/*! | ||||
\fn void QPieSlice::percentageChanged() | ||||
This signal is emitted when the percentage of the slice has changed. | ||||
|
r1470 | \sa percentage | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal void PieSlice::onPercentageChanged() | ||
|
r1470 | This signal is emitted when the percentage of the slice has changed. | ||
|
r1277 | \sa percentage | ||
*/ | ||||
/*! | ||||
\property QPieSlice::startAngle | ||||
Defines the starting angle of this slice in the series it belongs to. | ||||
Full pie is 360 degrees where 0 degrees is at 12 a'clock. | ||||
|
r1470 | Updated automatically once the slice is added to the series. | ||
*/ | ||||
/*! | ||||
\qmlproperty real PieSlice::startAngle | ||||
Defines the starting angle of this slice in the series it belongs to. | ||||
Full pie is 360 degrees where 0 degrees is at 12 a'clock. | ||||
|
r1277 | Updated automatically once the slice is added to the series. | ||
|
r1224 | */ | ||
/*! | ||||
|
r1277 | \fn void QPieSlice::startAngleChanged() | ||
This signal is emitted when the starting angle f the slice has changed. | ||||
|
r1470 | \sa startAngle | ||
*/ | ||||
/*! | ||||
|
r1531 | \qmlsignal PieSlice::onStartAngleChanged() | ||
|
r1470 | This signal is emitted when the starting angle f the slice has changed. | ||
|
r1277 | \sa startAngle | ||
*/ | ||||
|
r1224 | |||
|
r1277 | /*! | ||
\property QPieSlice::angleSpan | ||||
Span of the slice in degrees. | ||||
Full pie is 360 degrees where 0 degrees is at 12 a'clock. | ||||
|
r1470 | Updated automatically once the slice is added to the series. | ||
*/ | ||||
/*! | ||||
\qmlproperty real PieSlice::angleSpan | ||||
Span of the slice in degrees. | ||||
Full pie is 360 degrees where 0 degrees is at 12 a'clock. | ||||
|
r1277 | Updated automatically once the slice is added to the series. | ||
|
r1224 | */ | ||
/*! | ||||
|
r1277 | \fn void QPieSlice::angleSpanChanged() | ||
This signal is emitted when the angle span of the slice has changed. | ||||
\sa angleSpan | ||||
|
r1224 | */ | ||
|
r1470 | /*! | ||
|
r1531 | \qmlsignal PieSlice::onAngleSpanChanged() | ||
|
r1470 | This signal is emitted when the angle span of the slice has changed. | ||
\sa angleSpan | ||||
*/ | ||||
|
r1277 | |||
|
r314 | /*! | ||
|
r1009 | \fn void QPieSlice::clicked() | ||
|
r314 | This signal is emitted when user has clicked the slice. | ||
\sa QPieSeries::clicked() | ||||
*/ | ||||
|
r1470 | /*! | ||
\qmlsignal PieSlice::onClicked() | ||||
This signal is emitted when user has clicked the slice. | ||||
*/ | ||||
|
r314 | |||
/*! | ||||
|
r1009 | \fn void QPieSlice::hovered(bool state) | ||
This signal is emitted when user has hovered over or away from the slice. | ||||
\a state is true when user has hovered over the slice and false when hover has moved away from the slice. | ||||
\sa QPieSeries::hovered() | ||||
|
r314 | */ | ||
|
r1470 | /*! | ||
\qmlsignal PieSlice::onHovered(bool state) | ||||
This signal is emitted when user has hovered over or away from the slice. | ||||
\a state is true when user has hovered over the slice and false when hover has moved away from the slice. | ||||
*/ | ||||
|
r314 | |||
/*! | ||||
|
r1277 | Constructs an empty slice with a \a parent. | ||
\sa QPieSeries::append(), QPieSeries::insert() | ||||
|
r314 | */ | ||
|
r1277 | QPieSlice::QPieSlice(QObject *parent) | ||
:QObject(parent), | ||||
d_ptr(new QPieSlicePrivate(this)) | ||||
|
r203 | { | ||
|
r1277 | |||
|
r203 | } | ||
|
r314 | /*! | ||
|
r1277 | Constructs an empty slice with given \a value, \a label and a \a parent. | ||
\sa QPieSeries::append(), QPieSeries::insert() | ||||
|
r314 | */ | ||
|
r1277 | QPieSlice::QPieSlice(QString label, qreal value, QObject *parent) | ||
:QObject(parent), | ||||
d_ptr(new QPieSlicePrivate(this)) | ||||
{ | ||||
|
r1280 | setValue(value); | ||
setLabel(label); | ||||
|
r1277 | } | ||
/*! | ||||
Destroys the slice. | ||||
User should not delete the slice if it has been added to the series. | ||||
*/ | ||||
QPieSlice::~QPieSlice() | ||||
{ | ||||
} | ||||
|
r203 | void QPieSlice::setLabel(QString label) | ||
{ | ||||
|
r1274 | if (d_ptr->m_data.m_labelText != label) { | ||
d_ptr->m_data.m_labelText = label; | ||||
|
r1224 | emit labelChanged(); | ||
|
r203 | } | ||
} | ||||
|
r1277 | QString QPieSlice::label() const | ||
{ | ||||
return d_ptr->m_data.m_labelText; | ||||
} | ||||
void QPieSlice::setValue(qreal value) | ||||
{ | ||||
|
r1280 | value = qAbs(value); // negative values not allowed | ||
|
r1277 | if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { | ||
d_ptr->m_data.m_value = value; | ||||
emit valueChanged(); | ||||
} | ||||
} | ||||
qreal QPieSlice::value() const | ||||
{ | ||||
return d_ptr->m_data.m_value; | ||||
} | ||||
|
r203 | void QPieSlice::setLabelVisible(bool visible) | ||
{ | ||||
|
r1274 | if (d_ptr->m_data.m_isLabelVisible != visible) { | ||
d_ptr->m_data.m_isLabelVisible = visible; | ||||
emit labelVisibleChanged(); | ||||
|
r203 | } | ||
} | ||||
|
r1277 | bool QPieSlice::isLabelVisible() const | ||
{ | ||||
return d_ptr->m_data.m_isLabelVisible; | ||||
} | ||||
|
r952 | |||
|
r203 | void QPieSlice::setExploded(bool exploded) | ||
{ | ||||
|
r1274 | if (d_ptr->m_data.m_isExploded != exploded) { | ||
d_ptr->m_data.m_isExploded = exploded; | ||||
|
r1494 | emit d_ptr->explodedChanged(); | ||
|
r203 | } | ||
} | ||||
|
r1450 | QPieSlice::LabelPosition QPieSlice::labelPosition() | ||
{ | ||||
return d_ptr->m_data.m_labelPosition; | ||||
} | ||||
void QPieSlice::setLabelPosition(LabelPosition position) | ||||
{ | ||||
if (d_ptr->m_data.m_labelPosition != position) { | ||||
d_ptr->m_data.m_labelPosition = position; | ||||
|
r1494 | emit d_ptr->labelPositionChanged(); | ||
|
r1450 | } | ||
} | ||||
|
r1277 | bool QPieSlice::isExploded() const | ||
|
r289 | { | ||
|
r1277 | return d_ptr->m_data.m_isExploded; | ||
|
r289 | } | ||
|
r756 | void QPieSlice::setPen(const QPen &pen) | ||
|
r203 | { | ||
|
r1274 | d_ptr->setPen(pen, false); | ||
|
r203 | } | ||
|
r1277 | QPen QPieSlice::pen() const | ||
{ | ||||
return d_ptr->m_data.m_slicePen; | ||||
} | ||||
|
r952 | |||
|
r1338 | QColor QPieSlice::borderColor() | ||
{ | ||||
return pen().color(); | ||||
} | ||||
void QPieSlice::setBorderColor(QColor color) | ||||
{ | ||||
QPen p = pen(); | ||||
if (color != p.color()) { | ||||
p.setColor(color); | ||||
setPen(p); | ||||
} | ||||
} | ||||
int QPieSlice::borderWidth() | ||||
{ | ||||
return pen().width(); | ||||
} | ||||
void QPieSlice::setBorderWidth(int width) | ||||
{ | ||||
QPen p = pen(); | ||||
if (width != p.width()) { | ||||
p.setWidth(width); | ||||
setPen(p); | ||||
} | ||||
} | ||||
|
r756 | void QPieSlice::setBrush(const QBrush &brush) | ||
|
r203 | { | ||
|
r1274 | d_ptr->setBrush(brush, false); | ||
|
r203 | } | ||
|
r1277 | QBrush QPieSlice::brush() const | ||
{ | ||||
return d_ptr->m_data.m_sliceBrush; | ||||
} | ||||
|
r952 | |||
|
r1338 | QColor QPieSlice::color() | ||
{ | ||||
return brush().color(); | ||||
} | ||||
void QPieSlice::setColor(QColor color) | ||||
{ | ||||
QBrush b = brush(); | ||||
if (color != b.color()) { | ||||
b.setColor(color); | ||||
setBrush(b); | ||||
} | ||||
} | ||||
|
r1307 | void QPieSlice::setLabelBrush(const QBrush &brush) | ||
|
r203 | { | ||
|
r1307 | d_ptr->setLabelBrush(brush, false); | ||
|
r203 | } | ||
|
r1307 | QBrush QPieSlice::labelBrush() const | ||
|
r1277 | { | ||
|
r1307 | return d_ptr->m_data.m_labelBrush; | ||
|
r1277 | } | ||
|
r952 | |||
|
r1338 | QColor QPieSlice::labelColor() | ||
{ | ||||
return labelBrush().color(); | ||||
} | ||||
void QPieSlice::setLabelColor(QColor color) | ||||
{ | ||||
QBrush b = labelBrush(); | ||||
if (color != b.color()) { | ||||
b.setColor(color); | ||||
setLabelBrush(b); | ||||
} | ||||
} | ||||
|
r469 | void QPieSlice::setLabelFont(const QFont &font) | ||
|
r203 | { | ||
|
r1274 | d_ptr->setLabelFont(font, false); | ||
|
r203 | } | ||
|
r1277 | QFont QPieSlice::labelFont() const | ||
{ | ||||
return d_ptr->m_data.m_labelFont; | ||||
} | ||||
|
r454 | |||
void QPieSlice::setLabelArmLengthFactor(qreal factor) | ||||
|
r203 | { | ||
|
r1274 | if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { | ||
d_ptr->m_data.m_labelArmLengthFactor = factor; | ||||
|
r1494 | emit d_ptr->labelArmLengthFactorChanged(); | ||
|
r1274 | } | ||
} | ||||
|
r1277 | qreal QPieSlice::labelArmLengthFactor() const | ||
{ | ||||
return d_ptr->m_data.m_labelArmLengthFactor; | ||||
} | ||||
void QPieSlice::setExplodeDistanceFactor(qreal factor) | ||||
{ | ||||
if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { | ||||
d_ptr->m_data.m_explodeDistanceFactor = factor; | ||||
|
r1494 | emit d_ptr->explodeDistanceFactorChanged(); | ||
|
r1277 | } | ||
} | ||||
qreal QPieSlice::explodeDistanceFactor() const | ||||
{ | ||||
return d_ptr->m_data.m_explodeDistanceFactor; | ||||
} | ||||
qreal QPieSlice::percentage() const | ||||
{ | ||||
return d_ptr->m_data.m_percentage; | ||||
} | ||||
qreal QPieSlice::startAngle() const | ||||
{ | ||||
return d_ptr->m_data.m_startAngle; | ||||
} | ||||
qreal QPieSlice::angleSpan() const | ||||
{ | ||||
return d_ptr->m_data.m_angleSpan; | ||||
} | ||||
|
r1323 | /*! | ||
Returns the series that this slice belongs to. | ||||
\sa QPieSeries::append() | ||||
*/ | ||||
QPieSeries *QPieSlice::series() const | ||||
{ | ||||
return d_ptr->m_series; | ||||
} | ||||
|
r1274 | QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent) | ||
:QObject(parent), | ||||
|
r1323 | q_ptr(parent), | ||
m_series(0) | ||||
|
r1274 | { | ||
} | ||||
QPieSlicePrivate::~QPieSlicePrivate() | ||||
{ | ||||
} | ||||
QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice) | ||||
{ | ||||
return slice->d_func(); | ||||
} | ||||
void QPieSlicePrivate::setPen(const QPen &pen, bool themed) | ||||
{ | ||||
if (m_data.m_slicePen != pen) { | ||||
|
r1338 | |||
QPen oldPen = m_data.m_slicePen; | ||||
|
r1274 | m_data.m_slicePen = pen; | ||
m_data.m_slicePen.setThemed(themed); | ||||
|
r1338 | |||
|
r1274 | emit q_ptr->penChanged(); | ||
|
r1338 | if (oldPen.color() != pen.color()) | ||
emit q_ptr->borderColorChanged(); | ||||
if (oldPen.width() != pen.width()) | ||||
emit q_ptr->borderWidthChanged(); | ||||
|
r1274 | } | ||
} | ||||
void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed) | ||||
{ | ||||
if (m_data.m_sliceBrush != brush) { | ||||
|
r1338 | |||
QBrush oldBrush = m_data.m_sliceBrush; | ||||
|
r1274 | m_data.m_sliceBrush = brush; | ||
m_data.m_sliceBrush.setThemed(themed); | ||||
|
r1338 | |||
|
r1274 | emit q_ptr->brushChanged(); | ||
|
r1338 | if (oldBrush.color() != brush.color()) | ||
emit q_ptr->colorChanged(); | ||||
|
r1274 | } | ||
} | ||||
|
r1307 | void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed) | ||
|
r1274 | { | ||
|
r1307 | if (m_data.m_labelBrush != brush) { | ||
|
r1338 | |||
QBrush oldBrush = m_data.m_labelBrush; | ||||
|
r1307 | m_data.m_labelBrush = brush; | ||
m_data.m_labelBrush.setThemed(themed); | ||||
|
r1338 | |||
|
r1307 | emit q_ptr->labelBrushChanged(); | ||
|
r1338 | if (oldBrush.color() != brush.color()) | ||
emit q_ptr->labelColorChanged(); | ||||
|
r1274 | } | ||
} | ||||
void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) | ||||
{ | ||||
if (m_data.m_labelFont != font) { | ||||
m_data.m_labelFont = font; | ||||
m_data.m_labelFont.setThemed(themed); | ||||
emit q_ptr->labelFontChanged(); | ||||
} | ||||
} | ||||
void QPieSlicePrivate::setPercentage(qreal percentage) | ||||
{ | ||||
if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { | ||||
m_data.m_percentage = percentage; | ||||
emit q_ptr->percentageChanged(); | ||||
} | ||||
} | ||||
void QPieSlicePrivate::setStartAngle(qreal angle) | ||||
{ | ||||
if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { | ||||
m_data.m_startAngle = angle; | ||||
emit q_ptr->startAngleChanged(); | ||||
} | ||||
} | ||||
void QPieSlicePrivate::setAngleSpan(qreal span) | ||||
{ | ||||
if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { | ||||
m_data.m_angleSpan = span; | ||||
emit q_ptr->angleSpanChanged(); | ||||
|
r203 | } | ||
} | ||||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
|
r837 | |||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
#include "moc_qpieslice.cpp" | ||||
|
r1274 | #include "moc_qpieslice_p.cpp" | ||