qpielegendmarker.cpp
99 lines
| 2.8 KiB
| text/x-c
|
CppLexer
|
r2162 | /**************************************************************************** | ||
** | ||||
** 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 "qpielegendmarker.h" | ||||
|
r2166 | #include "qpielegendmarker_p.h" | ||
|
r2162 | #include <QPieSeries> | ||
|
r2174 | #include <QPieSlice> | ||
|
r2167 | #include <QDebug> | ||
|
r2162 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r2168 | |||
|
r2171 | QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent) : | ||
QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent) | ||||
|
r2162 | { | ||
} | ||||
|
r2168 | QPieLegendMarker::~QPieLegendMarker() | ||
|
r2167 | { | ||
|
r2174 | // qDebug() << "deleting pie marker" << this; | ||
|
r2167 | } | ||
/*! | ||||
\internal | ||||
*/ | ||||
QPieLegendMarker::QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent) : | ||||
QLegendMarker(d, parent) | ||||
|
r2164 | { | ||
} | ||||
|
r2174 | QPieSeries* QPieLegendMarker::series() | ||
|
r2163 | { | ||
|
r2167 | Q_D(QPieLegendMarker); | ||
return d->m_series; | ||||
} | ||||
|
r2179 | QPieSlice* QPieLegendMarker::slice() | ||
|
r2167 | { | ||
Q_D(QPieLegendMarker); | ||||
return d->m_slice; | ||||
|
r2163 | } | ||
|
r2162 | |||
|
r2166 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
r2171 | QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) : | ||
QLegendMarkerPrivate(q,legend), | ||||
|
r2167 | m_series(series), | ||
m_slice(slice) | ||||
|
r2166 | { | ||
|
r2168 | QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); | ||
QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); | ||||
|
r2174 | QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); | ||
|
r2167 | updated(); | ||
|
r2166 | } | ||
QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate() | ||||
{ | ||||
|
r2168 | QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); | ||
QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); | ||||
|
r2174 | QObject::disconnect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); | ||
|
r2166 | } | ||
|
r2182 | QPieSeries* QPieLegendMarkerPrivate::series() | ||
{ | ||||
return m_series; | ||||
} | ||||
QObject* QPieLegendMarkerPrivate::relatedObject() | ||||
{ | ||||
return m_slice; | ||||
} | ||||
|
r2167 | void QPieLegendMarkerPrivate::updated() | ||
{ | ||||
|
r2168 | m_item->setPen(m_slice->pen()); | ||
m_item->setBrush(m_slice->brush()); | ||||
|
r2174 | m_item->setLabel(m_slice->label()); | ||
|
r2167 | } | ||
|
r2162 | #include "moc_qpielegendmarker.cpp" | ||
|
r2166 | #include "moc_qpielegendmarker_p.cpp" | ||
|
r2162 | |||
QTCOMMERCIALCHART_END_NAMESPACE | ||||