barvalue.cpp
93 lines
| 1.9 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
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$ | ||||
** | ||||
****************************************************************************/ | ||||
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), | ||
sauimone
|
r763 | m_barSet(set), | ||
m_xPos(0), | ||||
m_yPos(0), | ||||
m_width(0), | ||||
m_height(0) | ||||
sauimone
|
r263 | { | ||
sauimone
|
r273 | setVisible(false); | ||
sauimone
|
r263 | } | ||
sauimone
|
r776 | void BarValue::setText(QString str) | ||
sauimone
|
r263 | { | ||
sauimone
|
r763 | m_valueString = str; | ||
sauimone
|
r263 | } | ||
sauimone
|
r776 | QString BarValue::text() const | ||
sauimone
|
r263 | { | ||
sauimone
|
r763 | return m_valueString; | ||
sauimone
|
r263 | } | ||
sauimone
|
r776 | void BarValue::setPen(const QPen &pen) | ||
sauimone
|
r263 | { | ||
sauimone
|
r763 | m_pen = pen; | ||
sauimone
|
r263 | } | ||
sauimone
|
r473 | QPen BarValue::pen() const | ||
sauimone
|
r263 | { | ||
sauimone
|
r763 | return m_pen; | ||
sauimone
|
r263 | } | ||
void BarValue::resize(qreal w, qreal h) | ||||
{ | ||||
sauimone
|
r763 | m_width = w; | ||
m_height = h; | ||||
sauimone
|
r263 | } | ||
void BarValue::setPos(qreal x, qreal y) | ||||
{ | ||||
sauimone
|
r763 | m_xPos = x; | ||
m_yPos = y; | ||||
sauimone
|
r263 | } | ||
void BarValue::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | ||||
{ | ||||
Tero Ahola
|
r611 | Q_UNUSED(option) | ||
Q_UNUSED(widget) | ||||
sauimone
|
r387 | if (isVisible()) { | ||
sauimone
|
r763 | painter->setPen(m_pen); | ||
painter->drawText(boundingRect(), m_valueString); | ||||
sauimone
|
r387 | } | ||
sauimone
|
r263 | } | ||
QRectF BarValue::boundingRect() const | ||||
{ | ||||
sauimone
|
r763 | QRectF r(m_xPos, m_yPos, m_width, m_height); | ||
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 | ||