qlegendmarker.cpp
192 lines
| 3.9 KiB
| text/x-c
|
CppLexer
sauimone
|
r2160 | /**************************************************************************** | ||
** | ||||
** 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$ | ||||
** | ||||
****************************************************************************/ | ||||
#include "qlegendmarker.h" | ||||
sauimone
|
r2163 | #include "qlegendmarker_p.h" | ||
sauimone
|
r2164 | #include "legendmarkeritem_p.h" | ||
sauimone
|
r2160 | #include <QDebug> | ||
sauimone
|
r2163 | #include <QFontMetrics> | ||
sauimone
|
r2169 | #include <QGraphicsSceneEvent> | ||
sauimone
|
r2160 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r2167 | /* | ||
sauimone
|
r2162 | QLegendMarker::QLegendMarker(QAbstractSeries* series, QObject *parent) : | ||
QObject(parent), | ||||
sauimone
|
r2163 | d_ptr(new QLegendMarkerPrivate(series, this)) | ||
sauimone
|
r2160 | { | ||
} | ||||
sauimone
|
r2167 | */ | ||
QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) : | ||||
QObject(parent), | ||||
d_ptr(&d) | ||||
{ | ||||
} | ||||
sauimone
|
r2160 | |||
QLegendMarker::~QLegendMarker() | ||||
{ | ||||
} | ||||
QString QLegendMarker::label() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->label(); | ||
sauimone
|
r2160 | } | ||
void QLegendMarker::setLabel(const QString &label) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setLabel(label); | ||
sauimone
|
r2163 | } | ||
QBrush QLegendMarker::labelBrush() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->labelBrush(); | ||
sauimone
|
r2163 | } | ||
void QLegendMarker::setLabelBrush(const QBrush &brush) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setLabelBrush(brush); | ||
sauimone
|
r2163 | } | ||
QFont QLegendMarker::font() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->font(); | ||
sauimone
|
r2163 | } | ||
void QLegendMarker::setFont(const QFont &font) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setFont(font); | ||
sauimone
|
r2160 | } | ||
QPen QLegendMarker::pen() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->pen(); | ||
sauimone
|
r2160 | } | ||
void QLegendMarker::setPen(const QPen &pen) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setPen(pen); | ||
sauimone
|
r2160 | } | ||
QBrush QLegendMarker::brush() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->brush(); | ||
sauimone
|
r2160 | } | ||
void QLegendMarker::setBrush(const QBrush &brush) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setBrush(brush); | ||
sauimone
|
r2160 | } | ||
bool QLegendMarker::isVisible() const | ||||
{ | ||||
sauimone
|
r2168 | return d_ptr->isVisible(); | ||
sauimone
|
r2160 | } | ||
void QLegendMarker::setVisible(bool visible) | ||||
{ | ||||
sauimone
|
r2168 | d_ptr->setVisible(visible); | ||
sauimone
|
r2160 | } | ||
sauimone
|
r2163 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
sauimone
|
r2167 | QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q) : | ||
q_ptr(q) | ||||
{ | ||||
sauimone
|
r2168 | // qDebug() << "QLegendMarkerPrivate created"; | ||
sauimone
|
r2167 | m_item = new LegendMarkerItem(this); | ||
} | ||||
sauimone
|
r2163 | |||
sauimone
|
r2166 | QLegendMarkerPrivate::~QLegendMarkerPrivate() | ||
{ | ||||
} | ||||
sauimone
|
r2167 | void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event) | ||
{ | ||||
sauimone
|
r2169 | // Just emit clicked signal for now (our default logic for events) | ||
// This could propably be on the LegendMarkerItem? | ||||
// TODO: how to handle scrolling vs clicking? drag event? | ||||
event->accept(); | ||||
sauimone
|
r2167 | Q_Q(QLegendMarker); | ||
emit q->clicked(); | ||||
} | ||||
sauimone
|
r2168 | void QLegendMarkerPrivate::setPen(const QPen &pen) | ||
{ | ||||
m_item->setPen(pen); | ||||
} | ||||
QPen QLegendMarkerPrivate::pen() const | ||||
{ | ||||
return m_item->pen(); | ||||
} | ||||
void QLegendMarkerPrivate::setBrush(const QBrush &brush) | ||||
{ | ||||
m_item->setBrush(brush); | ||||
} | ||||
QBrush QLegendMarkerPrivate::brush() const | ||||
{ | ||||
return m_item->brush(); | ||||
} | ||||
void QLegendMarkerPrivate::setFont(const QFont &font) | ||||
{ | ||||
m_item->setFont(font); | ||||
} | ||||
QFont QLegendMarkerPrivate::font() const | ||||
{ | ||||
return m_item->font(); | ||||
} | ||||
void QLegendMarkerPrivate::setLabel(const QString label) | ||||
{ | ||||
m_item->setLabel(label); | ||||
} | ||||
QString QLegendMarkerPrivate::label() const | ||||
{ | ||||
return m_item->label(); | ||||
} | ||||
void QLegendMarkerPrivate::setLabelBrush(const QBrush &brush) | ||||
{ | ||||
m_item->setLabelBrush(brush); | ||||
} | ||||
QBrush QLegendMarkerPrivate::labelBrush() const | ||||
{ | ||||
return m_item->labelBrush(); | ||||
} | ||||
bool QLegendMarkerPrivate::isVisible() const | ||||
{ | ||||
return m_item->isVisible(); | ||||
} | ||||
void QLegendMarkerPrivate::setVisible(bool visible) | ||||
{ | ||||
m_item->setVisible(visible); | ||||
} | ||||
sauimone
|
r2166 | |||
sauimone
|
r2160 | #include "moc_qlegendmarker.cpp" | ||
sauimone
|
r2163 | #include "moc_qlegendmarker_p.cpp" | ||
sauimone
|
r2160 | |||
QTCOMMERCIALCHART_END_NAMESPACE | ||||