@@ -103,11 +103,11 void QAreaLegendMarkerPrivate::updated() | |||||
103 | bool labelChanged = false; |
|
103 | bool labelChanged = false; | |
104 | bool brushChanged = false; |
|
104 | bool brushChanged = false; | |
105 |
|
105 | |||
106 | if (m_item->brush() != m_series->brush()) { |
|
106 | if (!m_customBrush && (m_item->brush() != m_series->brush())) { | |
107 | m_item->setBrush(m_series->brush()); |
|
107 | m_item->setBrush(m_series->brush()); | |
108 | brushChanged = true; |
|
108 | brushChanged = true; | |
109 | } |
|
109 | } | |
110 | if (m_item->label() != m_series->name()) { |
|
110 | if (!m_customLabel && (m_item->label() != m_series->name())) { | |
111 | m_item->setLabel(m_series->name()); |
|
111 | m_item->setLabel(m_series->name()); | |
112 | labelChanged = true; |
|
112 | labelChanged = true; | |
113 | } |
|
113 | } |
@@ -116,15 +116,15 void QBarLegendMarkerPrivate::updated() | |||||
116 | bool brushChanged = false; |
|
116 | bool brushChanged = false; | |
117 | bool penChanged = false; |
|
117 | bool penChanged = false; | |
118 |
|
118 | |||
119 | if (m_item->pen() != m_barset->pen()) { |
|
119 | if (!m_customPen && (m_item->pen() != m_barset->pen())) { | |
120 | m_item->setPen(m_barset->pen()); |
|
120 | m_item->setPen(m_barset->pen()); | |
121 | penChanged = true; |
|
121 | penChanged = true; | |
122 | } |
|
122 | } | |
123 | if (m_item->brush() != m_barset->brush()) { |
|
123 | if (!m_customBrush && (m_item->brush() != m_barset->brush())) { | |
124 | m_item->setBrush(m_barset->brush()); |
|
124 | m_item->setBrush(m_barset->brush()); | |
125 | brushChanged = true; |
|
125 | brushChanged = true; | |
126 | } |
|
126 | } | |
127 | if (m_item->label() != m_barset->label()) { |
|
127 | if (!m_customLabel && (m_item->label() != m_barset->label())) { | |
128 | m_item->setLabel(m_barset->label()); |
|
128 | m_item->setLabel(m_barset->label()); | |
129 | labelChanged = true; |
|
129 | labelChanged = true; | |
130 | } |
|
130 | } |
@@ -168,7 +168,12 QString QLegendMarker::label() const | |||||
168 | */ |
|
168 | */ | |
169 | void QLegendMarker::setLabel(const QString &label) |
|
169 | void QLegendMarker::setLabel(const QString &label) | |
170 | { |
|
170 | { | |
171 | d_ptr->m_item->setLabel(label); |
|
171 | if (label.isEmpty()) { | |
|
172 | d_ptr->m_customLabel = false; | |||
|
173 | } else { | |||
|
174 | d_ptr->m_customLabel = true; | |||
|
175 | d_ptr->m_item->setLabel(label); | |||
|
176 | } | |||
172 | } |
|
177 | } | |
173 | /*! |
|
178 | /*! | |
174 | Returns the brush which is used to draw label. |
|
179 | Returns the brush which is used to draw label. | |
@@ -215,7 +220,12 QPen QLegendMarker::pen() const | |||||
215 | */ |
|
220 | */ | |
216 | void QLegendMarker::setPen(const QPen &pen) |
|
221 | void QLegendMarker::setPen(const QPen &pen) | |
217 | { |
|
222 | { | |
218 | d_ptr->m_item->setPen(pen); |
|
223 | if (pen == QPen(Qt::NoPen)) { | |
|
224 | d_ptr->m_customPen = false; | |||
|
225 | } else { | |||
|
226 | d_ptr->m_customPen = true; | |||
|
227 | d_ptr->m_item->setPen(pen); | |||
|
228 | } | |||
219 | } |
|
229 | } | |
220 |
|
230 | |||
221 | /*! |
|
231 | /*! | |
@@ -231,7 +241,12 QBrush QLegendMarker::brush() const | |||||
231 | */ |
|
241 | */ | |
232 | void QLegendMarker::setBrush(const QBrush &brush) |
|
242 | void QLegendMarker::setBrush(const QBrush &brush) | |
233 | { |
|
243 | { | |
234 | d_ptr->m_item->setBrush(brush); |
|
244 | if (brush == QBrush(Qt::NoBrush)) { | |
|
245 | d_ptr->m_customBrush = false; | |||
|
246 | } else { | |||
|
247 | d_ptr->m_customBrush = true; | |||
|
248 | d_ptr->m_item->setBrush(brush); | |||
|
249 | } | |||
235 | } |
|
250 | } | |
236 |
|
251 | |||
237 | /*! |
|
252 | /*! | |
@@ -253,6 +268,9 void QLegendMarker::setVisible(bool visible) | |||||
253 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
268 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
254 | QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) : |
|
269 | QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) : | |
255 | m_legend(legend), |
|
270 | m_legend(legend), | |
|
271 | m_customLabel(false), | |||
|
272 | m_customBrush(false), | |||
|
273 | m_customPen(false), | |||
256 | q_ptr(q) |
|
274 | q_ptr(q) | |
257 | { |
|
275 | { | |
258 | m_item = new LegendMarkerItem(this); |
|
276 | m_item = new LegendMarkerItem(this); |
@@ -73,6 +73,9 public Q_SLOTS: | |||||
73 | protected: |
|
73 | protected: | |
74 | LegendMarkerItem *m_item; |
|
74 | LegendMarkerItem *m_item; | |
75 | QLegend *m_legend; |
|
75 | QLegend *m_legend; | |
|
76 | bool m_customLabel; | |||
|
77 | bool m_customBrush; | |||
|
78 | bool m_customPen; | |||
76 |
|
79 | |||
77 | private: |
|
80 | private: | |
78 | QLegendMarker *q_ptr; |
|
81 | QLegendMarker *q_ptr; |
@@ -115,15 +115,15 void QPieLegendMarkerPrivate::updated() | |||||
115 | bool brushChanged = false; |
|
115 | bool brushChanged = false; | |
116 | bool penChanged = false; |
|
116 | bool penChanged = false; | |
117 |
|
117 | |||
118 | if (m_item->pen() != m_slice->pen()) { |
|
118 | if (!m_customPen && (m_item->pen() != m_slice->pen())) { | |
119 | m_item->setPen(m_slice->pen()); |
|
119 | m_item->setPen(m_slice->pen()); | |
120 | penChanged = true; |
|
120 | penChanged = true; | |
121 | } |
|
121 | } | |
122 | if (m_item->brush() != m_slice->brush()) { |
|
122 | if (!m_customBrush && (m_item->brush() != m_slice->brush())) { | |
123 | m_item->setBrush(m_slice->brush()); |
|
123 | m_item->setBrush(m_slice->brush()); | |
124 | brushChanged = true; |
|
124 | brushChanged = true; | |
125 | } |
|
125 | } | |
126 | if (m_item->label() != m_slice->label()) { |
|
126 | if (!m_customLabel && (m_item->label() != m_slice->label())) { | |
127 | m_item->setLabel(m_slice->label()); |
|
127 | m_item->setLabel(m_slice->label()); | |
128 | labelChanged = true; |
|
128 | labelChanged = true; | |
129 | } |
|
129 | } |
@@ -103,18 +103,18 void QXYLegendMarkerPrivate::updated() | |||||
103 | bool labelChanged = false; |
|
103 | bool labelChanged = false; | |
104 | bool brushChanged = false; |
|
104 | bool brushChanged = false; | |
105 |
|
105 | |||
106 | if (m_item->label() != m_series->name()) { |
|
106 | if (!m_customLabel && (m_item->label() != m_series->name())) { | |
107 | m_item->setLabel(m_series->name()); |
|
107 | m_item->setLabel(m_series->name()); | |
108 | labelChanged = true; |
|
108 | labelChanged = true; | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | if (m_series->type()== QAbstractSeries::SeriesTypeScatter) { |
|
111 | if (m_series->type()== QAbstractSeries::SeriesTypeScatter) { | |
112 | if (m_item->brush() != m_series->brush()) { |
|
112 | if (!m_customBrush && (m_item->brush() != m_series->brush())) { | |
113 | m_item->setBrush(m_series->brush()); |
|
113 | m_item->setBrush(m_series->brush()); | |
114 | brushChanged = true; |
|
114 | brushChanged = true; | |
115 | } |
|
115 | } | |
116 | } else { |
|
116 | } else { | |
117 | if (m_item->brush().color() != m_series->pen().color()) { |
|
117 | if (!m_customBrush && (m_item->brush().color() != m_series->pen().color())) { | |
118 | m_item->setBrush(QBrush(m_series->pen().color())); |
|
118 | m_item->setBrush(QBrush(m_series->pen().color())); | |
119 | brushChanged = true; |
|
119 | brushChanged = true; | |
120 | } |
|
120 | } |
General Comments 0
You need to be logged in to leave comments.
Login now