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