barvalue.cpp
73 lines
| 1.1 KiB
| text/x-c
|
CppLexer
sauimone
|
r263 | #include "barvalue_p.h" | ||
#include <QPainter> | ||||
#include <QPen> | ||||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r267 | BarValue::BarValue(QBarSet &set, QGraphicsItem *parent) | ||
Tero Ahola
|
r518 | : QGraphicsObject(parent), | ||
mBarSet(set), | ||||
mXpos(0), | ||||
mYpos(0), | ||||
mWidth(0), | ||||
mHeight(0) | ||||
sauimone
|
r263 | { | ||
sauimone
|
r273 | setVisible(false); | ||
sauimone
|
r263 | } | ||
void BarValue::setValueString(QString str) | ||||
{ | ||||
mValueString = str; | ||||
} | ||||
QString BarValue::valueString() | ||||
{ | ||||
return mValueString; | ||||
} | ||||
sauimone
|
r473 | void BarValue::setPen(const QPen pen) | ||
sauimone
|
r263 | { | ||
mPen = pen; | ||||
} | ||||
sauimone
|
r473 | QPen BarValue::pen() const | ||
sauimone
|
r263 | { | ||
return mPen; | ||||
} | ||||
void BarValue::resize(qreal w, qreal h) | ||||
{ | ||||
mWidth = w; | ||||
mHeight = h; | ||||
} | ||||
void BarValue::setPos(qreal x, qreal y) | ||||
{ | ||||
mXpos = x; | ||||
mYpos = y; | ||||
} | ||||
void BarValue::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | ||||
{ | ||||
Tero Ahola
|
r611 | Q_UNUSED(option) | ||
Q_UNUSED(widget) | ||||
sauimone
|
r387 | if (isVisible()) { | ||
painter->setPen(mPen); | ||||
painter->drawText(boundingRect(),mValueString); | ||||
} | ||||
sauimone
|
r263 | } | ||
QRectF BarValue::boundingRect() const | ||||
{ | ||||
sauimone
|
r273 | QRectF r(mXpos, mYpos, mWidth, mHeight); | ||
sauimone
|
r263 | return r; | ||
} | ||||
sauimone
|
r273 | void BarValue::toggleVisible() | ||
{ | ||||
setVisible(!isVisible()); | ||||
} | ||||
sauimone
|
r263 | |||
sauimone
|
r273 | #include "moc_barvalue_p.cpp" | ||
sauimone
|
r263 | QTCOMMERCIALCHART_END_NAMESPACE | ||