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