barlabel.cpp
104 lines
| 2.3 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
|
r820 | #include "barlabel_p.h" | ||
#include "chartpresenter_p.h" | ||||
#include <QBarSet> | ||||
sauimone
|
r263 | #include <QPainter> | ||
#include <QPen> | ||||
sauimone
|
r811 | #include <QGraphicsSimpleTextItem> | ||
sauimone
|
r263 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r820 | BarLabel::BarLabel(QBarSet &barSet, QGraphicsItem *parent) : QGraphicsObject(parent), | ||
m_barSet(barSet), | ||||
sauimone
|
r811 | m_textItem(new QGraphicsSimpleTextItem(this)) | ||
sauimone
|
r263 | { | ||
sauimone
|
r820 | // connect(&set,SIGNAL(labelsVisibleChanged(bool)),value,SLOT(labelsVisibleChanged(bool))); | ||
setZValue(ChartPresenter::BarSeriesZValue + 1); | ||||
setVisible(barSet.labelsVisible()); | ||||
setPen(Qt::NoPen); | ||||
setBrush(Qt::SolidPattern); | ||||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::setText(QString str) | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | m_textItem->setText(str); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | QString BarLabel::text() const | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | return m_textItem->text(); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::setPen(const QPen &pen) | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | m_textItem->setPen(pen); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | QPen BarLabel::pen() const | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | return m_textItem->pen(); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::setBrush(const QBrush &brush) | ||
{ | ||||
m_textItem->setBrush(brush); | ||||
} | ||||
QBrush BarLabel::brush() const | ||||
{ | ||||
return m_textItem->brush(); | ||||
} | ||||
void BarLabel::setFont(const QFont &font) | ||||
sauimone
|
r263 | { | ||
sauimone
|
r811 | m_textItem->setFont(font); | ||
} | ||||
sauimone
|
r820 | QFont BarLabel::font() const | ||
sauimone
|
r811 | { | ||
return m_textItem->font(); | ||||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::setPos(qreal x, qreal y) | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | m_textItem->setPos(x,y); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | ||
sauimone
|
r263 | { | ||
Tero Ahola
|
r816 | Q_UNUSED(painter) | ||
Tero Ahola
|
r611 | Q_UNUSED(option) | ||
Q_UNUSED(widget) | ||||
sauimone
|
r263 | } | ||
sauimone
|
r820 | QRectF BarLabel::boundingRect() const | ||
sauimone
|
r263 | { | ||
sauimone
|
r811 | return m_textItem->boundingRect(); | ||
sauimone
|
r263 | } | ||
sauimone
|
r820 | void BarLabel::labelsVisibleChanged(bool visible) | ||
sauimone
|
r273 | { | ||
sauimone
|
r813 | setVisible(visible); | ||
sauimone
|
r273 | } | ||
sauimone
|
r263 | |||
sauimone
|
r820 | #include "moc_barlabel_p.cpp" | ||
sauimone
|
r263 | QTCOMMERCIALCHART_END_NAMESPACE | ||