##// END OF EJS Templates
cleaning up todos
sauimone -
r2192:805641b9c3d1
parent child
Show More
@@ -21,7 +21,6
21 #include <QPainter>
21 #include <QPainter>
22 #include <QGraphicsSceneEvent>
22 #include <QGraphicsSceneEvent>
23 #include <QGraphicsSimpleTextItem>
23 #include <QGraphicsSimpleTextItem>
24 #include <QDebug>
25
24
26 #include "qlegend.h"
25 #include "qlegend.h"
27 #include "qlegend_p.h"
26 #include "qlegend_p.h"
@@ -22,7 +22,6
22 #include "qarealegendmarker_p.h"
22 #include "qarealegendmarker_p.h"
23 #include "qareaseries_p.h"
23 #include "qareaseries_p.h"
24 #include <QAreaSeries>
24 #include <QAreaSeries>
25 #include <QDebug>
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
@@ -33,7 +32,6 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries* series, QLegend *legend, QObje
33
32
34 QAreaLegendMarker::~QAreaLegendMarker()
33 QAreaLegendMarker::~QAreaLegendMarker()
35 {
34 {
36 // qDebug() << "deleting Area marker" << this;
37 }
35 }
38
36
39 /*!
37 /*!
@@ -29,7 +29,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class QAreaLegendMarkerPrivate;
30 class QAreaLegendMarkerPrivate;
31
31
32 // TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?)
33 class QTCOMMERCIALCHART_EXPORT QAreaLegendMarker : public QLegendMarker
32 class QTCOMMERCIALCHART_EXPORT QAreaLegendMarker : public QLegendMarker
34 {
33 {
35 Q_OBJECT
34 Q_OBJECT
@@ -35,8 +35,6
35 #include "legendmarkeritem_p.h"
35 #include "legendmarkeritem_p.h"
36 #include <QAreaSeries>
36 #include <QAreaSeries>
37
37
38 #include <QDebug>
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
39
42 class QAreaLegendMarker;
40 class QAreaLegendMarker;
@@ -48,7 +46,6 public:
48 explicit QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend);
46 explicit QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend);
49 virtual ~QAreaLegendMarkerPrivate();
47 virtual ~QAreaLegendMarkerPrivate();
50
48
51 // internal
52 virtual QAreaSeries* series();
49 virtual QAreaSeries* series();
53 virtual QObject* relatedObject();
50 virtual QObject* relatedObject();
54
51
@@ -57,10 +54,8 public Q_SLOTS:
57
54
58 private:
55 private:
59 QAreaLegendMarker *q_ptr;
56 QAreaLegendMarker *q_ptr;
60
61 QAreaSeries* m_series;
57 QAreaSeries* m_series;
62
58
63 friend class QLegendPrivate; // TODO: Is this needed?
64 Q_DECLARE_PUBLIC(QAreaLegendMarker)
59 Q_DECLARE_PUBLIC(QAreaLegendMarker)
65 };
60 };
66
61
@@ -22,7 +22,6
22 #include "qbarlegendmarker_p.h"
22 #include "qbarlegendmarker_p.h"
23 #include <QAbstractBarSeries>
23 #include <QAbstractBarSeries>
24 #include <QBarSet>
24 #include <QBarSet>
25 #include <QDebug>
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
@@ -33,7 +32,6 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset,
33
32
34 QBarLegendMarker::~QBarLegendMarker()
33 QBarLegendMarker::~QBarLegendMarker()
35 {
34 {
36 // qDebug() << "deleting bar marker" << this;
37 }
35 }
38
36
39 /*!
37 /*!
@@ -36,8 +36,6
36 #include <QAbstractBarSeries>
36 #include <QAbstractBarSeries>
37 #include <QBarSet>
37 #include <QBarSet>
38
38
39 #include <QDebug>
40
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
40
43 class QBarLegendMarker;
41 class QBarLegendMarker;
@@ -57,11 +55,9 public Q_SLOTS:
57
55
58 private:
56 private:
59 QBarLegendMarker *q_ptr;
57 QBarLegendMarker *q_ptr;
60
61 QAbstractBarSeries* m_series;
58 QAbstractBarSeries* m_series;
62 QBarSet* m_barset;
59 QBarSet* m_barset;
63
60
64 friend class QLegendPrivate;
65 Q_DECLARE_PUBLIC(QBarLegendMarker)
61 Q_DECLARE_PUBLIC(QBarLegendMarker)
66 };
62 };
67
63
@@ -178,7 +178,6 QLegend::QLegend(QChart *chart): QGraphicsWidget(chart),
178 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
178 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
179 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*)));
179 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*)));
180 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesRemoved(QAbstractSeries*)));
180 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesRemoved(QAbstractSeries*)));
181 // QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleCountChanged(QAbstractSeries*)));
182 setLayout(d_ptr->m_layout);
181 setLayout(d_ptr->m_layout);
183 }
182 }
184
183
@@ -477,7 +476,6 void QLegendPrivate::addSeries(QAbstractSeries* series)
477 {
476 {
478 // Only allow one instance of series
477 // Only allow one instance of series
479 if (m_series.contains(series)) {
478 if (m_series.contains(series)) {
480 qDebug() << "series already added" << series;
481 return;
479 return;
482 }
480 }
483
481
@@ -485,36 +483,7 void QLegendPrivate::addSeries(QAbstractSeries* series)
485 decorateMarkers(newMarkers);
483 decorateMarkers(newMarkers);
486 addMarkers(newMarkers);
484 addMarkers(newMarkers);
487
485
488 // TODO: This is the part I don't like. There should be better solution.
486 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
489 // On the other hand. It is only one switch case for appending and another for removing series
490 // If countChanged signal were on QAbstractSeries, there would be no need for switch at all.
491 switch (series->type())
492 {
493 case QAbstractSeries::SeriesTypePie: {
494 QPieSeries *s = qobject_cast<QPieSeries *> (series);
495 QObject::connect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
496 break;
497 }
498 case QAbstractSeries::SeriesTypeBar:
499 case QAbstractSeries::SeriesTypeStackedBar:
500 case QAbstractSeries::SeriesTypePercentBar:
501 case QAbstractSeries::SeriesTypeHorizontalBar:
502 case QAbstractSeries::SeriesTypeHorizontalStackedBar:
503 case QAbstractSeries::SeriesTypeHorizontalPercentBar: {
504 QAbstractBarSeries *s = qobject_cast<QAbstractBarSeries *> (series);
505 QObject::connect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
506 break;
507 }
508 case QAbstractSeries::SeriesTypeLine:
509 case QAbstractSeries::SeriesTypeArea:
510 case QAbstractSeries::SeriesTypeScatter:
511 case QAbstractSeries::SeriesTypeSpline:
512 default: {
513 // No need to connect any series related signals. We have no series level
514 // changes, that would generate or delete markers
515 }
516 }
517
518 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
487 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
519
488
520 m_series.append(series);
489 m_series.append(series);
@@ -537,38 +506,10 void QLegendPrivate::removeSeries(QAbstractSeries* series)
537 }
506 }
538 removeMarkers(removed);
507 removeMarkers(removed);
539
508
540 switch (series->type())
509 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
541 {
542 case QAbstractSeries::SeriesTypePie: {
543 QPieSeries *s = qobject_cast<QPieSeries *> (series);
544 QObject::disconnect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
545 break;
546 }
547 case QAbstractSeries::SeriesTypeBar:
548 case QAbstractSeries::SeriesTypeStackedBar:
549 case QAbstractSeries::SeriesTypePercentBar:
550 case QAbstractSeries::SeriesTypeHorizontalBar:
551 case QAbstractSeries::SeriesTypeHorizontalStackedBar:
552 case QAbstractSeries::SeriesTypeHorizontalPercentBar: {
553 QAbstractBarSeries *s = qobject_cast<QAbstractBarSeries *> (series);
554 QObject::disconnect(s, SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
555 break;
556 }
557 // TODO:
558 case QAbstractSeries::SeriesTypeLine:
559 case QAbstractSeries::SeriesTypeArea:
560 case QAbstractSeries::SeriesTypeScatter:
561 case QAbstractSeries::SeriesTypeSpline:
562 default: {
563 // No need to disconnect any series related signals
564 break;
565 }
566 }
567
568 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
510 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
569
511
570 m_layout->invalidate();
512 m_layout->invalidate();
571 // q_ptr->layout()->activate();
572 }
513 }
573
514
574 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series)
515 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series)
@@ -603,14 +544,14 void QLegendPrivate::handleCountChanged()
603 // Here we handle the changes in marker count.
544 // Here we handle the changes in marker count.
604 // Can happen for example when pieslice(s) have been added to or removed from pieseries.
545 // Can happen for example when pieslice(s) have been added to or removed from pieseries.
605
546
606 QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender());
547 QAbstractSeriesPrivate *series = qobject_cast<QAbstractSeriesPrivate *> (sender());
607 QList<QLegendMarker *> createdMarkers = series->d_ptr->createLegendMarkers(q_ptr);
548 QList<QLegendMarker *> createdMarkers = series->createLegendMarkers(q_ptr);
608
549
609 // Find out removed markers and created markers
550 // Find out removed markers and created markers
610 QList<QLegendMarker *> removedMarkers;
551 QList<QLegendMarker *> removedMarkers;
611 foreach (QLegendMarker *oldMarker, m_markers) {
552 foreach (QLegendMarker *oldMarker, m_markers) {
612 // we have marker, which is related to sender.
553 // we have marker, which is related to sender.
613 if (oldMarker->series() == series) {
554 if (oldMarker->series() == series->q_ptr) {
614 bool found = false;
555 bool found = false;
615 foreach(QLegendMarker *newMarker, createdMarkers) {
556 foreach(QLegendMarker *newMarker, createdMarkers) {
616 // New marker considered existing if:
557 // New marker considered existing if:
@@ -22,7 +22,6
22 #include "qlegendmarker_p.h"
22 #include "qlegendmarker_p.h"
23 #include "legendmarkeritem_p.h"
23 #include "legendmarkeritem_p.h"
24 #include "qlegend.h"
24 #include "qlegend.h"
25 #include <QDebug>
26 #include <QFontMetrics>
25 #include <QFontMetrics>
27 #include <QGraphicsSceneEvent>
26 #include <QGraphicsSceneEvent>
28 #include <QAbstractSeries>
27 #include <QAbstractSeries>
@@ -36,7 +36,6
36 #include <QPen>
36 #include <QPen>
37 #include <QGraphicsSimpleTextItem>
37 #include <QGraphicsSimpleTextItem>
38 #include <QGraphicsLayoutItem>
38 #include <QGraphicsLayoutItem>
39 #include <QDebug>
40
39
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
41
@@ -60,10 +59,9 public:
60 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
59 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
61 virtual ~QLegendMarkerPrivate();
60 virtual ~QLegendMarkerPrivate();
62
61
63 // Helper for now. (or deckare LegendLayout as friend)
62 // Helper for now. (or declare LegendLayout as friend)
64 LegendMarkerItem* item() const { return m_item; }
63 LegendMarkerItem* item() const { return m_item; }
65
64
66 // internal
67 virtual QAbstractSeries* series() = 0;
65 virtual QAbstractSeries* series() = 0;
68 virtual QObject* relatedObject() = 0;
66 virtual QObject* relatedObject() = 0;
69
67
@@ -22,7 +22,6
22 #include "qpielegendmarker_p.h"
22 #include "qpielegendmarker_p.h"
23 #include <QPieSeries>
23 #include <QPieSeries>
24 #include <QPieSlice>
24 #include <QPieSlice>
25 #include <QDebug>
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
@@ -33,7 +32,6 QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend
33
32
34 QPieLegendMarker::~QPieLegendMarker()
33 QPieLegendMarker::~QPieLegendMarker()
35 {
34 {
36 // qDebug() << "deleting pie marker" << this;
37 }
35 }
38
36
39 /*!
37 /*!
@@ -30,7 +30,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QPieLegendMarkerPrivate;
31 class QPieLegendMarkerPrivate;
32
32
33 // TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?)
34 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker
33 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker
35 {
34 {
36 Q_OBJECT
35 Q_OBJECT
@@ -36,8 +36,6
36 #include <QPieSeries>
36 #include <QPieSeries>
37 #include <QPieSlice>
37 #include <QPieSlice>
38
38
39 #include <QDebug>
40
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
40
43 class QPieLegendMarker;
41 class QPieLegendMarker;
@@ -62,7 +60,6 private:
62 QPieSeries* m_series;
60 QPieSeries* m_series;
63 QPieSlice* m_slice;
61 QPieSlice* m_slice;
64
62
65 friend class QLegendPrivate; // TODO: Is this needed?
66 Q_DECLARE_PUBLIC(QPieLegendMarker)
63 Q_DECLARE_PUBLIC(QPieLegendMarker)
67 };
64 };
68
65
@@ -22,7 +22,6
22 #include "qxylegendmarker_p.h"
22 #include "qxylegendmarker_p.h"
23 #include "qxyseries_p.h"
23 #include "qxyseries_p.h"
24 #include <QXYSeries>
24 #include <QXYSeries>
25 #include <QDebug>
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
@@ -33,7 +32,6 QXYLegendMarker::QXYLegendMarker(QXYSeries* series, QLegend *legend, QObject *pa
33
32
34 QXYLegendMarker::~QXYLegendMarker()
33 QXYLegendMarker::~QXYLegendMarker()
35 {
34 {
36 // qDebug() << "deleting xy marker" << this;
37 }
35 }
38
36
39 /*!
37 /*!
@@ -35,8 +35,6
35 #include "legendmarkeritem_p.h"
35 #include "legendmarkeritem_p.h"
36 #include <QXYSeries>
36 #include <QXYSeries>
37
37
38 #include <QDebug>
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
39
42 class QXYLegendMarker;
40 class QXYLegendMarker;
@@ -48,7 +46,6 public:
48 explicit QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend);
46 explicit QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend);
49 virtual ~QXYLegendMarkerPrivate();
47 virtual ~QXYLegendMarkerPrivate();
50
48
51 // internal
52 virtual QAbstractSeries* series();
49 virtual QAbstractSeries* series();
53 virtual QObject* relatedObject();
50 virtual QObject* relatedObject();
54
51
@@ -57,10 +54,8 public Q_SLOTS:
57
54
58 private:
55 private:
59 QXYLegendMarker *q_ptr;
56 QXYLegendMarker *q_ptr;
60
61 QXYSeries* m_series;
57 QXYSeries* m_series;
62
58
63 friend class QLegendPrivate; // TODO: Is this needed?
64 Q_DECLARE_PUBLIC(QXYLegendMarker)
59 Q_DECLARE_PUBLIC(QXYLegendMarker)
65 };
60 };
66
61
General Comments 0
You need to be logged in to leave comments. Login now