|
|
#include <QtCharts/QColorMapLegendMarker>
|
|
|
#include <private/qcolormapseries_p.h>
|
|
|
#include <private/qcolormaplegendmarker_p.h>
|
|
|
#include <QtCharts/QColorMapSeries>
|
|
|
|
|
|
QT_CHARTS_BEGIN_NAMESPACE
|
|
|
|
|
|
QColorMapLegendMarker::QColorMapLegendMarker(QColorMapSeries *series, QLegend *legend, QObject *parent)
|
|
|
: QLegendMarker(*new QColorMapLegendMarkerPrivate(this,series,legend), parent)
|
|
|
{
|
|
|
d_ptr->updated();
|
|
|
}
|
|
|
|
|
|
QColorMapLegendMarker::~QColorMapLegendMarker()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
QColorMapLegendMarker::QColorMapLegendMarker(QColorMapLegendMarkerPrivate &d, QObject *parent) :
|
|
|
QLegendMarker(d, parent)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
QColorMapSeries* QColorMapLegendMarker::series()
|
|
|
{
|
|
|
Q_D(QColorMapLegendMarker);
|
|
|
return d->m_series;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
QColorMapLegendMarkerPrivate::QColorMapLegendMarkerPrivate(QColorMapLegendMarker *q, QColorMapSeries *series, QLegend *legend) :
|
|
|
QLegendMarkerPrivate(q,legend),
|
|
|
q_ptr(q),
|
|
|
m_series(series)
|
|
|
{
|
|
|
QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
|
|
|
QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
|
|
|
}
|
|
|
|
|
|
QColorMapLegendMarkerPrivate::~QColorMapLegendMarkerPrivate()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
QAbstractSeries* QColorMapLegendMarkerPrivate::series()
|
|
|
{
|
|
|
return m_series;
|
|
|
}
|
|
|
|
|
|
QObject* QColorMapLegendMarkerPrivate::relatedObject()
|
|
|
{
|
|
|
return m_series;
|
|
|
}
|
|
|
|
|
|
void QColorMapLegendMarkerPrivate::updated()
|
|
|
{
|
|
|
bool labelChanged = false;
|
|
|
bool brushChanged = false;
|
|
|
|
|
|
if (!m_customLabel && (m_item->label() != m_series->name())) {
|
|
|
m_item->setLabel(m_series->name());
|
|
|
labelChanged = true;
|
|
|
}
|
|
|
|
|
|
QBrush emptyBrush;
|
|
|
if (!m_customBrush
|
|
|
&& (m_item->brush() == emptyBrush
|
|
|
|| m_item->brush().color() != m_series->pen().color())) {
|
|
|
m_item->setBrush(QBrush(m_series->pen().color()));
|
|
|
brushChanged = true;
|
|
|
}
|
|
|
|
|
|
invalidateLegend();
|
|
|
|
|
|
if (labelChanged)
|
|
|
emit q_ptr->labelChanged();
|
|
|
if (brushChanged)
|
|
|
emit q_ptr->brushChanged();
|
|
|
}
|
|
|
|
|
|
//#include "moc_qcolormaplegendmarker.cpp"
|
|
|
//#include "moc_qcolormaplegendmarker_p.cpp"
|
|
|
|
|
|
QT_CHARTS_END_NAMESPACE
|
|
|
|