diff --git a/src/areachart/qareaseries.h b/src/areachart/qareaseries.h index 11db5ba..70d6a02 100644 --- a/src/areachart/qareaseries.h +++ b/src/areachart/qareaseries.h @@ -77,6 +77,7 @@ private: Q_DISABLE_COPY(QAreaSeries) friend class AreaLegendMarker; friend class AreaChartItem; + friend class QAreaLegendMarkerPrivate; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/legend/legend.pri b/src/legend/legend.pri index 3e7520a..ca28f4e 100644 --- a/src/legend/legend.pri +++ b/src/legend/legend.pri @@ -9,7 +9,8 @@ SOURCES += \ $$PWD/qpielegendmarker.cpp \ $$PWD/legendmarkeritem.cpp \ $$PWD/qbarlegendmarker.cpp \ - $$PWD/qxylegendmarker.cpp + $$PWD/qxylegendmarker.cpp \ + $$PWD/qarealegendmarker.cpp PRIVATE_HEADERS += \ $$PWD/legendmarker_p.h \ @@ -20,7 +21,8 @@ PRIVATE_HEADERS += \ $$PWD/legendmarkeritem_p.h \ $$PWD/qpielegendmarker_p.h \ $$PWD/qbarlegendmarker_p.h \ - $$PWD/qxylegendmarker_p.h + $$PWD/qxylegendmarker_p.h \ + $$PWD/qarealegendmarker_p.h PUBLIC_HEADERS += \ @@ -28,4 +30,5 @@ PUBLIC_HEADERS += \ $$PWD/qlegendmarker.h \ $$PWD/qpielegendmarker.h \ $$PWD/qbarlegendmarker.h \ - $$PWD/qxylegendmarker.h + $$PWD/qxylegendmarker.h \ + $$PWD/qarealegendmarker.h diff --git a/src/legend/qarealegendmarker.cpp b/src/legend/qarealegendmarker.cpp new file mode 100644 index 0000000..84084ed --- /dev/null +++ b/src/legend/qarealegendmarker.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 "qarealegendmarker.h" +#include "qarealegendmarker_p.h" +#include "qareaseries_p.h" +#include +#include + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +QAreaLegendMarker::QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObject *parent) : + QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent) +{ +} + +QAreaLegendMarker::~QAreaLegendMarker() +{ +// qDebug() << "deleting Area marker" << this; +} + +/*! + \internal +*/ +QAreaLegendMarker::QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent) : + QLegendMarker(d, parent) +{ +} + +QAreaSeries* QAreaLegendMarker::series() +{ + Q_D(QAreaLegendMarker); + return d->m_series; +} + +QAreaSeries* QAreaLegendMarker::peerObject() +{ + Q_D(QAreaLegendMarker); + return d->m_series; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) : + QLegendMarkerPrivate(q,legend), + m_series(series) +{ + QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated())); + QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); + updated(); +} + +QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate() +{ + QObject::disconnect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated())); + QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); +} + +void QAreaLegendMarkerPrivate::updated() +{ + m_item->setBrush(m_series->brush()); + m_item->setLabel(m_series->name()); +} + +#include "moc_qarealegendmarker.cpp" +#include "moc_qarealegendmarker_p.cpp" + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/legend/qarealegendmarker.h b/src/legend/qarealegendmarker.h new file mode 100644 index 0000000..6e5f34d --- /dev/null +++ b/src/legend/qarealegendmarker.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QAREALEGENDMARKER_H +#define QAREALEGENDMARKER_H + +#include +#include +#include + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class QAreaLegendMarkerPrivate; + +// TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?) +class QTCOMMERCIALCHART_EXPORT QAreaLegendMarker : public QLegendMarker +{ + Q_OBJECT + +public: + explicit QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObject *parent = 0); + virtual ~QAreaLegendMarker(); + + virtual QAreaSeries* series(); + virtual QAreaSeries* peerObject(); // TODO: rename to slice and remove these virtuals from base class? + +protected: + QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent = 0); + +//Q_SIGNALS: + +//public Q_SLOTS: + +private: + Q_DECLARE_PRIVATE(QAreaLegendMarker) + Q_DISABLE_COPY(QAreaLegendMarker) + +}; + +QTCOMMERCIALCHART_END_NAMESPACE + +#endif // QAREALEGENDMARKER_H diff --git a/src/legend/qarealegendmarker_p.h b/src/legend/qarealegendmarker_p.h new file mode 100644 index 0000000..9de60d9 --- /dev/null +++ b/src/legend/qarealegendmarker_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// W A R N I N G +// ------------- +// +// This file is not part of the QtCommercial Chart API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#ifndef QAREALEGENDMARKER_P_H +#define QAREALEGENDMARKER_P_H + +#include "qchartglobal.h" +#include "qlegendmarker_p.h" +#include "legendmarkeritem_p.h" +#include + +#include + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class QAreaLegendMarker; + +class QAreaLegendMarkerPrivate : public QLegendMarkerPrivate +{ + Q_OBJECT +public: + explicit QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend); + virtual ~QAreaLegendMarkerPrivate(); + +public Q_SLOTS: + virtual void updated(); + +private: + QAreaLegendMarker *q_ptr; + + QAreaSeries* m_series; + + friend class QLegendPrivate; // TODO: Is this needed? + Q_DECLARE_PUBLIC(QAreaLegendMarker) +}; + +QTCOMMERCIALCHART_END_NAMESPACE + +#endif // QAREALEGENDMARKER_P_H