##// END OF EJS Templates
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.

File last commit:

r203:7350e0387b3f
r203:7350e0387b3f
Show More
qpieslice.cpp
181 lines | 2.9 KiB | text/x-c | CppLexer
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 #include "qpieslice.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
#define DEFAULT_PEN_COLOR Qt::black
#define DEFAULT_BRUSH_COLOR Qt::white
#define DEFAULT_LABEL_ARM_LENGTH 50
QPieSlice::QPieSlice(QObject *parent)
:QObject(parent),
m_value(0),
m_isLabelVisible(true),
m_isExploded(false),
m_percentage(0),
m_angle(0),
m_span(0),
m_pen(DEFAULT_PEN_COLOR),
m_brush(DEFAULT_BRUSH_COLOR),
m_labelPen(DEFAULT_PEN_COLOR),
m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
{
}
QPieSlice::QPieSlice(qreal value, QString label, bool labelVisible, QObject *parent)
:QObject(parent),
m_value(value),
m_label(label),
m_isLabelVisible(labelVisible),
m_isExploded(false),
m_percentage(0),
m_angle(0),
m_span(0),
m_pen(DEFAULT_PEN_COLOR),
m_brush(DEFAULT_BRUSH_COLOR),
m_labelPen(DEFAULT_PEN_COLOR),
m_labelArmLength(DEFAULT_LABEL_ARM_LENGTH)
{
}
QPieSlice::~QPieSlice()
{
}
qreal QPieSlice::value() const
{
return m_value;
}
QString QPieSlice::label() const
{
return m_label;
}
bool QPieSlice::isLabelVisible() const
{
return m_isLabelVisible;
}
bool QPieSlice::isExploded() const
{
return m_isExploded;
}
qreal QPieSlice::percentage() const
{
return m_percentage;
}
qreal QPieSlice::angle() const
{
return m_angle;
}
qreal QPieSlice::span() const
{
return m_span;
}
QPen QPieSlice::pen() const
{
return m_pen;
}
QBrush QPieSlice::brush() const
{
return m_brush;
}
QPen QPieSlice::labelPen() const
{
return m_labelPen;
}
QFont QPieSlice::labelFont() const
{
return m_labelFont;
}
qreal QPieSlice::labelArmLenght() const
{
return m_labelArmLength;
}
void QPieSlice::setValue(qreal value)
{
if (m_value != value) {
m_value = value;
emit changed();
}
}
void QPieSlice::setLabel(QString label)
{
if (m_label != label) {
m_label = label;
emit changed();
}
}
void QPieSlice::setLabelVisible(bool visible)
{
if (m_isLabelVisible != visible) {
m_isLabelVisible = visible;
emit changed();
}
}
void QPieSlice::setExploded(bool exploded)
{
if (m_isExploded != exploded) {
m_isExploded = exploded;
emit changed();
}
}
void QPieSlice::setPen(QPen pen)
{
if (m_pen != pen) {
m_pen = pen;
emit changed();
}
}
void QPieSlice::setBrush(QBrush brush)
{
if (m_brush != brush) {
m_brush = brush;
emit changed();
}
}
void QPieSlice::setLabelFont(QFont font)
{
if (m_labelFont != font) {
m_labelFont = font;
emit changed();
}
}
void QPieSlice::setLabelPen(QPen pen)
{
if (m_labelPen != pen) {
m_labelPen = pen;
emit changed();
}
}
void QPieSlice::setLabelArmLength(qreal len)
{
if (m_labelArmLength != len) {
m_labelArmLength = len;
emit changed();
}
}
#include "moc_qpieslice.cpp"
QTCOMMERCIALCHART_END_NAMESPACE