##// END OF EJS Templates
fix to QTRD-1674: layout is not calculated correctly after the change in the text of legend marker
sauimone -
r2194:659ade794246
parent child
Show More
@@ -1,85 +1,86
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qarealegendmarker.h"
21 #include "qarealegendmarker.h"
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
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) :
28 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) :
29 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
29 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
30 {
30 {
31 }
31 }
32
32
33 QAreaLegendMarker::~QAreaLegendMarker()
33 QAreaLegendMarker::~QAreaLegendMarker()
34 {
34 {
35 }
35 }
36
36
37 /*!
37 /*!
38 \internal
38 \internal
39 */
39 */
40 QAreaLegendMarker::QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent) :
40 QAreaLegendMarker::QAreaLegendMarker(QAreaLegendMarkerPrivate &d, QObject *parent) :
41 QLegendMarker(d, parent)
41 QLegendMarker(d, parent)
42 {
42 {
43 }
43 }
44
44
45 QAreaSeries* QAreaLegendMarker::series()
45 QAreaSeries* QAreaLegendMarker::series()
46 {
46 {
47 Q_D(QAreaLegendMarker);
47 Q_D(QAreaLegendMarker);
48 return d->m_series;
48 return d->m_series;
49 }
49 }
50
50
51 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52
52
53 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
53 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
54 QLegendMarkerPrivate(q,legend),
54 QLegendMarkerPrivate(q,legend),
55 m_series(series)
55 m_series(series)
56 {
56 {
57 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
57 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
58 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
58 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
59 updated();
59 updated();
60 }
60 }
61
61
62 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
62 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
63 {
63 {
64 }
64 }
65
65
66 QAreaSeries* QAreaLegendMarkerPrivate::series()
66 QAreaSeries* QAreaLegendMarkerPrivate::series()
67 {
67 {
68 return m_series;
68 return m_series;
69 }
69 }
70
70
71 QObject* QAreaLegendMarkerPrivate::relatedObject()
71 QObject* QAreaLegendMarkerPrivate::relatedObject()
72 {
72 {
73 return m_series;
73 return m_series;
74 }
74 }
75
75
76 void QAreaLegendMarkerPrivate::updated()
76 void QAreaLegendMarkerPrivate::updated()
77 {
77 {
78 m_item->setBrush(m_series->brush());
78 m_item->setBrush(m_series->brush());
79 m_item->setLabel(m_series->name());
79 m_item->setLabel(m_series->name());
80 invalidateLegend();
80 }
81 }
81
82
82 #include "moc_qarealegendmarker.cpp"
83 #include "moc_qarealegendmarker.cpp"
83 #include "moc_qarealegendmarker_p.cpp"
84 #include "moc_qarealegendmarker_p.cpp"
84
85
85 QTCOMMERCIALCHART_END_NAMESPACE
86 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,95 +1,96
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qbarlegendmarker.h"
21 #include "qbarlegendmarker.h"
22 #include "qbarlegendmarker_p.h"
22 #include "qbarlegendmarker_p.h"
23 #include <QAbstractBarSeries>
23 #include <QAbstractBarSeries>
24 #include <QBarSet>
24 #include <QBarSet>
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) :
28 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) :
29 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
29 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
30 {
30 {
31 }
31 }
32
32
33 QBarLegendMarker::~QBarLegendMarker()
33 QBarLegendMarker::~QBarLegendMarker()
34 {
34 {
35 }
35 }
36
36
37 /*!
37 /*!
38 \internal
38 \internal
39 */
39 */
40 QBarLegendMarker::QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent) :
40 QBarLegendMarker::QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent) :
41 QLegendMarker(d, parent)
41 QLegendMarker(d, parent)
42 {
42 {
43 }
43 }
44
44
45 QAbstractBarSeries *QBarLegendMarker::series()
45 QAbstractBarSeries *QBarLegendMarker::series()
46 {
46 {
47 Q_D(QBarLegendMarker);
47 Q_D(QBarLegendMarker);
48 return d->m_series;
48 return d->m_series;
49 }
49 }
50
50
51 QBarSet* QBarLegendMarker::barset()
51 QBarSet* QBarLegendMarker::barset()
52 {
52 {
53 Q_D(QBarLegendMarker);
53 Q_D(QBarLegendMarker);
54 return d->m_barset;
54 return d->m_barset;
55 }
55 }
56
56
57 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58
58
59 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
59 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
60 QLegendMarkerPrivate(q,legend),
60 QLegendMarkerPrivate(q,legend),
61 m_series(series),
61 m_series(series),
62 m_barset(barset)
62 m_barset(barset)
63 {
63 {
64 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
64 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
65 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
65 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
66 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
66 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
67 updated();
67 updated();
68 }
68 }
69
69
70 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
70 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
71 {
71 {
72 }
72 }
73
73
74 QAbstractBarSeries* QBarLegendMarkerPrivate::series()
74 QAbstractBarSeries* QBarLegendMarkerPrivate::series()
75 {
75 {
76 return m_series;
76 return m_series;
77 }
77 }
78
78
79 QObject* QBarLegendMarkerPrivate::relatedObject()
79 QObject* QBarLegendMarkerPrivate::relatedObject()
80 {
80 {
81 return m_barset;
81 return m_barset;
82 }
82 }
83
83
84 void QBarLegendMarkerPrivate::updated()
84 void QBarLegendMarkerPrivate::updated()
85 {
85 {
86 m_item->setPen(m_barset->pen());
86 m_item->setPen(m_barset->pen());
87 m_item->setBrush(m_barset->brush());
87 m_item->setBrush(m_barset->brush());
88 m_item->setLabel(m_barset->label());
88 m_item->setLabel(m_barset->label());
89 invalidateLegend();
89 }
90 }
90
91
91 #include "moc_qbarlegendmarker.cpp"
92 #include "moc_qbarlegendmarker.cpp"
92 #include "moc_qbarlegendmarker_p.cpp"
93 #include "moc_qbarlegendmarker_p.cpp"
93
94
94 QTCOMMERCIALCHART_END_NAMESPACE
95 QTCOMMERCIALCHART_END_NAMESPACE
95
96
@@ -1,109 +1,110
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QLEGEND_H
21 #ifndef QLEGEND_H
22 #define QLEGEND_H
22 #define QLEGEND_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <QGraphicsWidget>
25 #include <QGraphicsWidget>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QChart;
31 class QChart;
32 class QLegendPrivate;
32 class QLegendPrivate;
33 class QLegendMarker;
33 class QLegendMarker;
34 class QAbstractSeries;
34 class QAbstractSeries;
35
35
36 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget
36 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
39 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
40 Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
40 Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
41 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
41 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
42 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
42 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
43 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
43 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
44 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
44 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged)
45
45
46 private:
46 private:
47 explicit QLegend(QChart *chart);
47 explicit QLegend(QChart *chart);
48
48
49 public:
49 public:
50 ~QLegend();
50 ~QLegend();
51
51
52 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
52 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
53
53
54 void setBrush(const QBrush &brush);
54 void setBrush(const QBrush &brush);
55 QBrush brush() const;
55 QBrush brush() const;
56 void setColor(QColor color);
56 void setColor(QColor color);
57 QColor color();
57 QColor color();
58
58
59 void setPen(const QPen &pen);
59 void setPen(const QPen &pen);
60 QPen pen() const;
60 QPen pen() const;
61 void setBorderColor(QColor color);
61 void setBorderColor(QColor color);
62 QColor borderColor();
62 QColor borderColor();
63
63
64 void setFont(const QFont &font);
64 void setFont(const QFont &font);
65 QFont font() const;
65 QFont font() const;
66 void setLabelBrush(const QBrush &brush);
66 void setLabelBrush(const QBrush &brush);
67 QBrush labelBrush() const;
67 QBrush labelBrush() const;
68
68
69 void setLabelColor(QColor color);
69 void setLabelColor(QColor color);
70 QColor labelColor() const;
70 QColor labelColor() const;
71
71
72 void setAlignment(Qt::Alignment alignment);
72 void setAlignment(Qt::Alignment alignment);
73 Qt::Alignment alignment() const;
73 Qt::Alignment alignment() const;
74
74
75 void detachFromChart();
75 void detachFromChart();
76 void attachToChart();
76 void attachToChart();
77 bool isAttachedToChart();
77 bool isAttachedToChart();
78
78
79 void setBackgroundVisible(bool visible = true);
79 void setBackgroundVisible(bool visible = true);
80 bool isBackgroundVisible() const;
80 bool isBackgroundVisible() const;
81
81
82 // New stuff:
82 // New stuff:
83 QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const;
83 QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const;
84 void addSeries(QAbstractSeries *series);
84 void addSeries(QAbstractSeries *series);
85 void removeSeries(QAbstractSeries *series);
85 void removeSeries(QAbstractSeries *series);
86
86
87 protected:
87 protected:
88 void hideEvent(QHideEvent *event);
88 void hideEvent(QHideEvent *event);
89 void showEvent(QShowEvent *event);
89 void showEvent(QShowEvent *event);
90
90
91 Q_SIGNALS:
91 Q_SIGNALS:
92 void backgroundVisibleChanged(bool visible);
92 void backgroundVisibleChanged(bool visible);
93 void colorChanged(QColor color);
93 void colorChanged(QColor color);
94 void borderColorChanged(QColor color);
94 void borderColorChanged(QColor color);
95 void fontChanged(QFont font);
95 void fontChanged(QFont font);
96 void labelColorChanged(QColor color);
96 void labelColorChanged(QColor color);
97
97
98 private:
98 private:
99 QScopedPointer<QLegendPrivate> d_ptr;
99 QScopedPointer<QLegendPrivate> d_ptr;
100 Q_DISABLE_COPY(QLegend)
100 Q_DISABLE_COPY(QLegend)
101 friend class LegendScroller;
101 friend class LegendScroller;
102 friend class LegendLayout;
102 friend class LegendLayout;
103 friend class ChartLayout;
103 friend class ChartLayout;
104 friend class LegendMarkerItem;
104 friend class LegendMarkerItem;
105 friend class QLegendMarkerPrivate;
105 };
106 };
106
107
107 QTCOMMERCIALCHART_END_NAMESPACE
108 QTCOMMERCIALCHART_END_NAMESPACE
108
109
109 #endif // QLEGEND_H
110 #endif // QLEGEND_H
@@ -1,100 +1,101
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLEGEND_P_H
30 #ifndef QLEGEND_P_H
31 #define QLEGEND_P_H
31 #define QLEGEND_P_H
32
32
33 #include "qlegend.h"
33 #include "qlegend.h"
34 #include "scroller_p.h"
34 #include "scroller_p.h"
35
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
37
38 class QChart;
38 class QChart;
39 class ChartPresenter;
39 class ChartPresenter;
40 class QAbstractSeries;
40 class QAbstractSeries;
41 class LegendLayout;
41 class LegendLayout;
42 class Domain;
42 class Domain;
43 class QLegendMarker;
43 class QLegendMarker;
44
44
45 class QLegendPrivate : public QObject, public Scroller
45 class QLegendPrivate : public QObject, public Scroller
46 {
46 {
47 Q_OBJECT
47 Q_OBJECT
48 public:
48 public:
49 QLegendPrivate(ChartPresenter *presenter, QChart *chart, QLegend *q);
49 QLegendPrivate(ChartPresenter *presenter, QChart *chart, QLegend *q);
50 ~QLegendPrivate();
50 ~QLegendPrivate();
51
51
52 void setOffset(const QPointF &offset);
52 void setOffset(const QPointF &offset);
53 QPointF offset() const;
53 QPointF offset() const;
54 int roundness(qreal size);
54 int roundness(qreal size);
55
55
56 QGraphicsItemGroup* items() { return m_items; }
56 QGraphicsItemGroup* items() { return m_items; }
57
57
58 QList<QLegendMarker*> markers(QAbstractSeries *series = 0);
58 QList<QLegendMarker*> markers(QAbstractSeries *series = 0);
59 void addSeries(QAbstractSeries *series);
59 void addSeries(QAbstractSeries *series);
60 void removeSeries(QAbstractSeries *series);
60 void removeSeries(QAbstractSeries *series);
61
61
62 public Q_SLOTS:
62 public Q_SLOTS:
63 void handleSeriesAdded(QAbstractSeries *series);
63 void handleSeriesAdded(QAbstractSeries *series);
64 void handleSeriesRemoved(QAbstractSeries *series);
64 void handleSeriesRemoved(QAbstractSeries *series);
65 void handleSeriesVisibleChanged();
65 void handleSeriesVisibleChanged();
66 void handleCountChanged();
66 void handleCountChanged();
67
67
68 private:
68 private:
69 // Internal helpers
69 // Internal helpers
70 void addMarkers(QList<QLegendMarker *> markers);
70 void addMarkers(QList<QLegendMarker *> markers);
71 void removeMarkers(QList<QLegendMarker *> markers);
71 void removeMarkers(QList<QLegendMarker *> markers);
72 void decorateMarkers(QList<QLegendMarker *> markers);
72 void decorateMarkers(QList<QLegendMarker *> markers);
73
73
74 private:
74 private:
75 QLegend *q_ptr;
75 QLegend *q_ptr;
76 ChartPresenter *m_presenter;
76 ChartPresenter *m_presenter;
77 LegendLayout *m_layout;
77 LegendLayout *m_layout;
78 QChart *m_chart;
78 QChart *m_chart;
79 QGraphicsItemGroup *m_items;
79 QGraphicsItemGroup *m_items;
80 Qt::Alignment m_alignment;
80 Qt::Alignment m_alignment;
81 QBrush m_brush;
81 QBrush m_brush;
82 QPen m_pen;
82 QPen m_pen;
83 QFont m_font;
83 QFont m_font;
84 QBrush m_labelBrush;
84 QBrush m_labelBrush;
85
85
86 qreal m_diameter;
86 qreal m_diameter;
87 bool m_attachedToChart;
87 bool m_attachedToChart;
88 bool m_backgroundVisible;
88 bool m_backgroundVisible;
89
89
90 QList<QLegendMarker *> m_markers;
90 QList<QLegendMarker *> m_markers;
91 QList<QAbstractSeries *> m_series;
91 QList<QAbstractSeries *> m_series;
92
92
93 friend class QLegend;
93 friend class QLegend;
94 friend class LegendMarkerItem;
94 friend class LegendMarkerItem;
95 friend class LegendLayout;
95 friend class LegendLayout;
96 friend class QLegendMarkerPrivate;
96 };
97 };
97
98
98 QTCOMMERCIALCHART_END_NAMESPACE
99 QTCOMMERCIALCHART_END_NAMESPACE
99
100
100 #endif
101 #endif
@@ -1,119 +1,127
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qlegendmarker.h"
21 #include "qlegendmarker.h"
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 "qlegend_p.h"
26 #include "legendlayout_p.h"
25 #include <QFontMetrics>
27 #include <QFontMetrics>
26 #include <QGraphicsSceneEvent>
28 #include <QGraphicsSceneEvent>
27 #include <QAbstractSeries>
29 #include <QAbstractSeries>
28
30
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
32
31 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
33 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
32 QObject(parent),
34 QObject(parent),
33 d_ptr(&d)
35 d_ptr(&d)
34 {
36 {
35 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
37 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
36 }
38 }
37
39
38 QLegendMarker::~QLegendMarker()
40 QLegendMarker::~QLegendMarker()
39 {
41 {
40 }
42 }
41
43
42 QString QLegendMarker::label() const
44 QString QLegendMarker::label() const
43 {
45 {
44 return d_ptr->m_item->label();
46 return d_ptr->m_item->label();
45 }
47 }
46
48
47 void QLegendMarker::setLabel(const QString &label)
49 void QLegendMarker::setLabel(const QString &label)
48 {
50 {
49 d_ptr->m_item->setLabel(label);
51 d_ptr->m_item->setLabel(label);
50 }
52 }
51
53
52 QBrush QLegendMarker::labelBrush() const
54 QBrush QLegendMarker::labelBrush() const
53 {
55 {
54 return d_ptr->m_item->brush();
56 return d_ptr->m_item->brush();
55 }
57 }
56
58
57 void QLegendMarker::setLabelBrush(const QBrush &brush)
59 void QLegendMarker::setLabelBrush(const QBrush &brush)
58 {
60 {
59 d_ptr->m_item->setLabelBrush(brush);
61 d_ptr->m_item->setLabelBrush(brush);
60 }
62 }
61
63
62 QFont QLegendMarker::font() const
64 QFont QLegendMarker::font() const
63 {
65 {
64 return d_ptr->m_item->font();
66 return d_ptr->m_item->font();
65 }
67 }
66
68
67 void QLegendMarker::setFont(const QFont &font)
69 void QLegendMarker::setFont(const QFont &font)
68 {
70 {
69 d_ptr->m_item->setFont(font);
71 d_ptr->m_item->setFont(font);
70 }
72 }
71
73
72 QPen QLegendMarker::pen() const
74 QPen QLegendMarker::pen() const
73 {
75 {
74 return d_ptr->m_item->pen();
76 return d_ptr->m_item->pen();
75 }
77 }
76
78
77 void QLegendMarker::setPen(const QPen &pen)
79 void QLegendMarker::setPen(const QPen &pen)
78 {
80 {
79 d_ptr->m_item->setPen(pen);
81 d_ptr->m_item->setPen(pen);
80 }
82 }
81
83
82 QBrush QLegendMarker::brush() const
84 QBrush QLegendMarker::brush() const
83 {
85 {
84 return d_ptr->m_item->brush();
86 return d_ptr->m_item->brush();
85 }
87 }
86
88
87 void QLegendMarker::setBrush(const QBrush &brush)
89 void QLegendMarker::setBrush(const QBrush &brush)
88 {
90 {
89 d_ptr->m_item->setBrush(brush);
91 d_ptr->m_item->setBrush(brush);
90 }
92 }
91
93
92 bool QLegendMarker::isVisible() const
94 bool QLegendMarker::isVisible() const
93 {
95 {
94 return d_ptr->m_item->isVisible();
96 return d_ptr->m_item->isVisible();
95 }
97 }
96
98
97 void QLegendMarker::setVisible(bool visible)
99 void QLegendMarker::setVisible(bool visible)
98 {
100 {
99 d_ptr->m_item->setVisible(visible);
101 d_ptr->m_item->setVisible(visible);
100 }
102 }
101
103
102 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
104 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
103 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
105 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
104 q_ptr(q),
106 q_ptr(q),
105 m_legend(legend)
107 m_legend(legend)
106 {
108 {
107 m_item = new LegendMarkerItem(this);
109 m_item = new LegendMarkerItem(this);
108 // m_item->setVisible(q->series()->isVisible());
110 // m_item->setVisible(q->series()->isVisible());
109 }
111 }
110
112
111 QLegendMarkerPrivate::~QLegendMarkerPrivate()
113 QLegendMarkerPrivate::~QLegendMarkerPrivate()
112 {
114 {
113 }
115 }
114
116
117 void QLegendMarkerPrivate::invalidateLegend()
118 {
119 m_legend->d_ptr->m_layout->invalidate();
120 }
121
122
115
123
116 #include "moc_qlegendmarker.cpp"
124 #include "moc_qlegendmarker.cpp"
117 #include "moc_qlegendmarker_p.cpp"
125 #include "moc_qlegendmarker_p.cpp"
118
126
119 QTCOMMERCIALCHART_END_NAMESPACE
127 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,85 +1,87
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLEGENDMARKERPRIVATE_H
30 #ifndef QLEGENDMARKERPRIVATE_H
31 #define QLEGENDMARKERPRIVATE_H
31 #define QLEGENDMARKERPRIVATE_H
32
32
33 #include "qchartglobal.h"
33 #include "qchartglobal.h"
34 #include <QGraphicsObject>
34 #include <QGraphicsObject>
35 #include <QBrush>
35 #include <QBrush>
36 #include <QPen>
36 #include <QPen>
37 #include <QGraphicsSimpleTextItem>
37 #include <QGraphicsSimpleTextItem>
38 #include <QGraphicsLayoutItem>
38 #include <QGraphicsLayoutItem>
39
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
41
42 // TODO: check these
42 // TODO: check these
43 class QAbstractSeries;
43 class QAbstractSeries;
44 class QAreaSeries;
44 class QAreaSeries;
45 class QXYSeries;
45 class QXYSeries;
46 class QBarSet;
46 class QBarSet;
47 class QAbstractBarSeries;
47 class QAbstractBarSeries;
48 class QPieSlice;
48 class QPieSlice;
49 class QLegend;
49 class QLegend;
50 class QPieSeries;
50 class QPieSeries;
51
51
52 class QLegendMarker;
52 class QLegendMarker;
53 class LegendMarkerItem;
53 class LegendMarkerItem;
54
54
55 class QLegendMarkerPrivate : public QObject
55 class QLegendMarkerPrivate : public QObject
56 {
56 {
57 Q_OBJECT
57 Q_OBJECT
58 public:
58 public:
59 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
59 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
60 virtual ~QLegendMarkerPrivate();
60 virtual ~QLegendMarkerPrivate();
61
61
62 // Helper for now. (or declare LegendLayout as friend)
62 // Helper for now. (or declare LegendLayout as friend)
63 LegendMarkerItem* item() const { return m_item; }
63 LegendMarkerItem* item() const { return m_item; }
64
64
65 virtual QAbstractSeries* series() = 0;
65 virtual QAbstractSeries* series() = 0;
66 virtual QObject* relatedObject() = 0;
66 virtual QObject* relatedObject() = 0;
67
67
68 void invalidateLegend();
69
68 public Q_SLOTS:
70 public Q_SLOTS:
69 virtual void updated() {};
71 virtual void updated() { invalidateLegend(); }
70
72
71 protected:
73 protected:
72 LegendMarkerItem *m_item;
74 LegendMarkerItem *m_item;
73 QLegend *m_legend;
75 QLegend *m_legend;
74
76
75 private:
77 private:
76 QLegendMarker *q_ptr;
78 QLegendMarker *q_ptr;
77
79
78 friend class QLegendPrivate;
80 friend class QLegendPrivate;
79 friend class LegendMarkerItem;
81 friend class LegendMarkerItem;
80 Q_DECLARE_PUBLIC(QLegendMarker)
82 Q_DECLARE_PUBLIC(QLegendMarker)
81 };
83 };
82
84
83 QTCOMMERCIALCHART_END_NAMESPACE
85 QTCOMMERCIALCHART_END_NAMESPACE
84
86
85 #endif // QLEGENDMARKERPRIVATE_H
87 #endif // QLEGENDMARKERPRIVATE_H
@@ -1,94 +1,95
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qpielegendmarker.h"
21 #include "qpielegendmarker.h"
22 #include "qpielegendmarker_p.h"
22 #include "qpielegendmarker_p.h"
23 #include <QPieSeries>
23 #include <QPieSeries>
24 #include <QPieSlice>
24 #include <QPieSlice>
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) :
28 QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) :
29 QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent)
29 QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent)
30 {
30 {
31 }
31 }
32
32
33 QPieLegendMarker::~QPieLegendMarker()
33 QPieLegendMarker::~QPieLegendMarker()
34 {
34 {
35 }
35 }
36
36
37 /*!
37 /*!
38 \internal
38 \internal
39 */
39 */
40 QPieLegendMarker::QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent) :
40 QPieLegendMarker::QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent) :
41 QLegendMarker(d, parent)
41 QLegendMarker(d, parent)
42 {
42 {
43 }
43 }
44
44
45 QPieSeries* QPieLegendMarker::series()
45 QPieSeries* QPieLegendMarker::series()
46 {
46 {
47 Q_D(QPieLegendMarker);
47 Q_D(QPieLegendMarker);
48 return d->m_series;
48 return d->m_series;
49 }
49 }
50
50
51 QPieSlice* QPieLegendMarker::slice()
51 QPieSlice* QPieLegendMarker::slice()
52 {
52 {
53 Q_D(QPieLegendMarker);
53 Q_D(QPieLegendMarker);
54 return d->m_slice;
54 return d->m_slice;
55 }
55 }
56
56
57 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58
58
59 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) :
59 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) :
60 QLegendMarkerPrivate(q,legend),
60 QLegendMarkerPrivate(q,legend),
61 m_series(series),
61 m_series(series),
62 m_slice(slice)
62 m_slice(slice)
63 {
63 {
64 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
64 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
65 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
65 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
67 updated();
67 updated();
68 }
68 }
69
69
70 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
70 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
71 {
71 {
72 }
72 }
73
73
74 QPieSeries* QPieLegendMarkerPrivate::series()
74 QPieSeries* QPieLegendMarkerPrivate::series()
75 {
75 {
76 return m_series;
76 return m_series;
77 }
77 }
78
78
79 QObject* QPieLegendMarkerPrivate::relatedObject()
79 QObject* QPieLegendMarkerPrivate::relatedObject()
80 {
80 {
81 return m_slice;
81 return m_slice;
82 }
82 }
83
83
84 void QPieLegendMarkerPrivate::updated()
84 void QPieLegendMarkerPrivate::updated()
85 {
85 {
86 m_item->setPen(m_slice->pen());
86 m_item->setPen(m_slice->pen());
87 m_item->setBrush(m_slice->brush());
87 m_item->setBrush(m_slice->brush());
88 m_item->setLabel(m_slice->label());
88 m_item->setLabel(m_slice->label());
89 invalidateLegend();
89 }
90 }
90
91
91 #include "moc_qpielegendmarker.cpp"
92 #include "moc_qpielegendmarker.cpp"
92 #include "moc_qpielegendmarker_p.cpp"
93 #include "moc_qpielegendmarker_p.cpp"
93
94
94 QTCOMMERCIALCHART_END_NAMESPACE
95 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,91 +1,92
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qxylegendmarker.h"
21 #include "qxylegendmarker.h"
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
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) :
28 QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) :
29 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
29 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
30 {
30 {
31 }
31 }
32
32
33 QXYLegendMarker::~QXYLegendMarker()
33 QXYLegendMarker::~QXYLegendMarker()
34 {
34 {
35 }
35 }
36
36
37 /*!
37 /*!
38 \internal
38 \internal
39 */
39 */
40 QXYLegendMarker::QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent) :
40 QXYLegendMarker::QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent) :
41 QLegendMarker(d, parent)
41 QLegendMarker(d, parent)
42 {
42 {
43 }
43 }
44
44
45 QXYSeries* QXYLegendMarker::series()
45 QXYSeries* QXYLegendMarker::series()
46 {
46 {
47 Q_D(QXYLegendMarker);
47 Q_D(QXYLegendMarker);
48 return d->m_series;
48 return d->m_series;
49 }
49 }
50
50
51 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52
52
53 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
53 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
54 QLegendMarkerPrivate(q,legend),
54 QLegendMarkerPrivate(q,legend),
55 m_series(series)
55 m_series(series)
56 {
56 {
57 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
57 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
58 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
58 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
59 updated();
59 updated();
60 }
60 }
61
61
62 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
62 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
63 {
63 {
64 }
64 }
65
65
66 QAbstractSeries* QXYLegendMarkerPrivate::series()
66 QAbstractSeries* QXYLegendMarkerPrivate::series()
67 {
67 {
68 return m_series;
68 return m_series;
69 }
69 }
70
70
71 QObject* QXYLegendMarkerPrivate::relatedObject()
71 QObject* QXYLegendMarkerPrivate::relatedObject()
72 {
72 {
73 return m_series;
73 return m_series;
74 }
74 }
75
75
76 void QXYLegendMarkerPrivate::updated()
76 void QXYLegendMarkerPrivate::updated()
77 {
77 {
78 m_item->setLabel(m_series->name());
78 m_item->setLabel(m_series->name());
79
79
80 if (m_series->type()== QAbstractSeries::SeriesTypeScatter) {
80 if (m_series->type()== QAbstractSeries::SeriesTypeScatter) {
81 m_item->setBrush(m_series->brush());
81 m_item->setBrush(m_series->brush());
82 } else {
82 } else {
83 m_item->setBrush(QBrush(m_series->pen().color()));
83 m_item->setBrush(QBrush(m_series->pen().color()));
84 }
84 }
85 invalidateLegend();
85 }
86 }
86
87
87 #include "moc_qxylegendmarker.cpp"
88 #include "moc_qxylegendmarker.cpp"
88 #include "moc_qxylegendmarker_p.cpp"
89 #include "moc_qxylegendmarker_p.cpp"
89
90
90 QTCOMMERCIALCHART_END_NAMESPACE
91 QTCOMMERCIALCHART_END_NAMESPACE
91
92
General Comments 0
You need to be logged in to leave comments. Login now