@@ -1,134 +1,137 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qxylegendmarker.h" |
|
22 | 22 | #include "qxylegendmarker_p.h" |
|
23 | 23 | #include "qxyseries_p.h" |
|
24 | 24 | #include <QXYSeries> |
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | /*! |
|
29 | 29 | \class QXYLegendMarker |
|
30 | 30 | \brief QXYLegendMarker object |
|
31 | 31 | \mainclass |
|
32 | 32 | |
|
33 | 33 | QXYLegendMarker is related to QXYSeries derived classes. Each marker is related to one series. |
|
34 | 34 | |
|
35 | 35 | \sa QLegend QXYSeries QSplineSeries QScatterSeries QLineSeries |
|
36 | 36 | */ |
|
37 | 37 | |
|
38 | 38 | /*! |
|
39 | 39 | \fn virtual LegendMarkerType QXYLegendMarker::type() |
|
40 | 40 | Returns QLegendMarker::LegendMarkerTypeXY |
|
41 | 41 | */ |
|
42 | 42 | |
|
43 | 43 | /*! |
|
44 | 44 | \internal |
|
45 | 45 | */ |
|
46 | 46 | QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) : |
|
47 | 47 | QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent) |
|
48 | 48 | { |
|
49 | 49 | d_ptr->updated(); |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | /*! |
|
53 | 53 | Destructor |
|
54 | 54 | */ |
|
55 | 55 | QXYLegendMarker::~QXYLegendMarker() |
|
56 | 56 | { |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \internal |
|
61 | 61 | */ |
|
62 | 62 | QXYLegendMarker::QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent) : |
|
63 | 63 | QLegendMarker(d, parent) |
|
64 | 64 | { |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | /*! |
|
68 | 68 | Returns the related series |
|
69 | 69 | */ |
|
70 | 70 | QXYSeries* QXYLegendMarker::series() |
|
71 | 71 | { |
|
72 | 72 | Q_D(QXYLegendMarker); |
|
73 | 73 | return d->m_series; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 | 77 | |
|
78 | 78 | QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) : |
|
79 | 79 | QLegendMarkerPrivate(q,legend), |
|
80 | 80 | q_ptr(q), |
|
81 | 81 | m_series(series) |
|
82 | 82 | { |
|
83 | 83 | QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); |
|
84 | 84 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated())); |
|
85 | 85 | } |
|
86 | 86 | |
|
87 | 87 | QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate() |
|
88 | 88 | { |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | QAbstractSeries* QXYLegendMarkerPrivate::series() |
|
92 | 92 | { |
|
93 | 93 | return m_series; |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | QObject* QXYLegendMarkerPrivate::relatedObject() |
|
97 | 97 | { |
|
98 | 98 | return m_series; |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | void QXYLegendMarkerPrivate::updated() |
|
102 | 102 | { |
|
103 | 103 | bool labelChanged = false; |
|
104 | 104 | bool brushChanged = false; |
|
105 | 105 | |
|
106 | 106 | if (!m_customLabel && (m_item->label() != m_series->name())) { |
|
107 | 107 | m_item->setLabel(m_series->name()); |
|
108 | 108 | labelChanged = true; |
|
109 | 109 | } |
|
110 | 110 | |
|
111 | 111 | if (m_series->type()== QAbstractSeries::SeriesTypeScatter) { |
|
112 | 112 | if (!m_customBrush && (m_item->brush() != m_series->brush())) { |
|
113 | 113 | m_item->setBrush(m_series->brush()); |
|
114 | 114 | brushChanged = true; |
|
115 | 115 | } |
|
116 | 116 | } else { |
|
117 | if (!m_customBrush && (m_item->brush().color() != m_series->pen().color())) { | |
|
117 | QBrush emptyBrush; | |
|
118 | if (!m_customBrush | |
|
119 | && (m_item->brush() == emptyBrush | |
|
120 | || m_item->brush().color() != m_series->pen().color())) { | |
|
118 | 121 | m_item->setBrush(QBrush(m_series->pen().color())); |
|
119 | 122 | brushChanged = true; |
|
120 | 123 | } |
|
121 | 124 | } |
|
122 | 125 | invalidateLegend(); |
|
123 | 126 | |
|
124 | 127 | if (labelChanged) |
|
125 | 128 | emit q_ptr->labelChanged(); |
|
126 | 129 | if (brushChanged) |
|
127 | 130 | emit q_ptr->brushChanged(); |
|
128 | 131 | } |
|
129 | 132 | |
|
130 | 133 | #include "moc_qxylegendmarker.cpp" |
|
131 | 134 | #include "moc_qxylegendmarker_p.cpp" |
|
132 | 135 | |
|
133 | 136 | QTCOMMERCIALCHART_END_NAMESPACE |
|
134 | 137 |
General Comments 0
You need to be logged in to leave comments.
Login now