@@ -198,9 +198,11 QAbstractBarSeries::~QAbstractBarSeries() | |||||
198 | /*! |
|
198 | /*! | |
199 | \internal |
|
199 | \internal | |
200 | */ |
|
200 | */ | |
201 |
QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate & |
|
201 | QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &o, QObject *parent) : | |
202 |
QAbstractSeries( |
|
202 | QAbstractSeries(o,parent) | |
203 | { |
|
203 | { | |
|
204 | Q_D(QAbstractSeries); | |||
|
205 | QObject::connect(this,SIGNAL(countChanged()),d,SIGNAL(countChanged())); | |||
204 | } |
|
206 | } | |
205 |
|
207 | |||
206 | /*! |
|
208 | /*! | |
@@ -672,7 +674,6 QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* lege | |||||
672 |
|
674 | |||
673 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) |
|
675 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) | |
674 | { |
|
676 | { | |
675 | Q_Q(QAbstractBarSeries); |
|
|||
676 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
677 | if ((m_barSets.contains(set)) || (set == 0)) { | |
677 | // Fail if set is already in list or set is null. |
|
678 | // Fail if set is already in list or set is null. | |
678 | return false; |
|
679 | return false; | |
@@ -684,13 +685,11 bool QAbstractBarSeriesPrivate::append(QBarSet *set) | |||||
684 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
685 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
685 |
|
686 | |||
686 | emit restructuredBars(); // this notifies barchartitem |
|
687 | emit restructuredBars(); // this notifies barchartitem | |
687 | emit legendPropertiesUpdated(q); // this notifies legend |
|
|||
688 | return true; |
|
688 | return true; | |
689 | } |
|
689 | } | |
690 |
|
690 | |||
691 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) |
|
691 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) | |
692 | { |
|
692 | { | |
693 | Q_Q(QAbstractBarSeries); |
|
|||
694 | if (!m_barSets.contains(set)) { |
|
693 | if (!m_barSets.contains(set)) { | |
695 | // Fail if set is not in list |
|
694 | // Fail if set is not in list | |
696 | return false; |
|
695 | return false; | |
@@ -702,13 +701,11 bool QAbstractBarSeriesPrivate::remove(QBarSet *set) | |||||
702 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
701 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
703 |
|
702 | |||
704 | emit restructuredBars(); // this notifies barchartitem |
|
703 | emit restructuredBars(); // this notifies barchartitem | |
705 | emit legendPropertiesUpdated(q); |
|
|||
706 | return true; |
|
704 | return true; | |
707 | } |
|
705 | } | |
708 |
|
706 | |||
709 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
707 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) | |
710 | { |
|
708 | { | |
711 | Q_Q(QAbstractBarSeries); |
|
|||
712 | foreach (QBarSet* set, sets) { |
|
709 | foreach (QBarSet* set, sets) { | |
713 | if ((set == 0) || (m_barSets.contains(set))) { |
|
710 | if ((set == 0) || (m_barSets.contains(set))) { | |
714 | // Fail if any of the sets is null or is already appended. |
|
711 | // Fail if any of the sets is null or is already appended. | |
@@ -728,13 +725,11 bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) | |||||
728 | } |
|
725 | } | |
729 |
|
726 | |||
730 | emit restructuredBars(); // this notifies barchartitem |
|
727 | emit restructuredBars(); // this notifies barchartitem | |
731 | emit legendPropertiesUpdated(q); // this notifies legend |
|
|||
732 | return true; |
|
728 | return true; | |
733 | } |
|
729 | } | |
734 |
|
730 | |||
735 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
731 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
736 | { |
|
732 | { | |
737 | Q_Q(QAbstractBarSeries); |
|
|||
738 | if (sets.count() == 0) { |
|
733 | if (sets.count() == 0) { | |
739 | return false; |
|
734 | return false; | |
740 | } |
|
735 | } | |
@@ -757,13 +752,11 bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) | |||||
757 | } |
|
752 | } | |
758 |
|
753 | |||
759 | emit restructuredBars(); // this notifies barchartitem |
|
754 | emit restructuredBars(); // this notifies barchartitem | |
760 | emit legendPropertiesUpdated(q); |
|
|||
761 | return true; |
|
755 | return true; | |
762 | } |
|
756 | } | |
763 |
|
757 | |||
764 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) |
|
758 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) | |
765 | { |
|
759 | { | |
766 | Q_Q(QAbstractBarSeries); |
|
|||
767 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
760 | if ((m_barSets.contains(set)) || (set == 0)) { | |
768 | // Fail if set is already in list or set is null. |
|
761 | // Fail if set is already in list or set is null. | |
769 | return false; |
|
762 | return false; | |
@@ -775,7 +768,6 bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) | |||||
775 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
768 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); | |
776 |
|
769 | |||
777 | emit restructuredBars(); // this notifies barchartitem |
|
770 | emit restructuredBars(); // this notifies barchartitem | |
778 | emit legendPropertiesUpdated(q); |
|
|||
779 | return true; |
|
771 | return true; | |
780 | } |
|
772 | } | |
781 |
|
773 |
@@ -62,6 +62,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
62 | QBarSeries::QBarSeries(QObject *parent) |
|
62 | QBarSeries::QBarSeries(QObject *parent) | |
63 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) |
|
63 | : QAbstractBarSeries(*new QBarSeriesPrivate(this), parent) | |
64 | { |
|
64 | { | |
|
65 | ||||
65 | } |
|
66 | } | |
66 |
|
67 | |||
67 | /*! |
|
68 | /*! |
@@ -104,7 +104,6 void LegendLayout::setGeometry(const QRectF& rect) | |||||
104 | void LegendLayout::setAttachedGeometry(const QRectF& rect) |
|
104 | void LegendLayout::setAttachedGeometry(const QRectF& rect) | |
105 | { |
|
105 | { | |
106 | if (!rect.isValid()) return; |
|
106 | if (!rect.isValid()) return; | |
107 |
|
||||
108 | m_offsetX=0; |
|
107 | m_offsetX=0; | |
109 | m_offsetY=0; |
|
108 | m_offsetY=0; | |
110 |
|
109 |
@@ -32,7 +32,7 | |||||
32 | #include <QPainter> |
|
32 | #include <QPainter> | |
33 | #include <QGraphicsSceneEvent> |
|
33 | #include <QGraphicsSceneEvent> | |
34 | #include <QGraphicsSimpleTextItem> |
|
34 | #include <QGraphicsSimpleTextItem> | |
35 |
#include <Q |
|
35 | #include <QGraphicsLayout> | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
@@ -88,6 +88,7 void LegendMarker::setLabel(const QString label) | |||||
88 | { |
|
88 | { | |
89 | m_text = label; |
|
89 | m_text = label; | |
90 | updateGeometry(); |
|
90 | updateGeometry(); | |
|
91 | m_legend->layout()->invalidate(); | |||
91 | } |
|
92 | } | |
92 |
|
93 | |||
93 | QString LegendMarker::label() const |
|
94 | QString LegendMarker::label() const |
@@ -475,10 +475,11 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||||
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
477 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
478 |
QObject::connect(series->d_ptr.data(), SIGNAL( |
|
478 | QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); | |
479 |
|
479 | |||
|
480 | m_items->setVisible(false); | |||
480 | q_ptr->layout()->invalidate(); |
|
481 | q_ptr->layout()->invalidate(); | |
481 |
|
|
482 | m_presenter->layout()->invalidate(); | |
482 | } |
|
483 | } | |
483 |
|
484 | |||
484 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
|
485 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |
@@ -491,7 +492,7 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |||||
491 | } |
|
492 | } | |
492 |
|
493 | |||
493 | QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
494 | QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
494 |
QObject::disconnect(series->d_ptr.data(), SIGNAL( |
|
495 | QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); | |
495 |
|
496 | |||
496 | q_ptr->layout()->invalidate(); |
|
497 | q_ptr->layout()->invalidate(); | |
497 | } |
|
498 | } | |
@@ -499,6 +500,7 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |||||
499 | void QLegendPrivate::handleSeriesVisibleChanged() |
|
500 | void QLegendPrivate::handleSeriesVisibleChanged() | |
500 | { |
|
501 | { | |
501 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); |
|
502 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); | |
|
503 | Q_ASSERT(series); | |||
502 |
|
504 | |||
503 | foreach (LegendMarker* marker, m_markers) { |
|
505 | foreach (LegendMarker* marker, m_markers) { | |
504 | if (marker->series() == series) { |
|
506 | if (marker->series() == series) { | |
@@ -509,13 +511,12 void QLegendPrivate::handleSeriesVisibleChanged() | |||||
509 | q_ptr->layout()->invalidate(); |
|
511 | q_ptr->layout()->invalidate(); | |
510 | } |
|
512 | } | |
511 |
|
513 | |||
512 | void QLegendPrivate::handleLegendPropertiesUpdated(QAbstractSeries *series) |
|
514 | void QLegendPrivate::handleCountChanged() | |
513 | { |
|
515 | { | |
514 | // Handle new or removed markers |
|
516 | QAbstractSeriesPrivate* series = qobject_cast<QAbstractSeriesPrivate *> (sender()); | |
515 | // Handle changes of marker pen/brush/label. every property that legend is interested |
|
517 | Q_ASSERT(series); | |
516 | handleSeriesRemoved(series); |
|
518 | handleSeriesRemoved(series->q_ptr); | |
517 | Domain domain; |
|
519 | handleSeriesAdded(series->q_ptr, 0); | |
518 | handleSeriesAdded(series, &domain); |
|
|||
519 | } |
|
520 | } | |
520 |
|
521 | |||
521 | #include "moc_qlegend.cpp" |
|
522 | #include "moc_qlegend.cpp" |
@@ -59,7 +59,7 public Q_SLOTS: | |||||
59 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); |
|
59 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |
60 | void handleSeriesRemoved(QAbstractSeries *series); |
|
60 | void handleSeriesRemoved(QAbstractSeries *series); | |
61 | void handleSeriesVisibleChanged(); |
|
61 | void handleSeriesVisibleChanged(); | |
62 | void handleLegendPropertiesUpdated(QAbstractSeries *series); |
|
62 | void handleCountChanged(); | |
63 |
|
63 | |||
64 | private: |
|
64 | private: | |
65 | QLegend *q_ptr; |
|
65 | QLegend *q_ptr; |
@@ -350,7 +350,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
350 | QPieSeries::QPieSeries(QObject *parent) : |
|
350 | QPieSeries::QPieSeries(QObject *parent) : | |
351 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) |
|
351 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) | |
352 | { |
|
352 | { | |
353 |
|
353 | Q_D(QPieSeries); | ||
|
354 | QObject::connect(this,SIGNAL(countChanged()),d,SIGNAL(countChanged())); | |||
354 | } |
|
355 | } | |
355 |
|
356 | |||
356 | /*! |
|
357 | /*! | |
@@ -412,13 +413,6 bool QPieSeries::append(QList<QPieSlice*> slices) | |||||
412 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
413 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
413 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
414 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
414 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
415 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
415 |
|
||||
416 | connect(s, SIGNAL(labelChanged()), d, SLOT(updateLegendProperties())); |
|
|||
417 | connect(s, SIGNAL(penChanged()), d, SLOT(updateLegendProperties())); |
|
|||
418 | connect(s, SIGNAL(brushChanged()), d, SLOT(updateLegendProperties())); |
|
|||
419 | connect(s, SIGNAL(labelBrushChanged()), d, SLOT(updateLegendProperties())); |
|
|||
420 | connect(s, SIGNAL(labelFontChanged()), d, SLOT(updateLegendProperties())); |
|
|||
421 | connect(s, SIGNAL(labelFontChanged()), d, SLOT(updateLegendProperties())); |
|
|||
422 | } |
|
416 | } | |
423 |
|
417 | |||
424 | emit added(slices); |
|
418 | emit added(slices); | |
@@ -478,12 +472,6 bool QPieSeries::insert(int index, QPieSlice* slice) | |||||
478 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
472 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
479 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
473 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
480 |
|
474 | |||
481 | connect(slice, SIGNAL(labelChanged()), d, SLOT(updateLegendProperties())); |
|
|||
482 | connect(slice, SIGNAL(penChanged()), d, SLOT(updateLegendProperties())); |
|
|||
483 | connect(slice, SIGNAL(brushChanged()), d, SLOT(updateLegendProperties())); |
|
|||
484 | connect(slice, SIGNAL(labelBrushChanged()), d, SLOT(updateLegendProperties())); |
|
|||
485 | connect(slice, SIGNAL(labelFontChanged()), d, SLOT(updateLegendProperties())); |
|
|||
486 | connect(slice, SIGNAL(labelFontChanged()), d, SLOT(updateLegendProperties())); |
|
|||
487 |
|
475 | |||
488 | emit added(QList<QPieSlice*>() << slice); |
|
476 | emit added(QList<QPieSlice*>() << slice); | |
489 | emit countChanged(); |
|
477 | emit countChanged(); | |
@@ -846,13 +834,6 void QPieSeriesPrivate::sliceHovered(bool state) | |||||
846 | emit q->hovered(slice, state); |
|
834 | emit q->hovered(slice, state); | |
847 | } |
|
835 | } | |
848 |
|
836 | |||
849 | void QPieSeriesPrivate::updateLegendProperties() |
|
|||
850 | { |
|
|||
851 | // This slot listens to all properties of slices, which may interest legend and signals it. |
|
|||
852 | Q_Q(QPieSeries); |
|
|||
853 | emit legendPropertiesUpdated(q); |
|
|||
854 | } |
|
|||
855 |
|
||||
856 | void QPieSeriesPrivate::scaleDomain(Domain& domain) |
|
837 | void QPieSeriesPrivate::scaleDomain(Domain& domain) | |
857 | { |
|
838 | { | |
858 | Q_UNUSED(domain); |
|
839 | Q_UNUSED(domain); |
@@ -67,7 +67,6 public Q_SLOTS: | |||||
67 | void sliceValueChanged(); |
|
67 | void sliceValueChanged(); | |
68 | void sliceClicked(); |
|
68 | void sliceClicked(); | |
69 | void sliceHovered(bool state); |
|
69 | void sliceHovered(bool state); | |
70 | void updateLegendProperties(); |
|
|||
71 |
|
70 | |||
72 | private: |
|
71 | private: | |
73 | QList<QPieSlice*> m_slices; |
|
72 | QList<QPieSlice*> m_slices; |
@@ -56,7 +56,7 public: | |||||
56 | virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation) const = 0; |
|
56 | virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation) const = 0; | |
57 |
|
57 | |||
58 | Q_SIGNALS: |
|
58 | Q_SIGNALS: | |
59 | void legendPropertiesUpdated(QAbstractSeries* series); |
|
59 | void countChanged(); | |
60 |
|
60 | |||
61 | protected: |
|
61 | protected: | |
62 | QAbstractSeries *q_ptr; |
|
62 | QAbstractSeries *q_ptr; | |
@@ -68,6 +68,7 protected: | |||||
68 |
|
68 | |||
69 | friend class QAbstractSeries; |
|
69 | friend class QAbstractSeries; | |
70 | friend class ChartDataSet; |
|
70 | friend class ChartDataSet; | |
|
71 | friend class QLegendPrivate; | |||
71 | }; |
|
72 | }; | |
72 |
|
73 | |||
73 | QTCOMMERCIALCHART_END_NAMESPACE |
|
74 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now