diff --git a/src/legend/legendmarkeritem.cpp b/src/legend/legendmarkeritem.cpp index 85e4fa3..fe8238e 100644 --- a/src/legend/legendmarkeritem.cpp +++ b/src/legend/legendmarkeritem.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "qlegend.h" #include "qlegend_p.h" diff --git a/src/legend/qarealegendmarker.cpp b/src/legend/qarealegendmarker.cpp index 7bf94e4..5a2a7ea 100644 --- a/src/legend/qarealegendmarker.cpp +++ b/src/legend/qarealegendmarker.cpp @@ -22,7 +22,6 @@ #include "qarealegendmarker_p.h" #include "qareaseries_p.h" #include -#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -33,7 +32,6 @@ QAreaLegendMarker::QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObje QAreaLegendMarker::~QAreaLegendMarker() { -// qDebug() << "deleting Area marker" << this; } /*! diff --git a/src/legend/qarealegendmarker.h b/src/legend/qarealegendmarker.h index 55c06b9..5d51d11 100644 --- a/src/legend/qarealegendmarker.h +++ b/src/legend/qarealegendmarker.h @@ -29,7 +29,6 @@ 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 diff --git a/src/legend/qarealegendmarker_p.h b/src/legend/qarealegendmarker_p.h index e2f88c5..b83a3f1 100644 --- a/src/legend/qarealegendmarker_p.h +++ b/src/legend/qarealegendmarker_p.h @@ -35,8 +35,6 @@ #include "legendmarkeritem_p.h" #include -#include - QTCOMMERCIALCHART_BEGIN_NAMESPACE class QAreaLegendMarker; @@ -48,7 +46,6 @@ public: explicit QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend); virtual ~QAreaLegendMarkerPrivate(); - // internal virtual QAreaSeries* series(); virtual QObject* relatedObject(); @@ -57,10 +54,8 @@ public Q_SLOTS: private: QAreaLegendMarker *q_ptr; - QAreaSeries* m_series; - friend class QLegendPrivate; // TODO: Is this needed? Q_DECLARE_PUBLIC(QAreaLegendMarker) }; diff --git a/src/legend/qbarlegendmarker.cpp b/src/legend/qbarlegendmarker.cpp index dd9abac..7d46ed1 100644 --- a/src/legend/qbarlegendmarker.cpp +++ b/src/legend/qbarlegendmarker.cpp @@ -22,7 +22,6 @@ #include "qbarlegendmarker_p.h" #include #include -#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -33,7 +32,6 @@ QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset, QBarLegendMarker::~QBarLegendMarker() { -// qDebug() << "deleting bar marker" << this; } /*! diff --git a/src/legend/qbarlegendmarker_p.h b/src/legend/qbarlegendmarker_p.h index 9c15b31..11fbb1d 100644 --- a/src/legend/qbarlegendmarker_p.h +++ b/src/legend/qbarlegendmarker_p.h @@ -36,8 +36,6 @@ #include #include -#include - QTCOMMERCIALCHART_BEGIN_NAMESPACE class QBarLegendMarker; @@ -57,11 +55,9 @@ public Q_SLOTS: private: QBarLegendMarker *q_ptr; - QAbstractBarSeries* m_series; QBarSet* m_barset; - friend class QLegendPrivate; Q_DECLARE_PUBLIC(QBarLegendMarker) }; diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index 2f002df..ad6ddaa 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -178,7 +178,6 @@ QLegend::QLegend(QChart *chart): QGraphicsWidget(chart), setFlags(QGraphicsItem::ItemClipsChildrenToShape); QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*))); QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesRemoved(QAbstractSeries*))); -// QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleCountChanged(QAbstractSeries*))); setLayout(d_ptr->m_layout); } @@ -477,7 +476,6 @@ void QLegendPrivate::addSeries(QAbstractSeries* series) { // Only allow one instance of series if (m_series.contains(series)) { - qDebug() << "series already added" << series; return; } @@ -485,36 +483,7 @@ void QLegendPrivate::addSeries(QAbstractSeries* series) decorateMarkers(newMarkers); addMarkers(newMarkers); - // TODO: This is the part I don't like. There should be better solution. - // On the other hand. It is only one switch case for appending and another for removing series - // If countChanged signal were on QAbstractSeries, there would be no need for switch at all. - switch (series->type()) - { - case QAbstractSeries::SeriesTypePie: { - QPieSeries *s = qobject_cast (series); - QObject::connect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged())); - break; - } - case QAbstractSeries::SeriesTypeBar: - case QAbstractSeries::SeriesTypeStackedBar: - case QAbstractSeries::SeriesTypePercentBar: - case QAbstractSeries::SeriesTypeHorizontalBar: - case QAbstractSeries::SeriesTypeHorizontalStackedBar: - case QAbstractSeries::SeriesTypeHorizontalPercentBar: { - QAbstractBarSeries *s = qobject_cast (series); - QObject::connect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged())); - break; - } - case QAbstractSeries::SeriesTypeLine: - case QAbstractSeries::SeriesTypeArea: - case QAbstractSeries::SeriesTypeScatter: - case QAbstractSeries::SeriesTypeSpline: - default: { - // No need to connect any series related signals. We have no series level - // changes, that would generate or delete markers - } - } - + QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); m_series.append(series); @@ -537,38 +506,10 @@ void QLegendPrivate::removeSeries(QAbstractSeries* series) } removeMarkers(removed); - switch (series->type()) - { - case QAbstractSeries::SeriesTypePie: { - QPieSeries *s = qobject_cast (series); - QObject::disconnect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged())); - break; - } - case QAbstractSeries::SeriesTypeBar: - case QAbstractSeries::SeriesTypeStackedBar: - case QAbstractSeries::SeriesTypePercentBar: - case QAbstractSeries::SeriesTypeHorizontalBar: - case QAbstractSeries::SeriesTypeHorizontalStackedBar: - case QAbstractSeries::SeriesTypeHorizontalPercentBar: { - QAbstractBarSeries *s = qobject_cast (series); - QObject::disconnect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged())); - break; - } - // TODO: - case QAbstractSeries::SeriesTypeLine: - case QAbstractSeries::SeriesTypeArea: - case QAbstractSeries::SeriesTypeScatter: - case QAbstractSeries::SeriesTypeSpline: - default: { - // No need to disconnect any series related signals - break; - } - } - + QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); m_layout->invalidate(); -// q_ptr->layout()->activate(); } void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series) @@ -603,14 +544,14 @@ void QLegendPrivate::handleCountChanged() // Here we handle the changes in marker count. // Can happen for example when pieslice(s) have been added to or removed from pieseries. - QAbstractSeries *series = qobject_cast (sender()); - QList createdMarkers = series->d_ptr->createLegendMarkers(q_ptr); + QAbstractSeriesPrivate *series = qobject_cast (sender()); + QList createdMarkers = series->createLegendMarkers(q_ptr); // Find out removed markers and created markers QList removedMarkers; foreach (QLegendMarker *oldMarker, m_markers) { // we have marker, which is related to sender. - if (oldMarker->series() == series) { + if (oldMarker->series() == series->q_ptr) { bool found = false; foreach(QLegendMarker *newMarker, createdMarkers) { // New marker considered existing if: diff --git a/src/legend/qlegendmarker.cpp b/src/legend/qlegendmarker.cpp index 783c193..cc77a26 100644 --- a/src/legend/qlegendmarker.cpp +++ b/src/legend/qlegendmarker.cpp @@ -22,7 +22,6 @@ #include "qlegendmarker_p.h" #include "legendmarkeritem_p.h" #include "qlegend.h" -#include #include #include #include diff --git a/src/legend/qlegendmarker_p.h b/src/legend/qlegendmarker_p.h index 386d0d2..874b929 100644 --- a/src/legend/qlegendmarker_p.h +++ b/src/legend/qlegendmarker_p.h @@ -36,7 +36,6 @@ #include #include #include -#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -60,10 +59,9 @@ public: explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend); virtual ~QLegendMarkerPrivate(); - // Helper for now. (or deckare LegendLayout as friend) + // Helper for now. (or declare LegendLayout as friend) LegendMarkerItem* item() const { return m_item; } - // internal virtual QAbstractSeries* series() = 0; virtual QObject* relatedObject() = 0; diff --git a/src/legend/qpielegendmarker.cpp b/src/legend/qpielegendmarker.cpp index 0b99e69..d8479ed 100644 --- a/src/legend/qpielegendmarker.cpp +++ b/src/legend/qpielegendmarker.cpp @@ -22,7 +22,6 @@ #include "qpielegendmarker_p.h" #include #include -#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -33,7 +32,6 @@ QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend QPieLegendMarker::~QPieLegendMarker() { -// qDebug() << "deleting pie marker" << this; } /*! diff --git a/src/legend/qpielegendmarker.h b/src/legend/qpielegendmarker.h index 47e0e21..467c95d 100644 --- a/src/legend/qpielegendmarker.h +++ b/src/legend/qpielegendmarker.h @@ -30,7 +30,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class QPieLegendMarkerPrivate; -// TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?) class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker { Q_OBJECT diff --git a/src/legend/qpielegendmarker_p.h b/src/legend/qpielegendmarker_p.h index 62f83df..dbb69c1 100644 --- a/src/legend/qpielegendmarker_p.h +++ b/src/legend/qpielegendmarker_p.h @@ -36,8 +36,6 @@ #include #include -#include - QTCOMMERCIALCHART_BEGIN_NAMESPACE class QPieLegendMarker; @@ -62,7 +60,6 @@ private: QPieSeries* m_series; QPieSlice* m_slice; - friend class QLegendPrivate; // TODO: Is this needed? Q_DECLARE_PUBLIC(QPieLegendMarker) }; diff --git a/src/legend/qxylegendmarker.cpp b/src/legend/qxylegendmarker.cpp index acfb6a0..71d698e 100644 --- a/src/legend/qxylegendmarker.cpp +++ b/src/legend/qxylegendmarker.cpp @@ -22,7 +22,6 @@ #include "qxylegendmarker_p.h" #include "qxyseries_p.h" #include -#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -33,7 +32,6 @@ QXYLegendMarker::QXYLegendMarker(QXYSeries* series, QLegend *legend, QObject *pa QXYLegendMarker::~QXYLegendMarker() { -// qDebug() << "deleting xy marker" << this; } /*! diff --git a/src/legend/qxylegendmarker_p.h b/src/legend/qxylegendmarker_p.h index 98c7c5b..af1e513 100644 --- a/src/legend/qxylegendmarker_p.h +++ b/src/legend/qxylegendmarker_p.h @@ -35,8 +35,6 @@ #include "legendmarkeritem_p.h" #include -#include - QTCOMMERCIALCHART_BEGIN_NAMESPACE class QXYLegendMarker; @@ -48,7 +46,6 @@ public: explicit QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend); virtual ~QXYLegendMarkerPrivate(); - // internal virtual QAbstractSeries* series(); virtual QObject* relatedObject(); @@ -57,10 +54,8 @@ public Q_SLOTS: private: QXYLegendMarker *q_ptr; - QXYSeries* m_series; - friend class QLegendPrivate; // TODO: Is this needed? Q_DECLARE_PUBLIC(QXYLegendMarker) };