##// END OF EJS Templates
Fixes previous commit
Michal Klocek -
r791:0a28782b4a44
parent child
Show More
@@ -1,29 +1,28
1 #include "legendscrollbutton_p.h"
1 #include "legendscrollbutton_p.h"
2 #include "qlegend.h"
2 #include "qlegend.h"
3 #include <QGraphicsSceneEvent>
3 #include <QGraphicsSceneEvent>
4
4
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
6
7 LegendScrollButton::LegendScrollButton(ScrollButtonId id, QLegend *legend)
7 LegendScrollButton::LegendScrollButton(ScrollButtonId id, QLegend *legend)
8 : QGraphicsPolygonItem(legend),
8 : QGraphicsPolygonItem(legend),
9 m_id(id),
9 m_id(id),
10 m_ledgend(legend)
10 m_ledgend(legend)
11 {
11 {
12 setAcceptedMouseButtons(Qt::LeftButton);
12 setAcceptedMouseButtons(Qt::LeftButton);
13 }
13 }
14
14
15 LegendScrollButton::ScrollButtonId LegendScrollButton::id()
15 LegendScrollButton::ScrollButtonId LegendScrollButton::id()
16 {
16 {
17 return m_id;
17 return m_id;
18 }
18 }
19
19
20 void LegendScrollButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
20 void LegendScrollButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
21 {
21 {
22 Q_UNUSED(event);
22 Q_UNUSED(event);
23 m_ledgend->scrollButtonClicked(this);
23 m_ledgend->scrollButtonClicked(this);
24 }
24 }
25
25
26 #include "moc_legendscrollbutton_p.cpp"
27
26
28 QTCOMMERCIALCHART_END_NAMESPACE
27 QTCOMMERCIALCHART_END_NAMESPACE
29
28
@@ -1,693 +1,693
1 #include "qlegend.h"
1 #include "qlegend.h"
2 #include "qchart_p.h"
2 #include "qchart_p.h"
3 #include "qseries.h"
3 #include "qseries.h"
4 #include "legendmarker_p.h"
4 #include "legendmarker_p.h"
5 #include "legendscrollbutton_p.h"
5 #include "legendscrollbutton_p.h"
6 #include "qxyseries.h"
6 #include "qxyseries.h"
7 #include "qlineseries.h"
7 #include "qlineseries.h"
8 #include "qareaseries.h"
8 #include "qareaseries.h"
9 #include "qscatterseries.h"
9 #include "qscatterseries.h"
10 #include "qsplineseries.h"
10 #include "qsplineseries.h"
11 #include "qbarseries.h"
11 #include "qbarseries.h"
12 #include "qstackedbarseries.h"
12 #include "qstackedbarseries.h"
13 #include "qpercentbarseries.h"
13 #include "qpercentbarseries.h"
14 #include "qbarset.h"
14 #include "qbarset.h"
15 #include "qpieseries.h"
15 #include "qpieseries.h"
16 #include "qpieslice.h"
16 #include "qpieslice.h"
17 #include "chartpresenter_p.h"
17 #include "chartpresenter_p.h"
18 #include <QPainter>
18 #include <QPainter>
19 #include <QPen>
19 #include <QPen>
20
20
21 #include <QGraphicsSceneEvent>
21 #include <QGraphicsSceneEvent>
22
22
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 /*!
25 /*!
26 \class QLegend
26 \class QLegend
27 \brief part of QtCommercial chart API.
27 \brief part of QtCommercial chart API.
28
28
29 QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when
29 QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when
30 series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and
30 series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and
31 handle the drawing manually.
31 handle the drawing manually.
32 User isn't supposed to create or delete legend objects, but can reference it via QChart class.
32 User isn't supposed to create or delete legend objects, but can reference it via QChart class.
33
33
34 \mainclass
34 \mainclass
35
35
36 \sa QChart, QSeries
36 \sa QChart, QSeries
37 */
37 */
38
38
39 /*!
39 /*!
40 \enum QLegend::Layout
40 \enum QLegend::Layout
41
41
42 This enum describes the possible position for legend inside chart.
42 This enum describes the possible position for legend inside chart.
43
43
44 \value LayoutTop
44 \value LayoutTop
45 \value LayoutBottom
45 \value LayoutBottom
46 \value LayoutLeft
46 \value LayoutLeft
47 \value LayoutRight
47 \value LayoutRight
48 */
48 */
49
49
50
50
51 /*!
51 /*!
52 \fn void QLegend::clicked(QSeries* series, Qt::MouseButton button)
52 \fn void QLegend::clicked(QSeries* series, Qt::MouseButton button)
53 \brief Notifies when series has been clicked on legend \a series \a button
53 \brief Notifies when series has been clicked on legend \a series \a button
54 */
54 */
55
55
56 /*!
56 /*!
57 \fn void QLegend::clicked(QBarSet* barset, Qt::MouseButton button)
57 \fn void QLegend::clicked(QBarSet* barset, Qt::MouseButton button)
58 \brief Notifies when barset has been clicked on legend \a barset \a button
58 \brief Notifies when barset has been clicked on legend \a barset \a button
59 */
59 */
60
60
61 /*!
61 /*!
62 \fn void QLegend::clicked(QPieSlice* slice, Qt::MouseButton button)
62 \fn void QLegend::clicked(QPieSlice* slice, Qt::MouseButton button)
63 \brief Notifies when pie slice has been clicked on legend \a slice \a button
63 \brief Notifies when pie slice has been clicked on legend \a slice \a button
64 */
64 */
65
65
66 /*!
66 /*!
67 Constructs the legend object and sets the parent to \a parent
67 Constructs the legend object and sets the parent to \a parent
68 */
68 */
69 QLegend::QLegend(QChart *chart):QGraphicsWidget(chart->d_ptr->m_presenter->rootItem()),
69 QLegend::QLegend(QChart *chart):QGraphicsWidget(chart),
70 m_margin(5),
70 m_margin(5),
71 m_pos(0,0),
71 m_pos(0,0),
72 m_minimumSize(50,20), // TODO: magic numbers
72 m_minimumSize(50,20), // TODO: magic numbers
73 m_maximumSize(150,100),
73 m_maximumSize(150,100),
74 m_size(m_minimumSize),
74 m_size(m_minimumSize),
75 m_brush(Qt::darkGray), // TODO: default should come from theme
75 m_brush(Qt::darkGray), // TODO: default should come from theme
76 m_alignment(QLegend::LayoutTop),
76 m_alignment(QLegend::LayoutTop),
77 mFirstMarker(0)
77 mFirstMarker(0)
78 {
78 {
79 m_scrollButtonLeft = new LegendScrollButton(LegendScrollButton::ScrollButtonIdLeft, this);
79 m_scrollButtonLeft = new LegendScrollButton(LegendScrollButton::ScrollButtonIdLeft, this);
80 m_scrollButtonRight = new LegendScrollButton(LegendScrollButton::ScrollButtonIdRight, this);
80 m_scrollButtonRight = new LegendScrollButton(LegendScrollButton::ScrollButtonIdRight, this);
81 m_scrollButtonUp = new LegendScrollButton(LegendScrollButton::ScrollButtonIdUp, this);
81 m_scrollButtonUp = new LegendScrollButton(LegendScrollButton::ScrollButtonIdUp, this);
82 m_scrollButtonDown = new LegendScrollButton(LegendScrollButton::ScrollButtonIdDown, this);
82 m_scrollButtonDown = new LegendScrollButton(LegendScrollButton::ScrollButtonIdDown, this);
83 setZValue(ChartPresenter::LegendZValue);
83 setZValue(ChartPresenter::LegendZValue);
84 }
84 }
85
85
86 /*!
86 /*!
87 Paints the legend to given \a painter. Paremeters \a option and \a widget arent used.
87 Paints the legend to given \a painter. Paremeters \a option and \a widget arent used.
88 */
88 */
89 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
89 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
90 {
90 {
91 Q_UNUSED(option)
91 Q_UNUSED(option)
92 Q_UNUSED(widget)
92 Q_UNUSED(widget)
93
93
94 painter->setOpacity(opacity());
94 painter->setOpacity(opacity());
95 painter->setPen(m_pen);
95 painter->setPen(m_pen);
96 painter->setBrush(m_brush);
96 painter->setBrush(m_brush);
97 // painter->drawRect(boundingRect());
97 // painter->drawRect(boundingRect());
98 }
98 }
99
99
100 /*!
100 /*!
101 Bounding rect of legend.
101 Bounding rect of legend.
102 */
102 */
103 QRectF QLegend::boundingRect() const
103 QRectF QLegend::boundingRect() const
104 {
104 {
105 return QRectF(m_pos,m_size);
105 return QRectF(m_pos,m_size);
106 }
106 }
107
107
108 /*!
108 /*!
109 Sets the \a brush of legend. Brush affects the background of legend.
109 Sets the \a brush of legend. Brush affects the background of legend.
110 */
110 */
111 void QLegend::setBrush(const QBrush &brush)
111 void QLegend::setBrush(const QBrush &brush)
112 {
112 {
113 if (m_brush != brush) {
113 if (m_brush != brush) {
114 m_brush = brush;
114 m_brush = brush;
115 update();
115 update();
116 }
116 }
117 }
117 }
118
118
119 /*!
119 /*!
120 Returns the brush used by legend.
120 Returns the brush used by legend.
121 */
121 */
122 QBrush QLegend::brush() const
122 QBrush QLegend::brush() const
123 {
123 {
124 return m_brush;
124 return m_brush;
125 }
125 }
126
126
127 /*!
127 /*!
128 Sets the \a pen of legend. Pen affects the legend borders.
128 Sets the \a pen of legend. Pen affects the legend borders.
129 */
129 */
130 void QLegend::setPen(const QPen &pen)
130 void QLegend::setPen(const QPen &pen)
131 {
131 {
132 if (m_pen != pen) {
132 if (m_pen != pen) {
133 m_pen = pen;
133 m_pen = pen;
134 update();
134 update();
135 }
135 }
136 }
136 }
137
137
138 /*!
138 /*!
139 Returns the pen used by legend
139 Returns the pen used by legend
140 */
140 */
141
141
142 QPen QLegend::pen() const
142 QPen QLegend::pen() const
143 {
143 {
144 return m_pen;
144 return m_pen;
145 }
145 }
146
146
147 /*!
147 /*!
148 Sets the \a preferred layout for legend. Legend tries to paint itself on the defined position in chart.
148 Sets the \a preferred layout for legend. Legend tries to paint itself on the defined position in chart.
149 \sa QLegend::Layout
149 \sa QLegend::Layout
150 */
150 */
151 void QLegend::setAlignmnent(QLegend::Layout alignment)
151 void QLegend::setAlignmnent(QLegend::Layout alignment)
152 {
152 {
153 m_alignment = alignment;
153 m_alignment = alignment;
154 updateLayout();
154 updateLayout();
155 }
155 }
156
156
157 /*!
157 /*!
158 Returns the preferred layout for legend
158 Returns the preferred layout for legend
159 */
159 */
160 QLegend::Layout QLegend::alignment() const
160 QLegend::Layout QLegend::alignment() const
161 {
161 {
162 return m_alignment;
162 return m_alignment;
163 }
163 }
164
164
165 /*!
165 /*!
166 Returns the maximum size of legend.
166 Returns the maximum size of legend.
167 */
167 */
168 QSizeF QLegend::maximumSize() const
168 QSizeF QLegend::maximumSize() const
169 {
169 {
170 return m_maximumSize;
170 return m_maximumSize;
171 }
171 }
172
172
173 /*!
173 /*!
174 Sets the maximum \a size for legend. The legend can't grow bigger than this size. If there are
174 Sets the maximum \a size for legend. The legend can't grow bigger than this size. If there are
175 more series than legend can fit to this size, scroll buttons are displayed.
175 more series than legend can fit to this size, scroll buttons are displayed.
176 */
176 */
177 void QLegend::setMaximumSize(const QSizeF size)
177 void QLegend::setMaximumSize(const QSizeF size)
178 {
178 {
179 m_maximumSize = size;
179 m_maximumSize = size;
180 updateLayout();
180 updateLayout();
181 }
181 }
182
182
183 /*!
183 /*!
184 Returns the current size of legend.
184 Returns the current size of legend.
185 */
185 */
186 QSizeF QLegend::size() const
186 QSizeF QLegend::size() const
187 {
187 {
188 return m_size;
188 return m_size;
189 }
189 }
190
190
191 /*!
191 /*!
192 Sets the \a size of legend. If size is bigger than maximum size of legend, the legend is resized to the maximum size.
192 Sets the \a size of legend. If size is bigger than maximum size of legend, the legend is resized to the maximum size.
193 \sa setMmaximumSize()
193 \sa setMmaximumSize()
194 */
194 */
195 void QLegend::setSize(const QSizeF size)
195 void QLegend::setSize(const QSizeF size)
196 {
196 {
197 m_size = size;
197 m_size = size;
198 if (m_size.width() > m_maximumSize.width()) {
198 if (m_size.width() > m_maximumSize.width()) {
199 m_size.setWidth(m_maximumSize.width());
199 m_size.setWidth(m_maximumSize.width());
200 }
200 }
201 if (m_size.height() > m_maximumSize.height()) {
201 if (m_size.height() > m_maximumSize.height()) {
202 m_size.setHeight(m_maximumSize.height());
202 m_size.setHeight(m_maximumSize.height());
203 }
203 }
204 }
204 }
205
205
206 /*!
206 /*!
207 Sets position of legend to \a pos
207 Sets position of legend to \a pos
208 */
208 */
209 void QLegend::setPos(const QPointF &pos)
209 void QLegend::setPos(const QPointF &pos)
210 {
210 {
211 m_pos = pos;
211 m_pos = pos;
212 updateLayout();
212 updateLayout();
213 }
213 }
214
214
215 /*!
215 /*!
216 \internal \a series \a domain Should be called when series is added to chart.
216 \internal \a series \a domain Should be called when series is added to chart.
217 */
217 */
218 void QLegend::handleSeriesAdded(QSeries *series, Domain *domain)
218 void QLegend::handleSeriesAdded(QSeries *series, Domain *domain)
219 {
219 {
220 Q_UNUSED(domain)
220 Q_UNUSED(domain)
221
221
222 createMarkers(series);
222 createMarkers(series);
223 connectSeries(series);
223 connectSeries(series);
224 updateLayout();
224 updateLayout();
225 }
225 }
226
226
227 /*!
227 /*!
228 \internal \a series Should be called when series is removed from chart.
228 \internal \a series Should be called when series is removed from chart.
229 */
229 */
230 void QLegend::handleSeriesRemoved(QSeries *series)
230 void QLegend::handleSeriesRemoved(QSeries *series)
231 {
231 {
232 disconnectSeries(series);
232 disconnectSeries(series);
233
233
234 if (series->type() == QSeries::SeriesTypeArea) {
234 if (series->type() == QSeries::SeriesTypeArea) {
235 // This is special case. Area series has upper and lower series, which each have markers
235 // This is special case. Area series has upper and lower series, which each have markers
236 QAreaSeries* s = static_cast<QAreaSeries *> (series);
236 QAreaSeries* s = static_cast<QAreaSeries *> (series);
237 deleteMarkers(s->upperSeries());
237 deleteMarkers(s->upperSeries());
238 deleteMarkers(s->lowerSeries());
238 deleteMarkers(s->lowerSeries());
239 } else {
239 } else {
240 deleteMarkers(series);
240 deleteMarkers(series);
241 }
241 }
242
242
243 updateLayout();
243 updateLayout();
244 }
244 }
245
245
246 /*!
246 /*!
247 \internal \a slices Should be called when slices are added to pie chart.
247 \internal \a slices Should be called when slices are added to pie chart.
248 */
248 */
249 void QLegend::handleAdded(QList<QPieSlice *> slices)
249 void QLegend::handleAdded(QList<QPieSlice *> slices)
250 {
250 {
251 QPieSeries* series = static_cast<QPieSeries *> (sender());
251 QPieSeries* series = static_cast<QPieSeries *> (sender());
252 foreach(QPieSlice* s, slices) {
252 foreach(QPieSlice* s, slices) {
253 LegendMarker* marker = new LegendMarker(series, s, this);
253 LegendMarker* marker = new LegendMarker(series, s, this);
254 marker->setName(s->label());
254 marker->setName(s->label());
255 marker->setBrush(s->brush());
255 marker->setBrush(s->brush());
256 connect(marker, SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),
256 connect(marker, SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),
257 this, SIGNAL(clicked(QPieSlice*,Qt::MouseButton)));
257 this, SIGNAL(clicked(QPieSlice*,Qt::MouseButton)));
258 connect(s, SIGNAL(changed()), marker, SLOT(changed()));
258 connect(s, SIGNAL(changed()), marker, SLOT(changed()));
259 connect(s, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
259 connect(s, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
260 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
260 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
261 m_markers.append(marker);
261 m_markers.append(marker);
262 childItems().append(marker);
262 childItems().append(marker);
263 }
263 }
264 updateLayout();
264 updateLayout();
265 }
265 }
266
266
267 /*!
267 /*!
268 \internal \a slices Should be called when slices are removed from pie chart. Currently unused,
268 \internal \a slices Should be called when slices are removed from pie chart. Currently unused,
269 because removed slices are also deleted and we listen destroyed signal
269 because removed slices are also deleted and we listen destroyed signal
270 */
270 */
271 void QLegend::handleRemoved(QList<QPieSlice *> slices)
271 void QLegend::handleRemoved(QList<QPieSlice *> slices)
272 {
272 {
273 Q_UNUSED(slices)
273 Q_UNUSED(slices)
274 }
274 }
275
275
276
276
277 /*!
277 /*!
278 \internal Notifies legend that some marker has been removed. Sent by legend markers when destroyed
278 \internal Notifies legend that some marker has been removed. Sent by legend markers when destroyed
279 */
279 */
280 void QLegend::handleMarkerDestroyed()
280 void QLegend::handleMarkerDestroyed()
281 {
281 {
282 LegendMarker* m = static_cast<LegendMarker *> (sender());
282 LegendMarker* m = static_cast<LegendMarker *> (sender());
283 m_markers.removeOne(m);
283 m_markers.removeOne(m);
284 updateLayout();
284 updateLayout();
285 }
285 }
286
286
287 /*!
287 /*!
288 \internal \a event Handles clicked signals from scroll buttons
288 \internal \a event Handles clicked signals from scroll buttons
289 */
289 */
290 void QLegend::scrollButtonClicked(LegendScrollButton *scrollButton)
290 void QLegend::scrollButtonClicked(LegendScrollButton *scrollButton)
291 {
291 {
292 Q_ASSERT(scrollButton);
292 Q_ASSERT(scrollButton);
293
293
294 switch (scrollButton->id()) {
294 switch (scrollButton->id()) {
295 case LegendScrollButton::ScrollButtonIdLeft:
295 case LegendScrollButton::ScrollButtonIdLeft:
296 case LegendScrollButton::ScrollButtonIdUp: {
296 case LegendScrollButton::ScrollButtonIdUp: {
297 // Lower limit is same in these cases
297 // Lower limit is same in these cases
298 mFirstMarker--;
298 mFirstMarker--;
299 checkFirstMarkerBounds();
299 checkFirstMarkerBounds();
300 break;
300 break;
301 }
301 }
302 case LegendScrollButton::ScrollButtonIdRight:
302 case LegendScrollButton::ScrollButtonIdRight:
303 case LegendScrollButton::ScrollButtonIdDown: {
303 case LegendScrollButton::ScrollButtonIdDown: {
304 mFirstMarker++;
304 mFirstMarker++;
305 checkFirstMarkerBounds();
305 checkFirstMarkerBounds();
306 break;
306 break;
307 }
307 }
308 default: {
308 default: {
309 break;
309 break;
310 }
310 }
311 }
311 }
312 updateLayout();
312 updateLayout();
313 }
313 }
314
314
315 /*!
315 /*!
316 \internal Connects the \a series to legend. Legend listens changes in series, for example pie slices added / removed.
316 \internal Connects the \a series to legend. Legend listens changes in series, for example pie slices added / removed.
317 Not all series notify about events
317 Not all series notify about events
318 */
318 */
319 void QLegend::connectSeries(QSeries *series)
319 void QLegend::connectSeries(QSeries *series)
320 {
320 {
321 // Connect relevant signals from series. Currently only pie series has interesting signals
321 // Connect relevant signals from series. Currently only pie series has interesting signals
322 // TODO: bar chart may have
322 // TODO: bar chart may have
323 if (series->type() == QSeries::SeriesTypePie) {
323 if (series->type() == QSeries::SeriesTypePie) {
324 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
324 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
325 connect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleAdded(QList<QPieSlice*>)));
325 connect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleAdded(QList<QPieSlice*>)));
326 }
326 }
327 }
327 }
328
328
329 /*!
329 /*!
330 \internal Disconnects \a series from legend. No more status updates from series to legend.
330 \internal Disconnects \a series from legend. No more status updates from series to legend.
331 */
331 */
332 void QLegend::disconnectSeries(QSeries *series)
332 void QLegend::disconnectSeries(QSeries *series)
333 {
333 {
334 if (series->type() == QSeries::SeriesTypePie) {
334 if (series->type() == QSeries::SeriesTypePie) {
335 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
335 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
336 disconnect(pieSeries, SIGNAL(added(QList<QPieSlice *>)), this, SLOT(handleAdded(QList<QPieSlice *>)));
336 disconnect(pieSeries, SIGNAL(added(QList<QPieSlice *>)), this, SLOT(handleAdded(QList<QPieSlice *>)));
337 }
337 }
338 }
338 }
339
339
340 /*!
340 /*!
341 \internal Creates new markers for \a series. Marker contains the colored rectangle and series name.
341 \internal Creates new markers for \a series. Marker contains the colored rectangle and series name.
342 With pie chart, created markers depend on pie slices.
342 With pie chart, created markers depend on pie slices.
343 With bar chart, created markers depend on bar sets.
343 With bar chart, created markers depend on bar sets.
344 */
344 */
345 void QLegend::createMarkers(QSeries *series)
345 void QLegend::createMarkers(QSeries *series)
346 {
346 {
347 switch (series->type())
347 switch (series->type())
348 {
348 {
349 case QSeries::SeriesTypeLine: {
349 case QSeries::SeriesTypeLine: {
350 QLineSeries *lineSeries = static_cast<QLineSeries *>(series);
350 QLineSeries *lineSeries = static_cast<QLineSeries *>(series);
351 appendMarkers(lineSeries);
351 appendMarkers(lineSeries);
352 break;
352 break;
353 }
353 }
354 case QSeries::SeriesTypeArea: {
354 case QSeries::SeriesTypeArea: {
355 QAreaSeries *areaSeries = static_cast<QAreaSeries *>(series);
355 QAreaSeries *areaSeries = static_cast<QAreaSeries *>(series);
356 appendMarkers(areaSeries->upperSeries());
356 appendMarkers(areaSeries->upperSeries());
357 if(areaSeries->lowerSeries())
357 if(areaSeries->lowerSeries())
358 appendMarkers(areaSeries->lowerSeries());
358 appendMarkers(areaSeries->lowerSeries());
359 break;
359 break;
360 }
360 }
361 case QSeries::SeriesTypeBar: {
361 case QSeries::SeriesTypeBar: {
362 QBarSeries *barSeries = static_cast<QBarSeries *>(series);
362 QBarSeries *barSeries = static_cast<QBarSeries *>(series);
363 appendMarkers(barSeries);
363 appendMarkers(barSeries);
364 break;
364 break;
365 }
365 }
366 case QSeries::SeriesTypeStackedBar: {
366 case QSeries::SeriesTypeStackedBar: {
367 QStackedBarSeries *stackedBarSeries = static_cast<QStackedBarSeries *>(series);
367 QStackedBarSeries *stackedBarSeries = static_cast<QStackedBarSeries *>(series);
368 appendMarkers(stackedBarSeries);
368 appendMarkers(stackedBarSeries);
369 break;
369 break;
370 }
370 }
371 case QSeries::SeriesTypePercentBar: {
371 case QSeries::SeriesTypePercentBar: {
372 QPercentBarSeries *percentBarSeries = static_cast<QPercentBarSeries *>(series);
372 QPercentBarSeries *percentBarSeries = static_cast<QPercentBarSeries *>(series);
373 appendMarkers(percentBarSeries);
373 appendMarkers(percentBarSeries);
374 break;
374 break;
375 }
375 }
376 case QSeries::SeriesTypeScatter: {
376 case QSeries::SeriesTypeScatter: {
377 QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series);
377 QScatterSeries *scatterSeries = static_cast<QScatterSeries *>(series);
378 appendMarkers(scatterSeries);
378 appendMarkers(scatterSeries);
379 break;
379 break;
380 }
380 }
381 case QSeries::SeriesTypePie: {
381 case QSeries::SeriesTypePie: {
382 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
382 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
383 appendMarkers(pieSeries);
383 appendMarkers(pieSeries);
384 break;
384 break;
385 }
385 }
386 case QSeries::SeriesTypeSpline: {
386 case QSeries::SeriesTypeSpline: {
387 QSplineSeries *splineSeries = static_cast<QSplineSeries *>(series);
387 QSplineSeries *splineSeries = static_cast<QSplineSeries *>(series);
388 appendMarkers(splineSeries);
388 appendMarkers(splineSeries);
389 break;
389 break;
390 }
390 }
391 default: {
391 default: {
392 qWarning()<< "QLegend::createMarkers" << series->type() << "unknown series type.";
392 qWarning()<< "QLegend::createMarkers" << series->type() << "unknown series type.";
393 break;
393 break;
394 }
394 }
395 }
395 }
396 }
396 }
397
397
398 /*!
398 /*!
399 \internal Helper function. Appends markers from \a series to legend.
399 \internal Helper function. Appends markers from \a series to legend.
400 */
400 */
401 void QLegend::appendMarkers(QXYSeries* series)
401 void QLegend::appendMarkers(QXYSeries* series)
402 {
402 {
403 LegendMarker* marker = new LegendMarker(series,this);
403 LegendMarker* marker = new LegendMarker(series,this);
404 marker->setName(series->name());
404 marker->setName(series->name());
405 marker->setPen(series->pen());
405 marker->setPen(series->pen());
406 marker->setBrush(series->brush());
406 marker->setBrush(series->brush());
407 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
407 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
408 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
408 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
409 m_markers.append(marker);
409 m_markers.append(marker);
410 childItems().append(marker);
410 childItems().append(marker);
411 }
411 }
412
412
413 /*!
413 /*!
414 \internal Helper function. Appends markers from \a series to legend.
414 \internal Helper function. Appends markers from \a series to legend.
415 */
415 */
416 void QLegend::appendMarkers(QBarSeries *series)
416 void QLegend::appendMarkers(QBarSeries *series)
417 {
417 {
418 foreach(QBarSet* set, series->barSets()) {
418 foreach(QBarSet* set, series->barSets()) {
419 LegendMarker* marker = new LegendMarker(series, set, this);
419 LegendMarker* marker = new LegendMarker(series, set, this);
420 marker->setName(set->name());
420 marker->setName(set->name());
421 marker->setPen(set->pen());
421 marker->setPen(set->pen());
422 marker->setBrush(set->brush());
422 marker->setBrush(set->brush());
423 connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)),
423 connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)),
424 this, SIGNAL(clicked(QBarSet *, Qt::MouseButton)));
424 this, SIGNAL(clicked(QBarSet *, Qt::MouseButton)));
425 connect(set, SIGNAL(valueChanged()), marker, SLOT(changed()));
425 connect(set, SIGNAL(valueChanged()), marker, SLOT(changed()));
426 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
426 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
427 m_markers.append(marker);
427 m_markers.append(marker);
428 childItems().append(marker);
428 childItems().append(marker);
429 }
429 }
430 }
430 }
431
431
432 /*!
432 /*!
433 \internal Helper function. Appends markers from \a series to legend.
433 \internal Helper function. Appends markers from \a series to legend.
434 */
434 */
435 void QLegend::appendMarkers(QPieSeries *series)
435 void QLegend::appendMarkers(QPieSeries *series)
436 {
436 {
437 foreach(QPieSlice* slice, series->slices()) {
437 foreach(QPieSlice* slice, series->slices()) {
438 LegendMarker* marker = new LegendMarker(series, slice, this);
438 LegendMarker* marker = new LegendMarker(series, slice, this);
439 marker->setName(slice->label());
439 marker->setName(slice->label());
440 marker->setPen(slice->pen());
440 marker->setPen(slice->pen());
441 marker->setBrush(slice->brush());
441 marker->setBrush(slice->brush());
442 connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)),
442 connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)),
443 this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)));
443 this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)));
444 connect(slice, SIGNAL(changed()), marker, SLOT(changed()));
444 connect(slice, SIGNAL(changed()), marker, SLOT(changed()));
445 connect(slice, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
445 connect(slice, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
446 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
446 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
447 m_markers.append(marker);
447 m_markers.append(marker);
448 childItems().append(marker);
448 childItems().append(marker);
449 }
449 }
450 }
450 }
451
451
452 /*!
452 /*!
453 \internal Deletes all markers that are created from \a series
453 \internal Deletes all markers that are created from \a series
454 */
454 */
455 void QLegend::deleteMarkers(QSeries *series)
455 void QLegend::deleteMarkers(QSeries *series)
456 {
456 {
457 // Search all markers that belong to given series and delete them.
457 // Search all markers that belong to given series and delete them.
458 foreach (LegendMarker *m, m_markers) {
458 foreach (LegendMarker *m, m_markers) {
459 if (m->series() == series) {
459 if (m->series() == series) {
460 m_markers.removeOne(m);
460 m_markers.removeOne(m);
461 delete m;
461 delete m;
462 }
462 }
463 }
463 }
464 }
464 }
465
465
466 /*!
466 /*!
467 \internal Updates layout of legend. Tries to fit as many markers as possible up to the maximum size of legend.
467 \internal Updates layout of legend. Tries to fit as many markers as possible up to the maximum size of legend.
468 If items don't fit, sets the visibility of scroll buttons accordingly.
468 If items don't fit, sets the visibility of scroll buttons accordingly.
469 Causes legend to be resized.
469 Causes legend to be resized.
470 */
470 */
471 void QLegend::updateLayout()
471 void QLegend::updateLayout()
472 {
472 {
473 // Calculate layout for markers and text
473 // Calculate layout for markers and text
474 if (m_markers.count() <= 0) {
474 if (m_markers.count() <= 0) {
475 // Nothing to do
475 // Nothing to do
476 return;
476 return;
477 }
477 }
478
478
479 // Find out widest item.
479 // Find out widest item.
480 QSizeF markerMaxSize = maximumMarkerSize();
480 QSizeF markerMaxSize = maximumMarkerSize();
481 checkFirstMarkerBounds();
481 checkFirstMarkerBounds();
482
482
483 // Use max height as scroll button size
483 // Use max height as scroll button size
484 rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height()));
484 rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height()));
485
485
486 qreal totalWidth = 0;
486 qreal totalWidth = 0;
487 qreal totalHeight = 0;
487 qreal totalHeight = 0;
488 switch (m_alignment)
488 switch (m_alignment)
489 {
489 {
490 // Both cases organise items horizontally
490 // Both cases organise items horizontally
491 case QLegend::LayoutBottom:
491 case QLegend::LayoutBottom:
492 case QLegend::LayoutTop: {
492 case QLegend::LayoutTop: {
493
493
494 qreal xStep = markerMaxSize.width();
494 qreal xStep = markerMaxSize.width();
495 qreal x = m_pos.x() + m_margin;
495 qreal x = m_pos.x() + m_margin;
496 qreal y = m_pos.y() + m_margin;
496 qreal y = m_pos.y() + m_margin;
497 int column = 0;
497 int column = 0;
498 int maxColumns = 1;
498 int maxColumns = 1;
499 qreal scrollButtonWidth = 0;
499 qreal scrollButtonWidth = 0;
500
500
501 // Set correct visibility for scroll scrollbuttons
501 // Set correct visibility for scroll scrollbuttons
502 if (scrollButtonsVisible()) {
502 if (scrollButtonsVisible()) {
503 m_scrollButtonLeft->setVisible(true);
503 m_scrollButtonLeft->setVisible(true);
504 m_scrollButtonRight->setVisible(true);
504 m_scrollButtonRight->setVisible(true);
505 // scrollbuttons visible, so add their width to total width
505 // scrollbuttons visible, so add their width to total width
506 totalWidth += (m_scrollButtonLeft->boundingRect().width() + m_margin) * 2;
506 totalWidth += (m_scrollButtonLeft->boundingRect().width() + m_margin) * 2;
507 scrollButtonWidth = m_scrollButtonLeft->boundingRect().width() + m_margin;
507 scrollButtonWidth = m_scrollButtonLeft->boundingRect().width() + m_margin;
508 // start position changes by scrollbutton width
508 // start position changes by scrollbutton width
509 x += scrollButtonWidth;
509 x += scrollButtonWidth;
510 } else {
510 } else {
511 m_scrollButtonLeft->setVisible(false);
511 m_scrollButtonLeft->setVisible(false);
512 m_scrollButtonRight->setVisible(false);
512 m_scrollButtonRight->setVisible(false);
513 }
513 }
514 m_scrollButtonUp->setVisible(false);
514 m_scrollButtonUp->setVisible(false);
515 m_scrollButtonDown->setVisible(false);
515 m_scrollButtonDown->setVisible(false);
516
516
517 for (int i=0; i < m_markers.count(); i++) {
517 for (int i=0; i < m_markers.count(); i++) {
518 LegendMarker *m = m_markers.at(i);
518 LegendMarker *m = m_markers.at(i);
519 if (i < mFirstMarker) {
519 if (i < mFirstMarker) {
520 // Markers before first are not visible.
520 // Markers before first are not visible.
521 m->setVisible(false);
521 m->setVisible(false);
522 } else {
522 } else {
523 if ((x + xStep + scrollButtonWidth + m_margin) > (m_pos.x() + m_maximumSize.width())) {
523 if ((x + xStep + scrollButtonWidth + m_margin) > (m_pos.x() + m_maximumSize.width())) {
524 // This marker would go outside legend rect.
524 // This marker would go outside legend rect.
525 m->setVisible(false);
525 m->setVisible(false);
526 } else {
526 } else {
527 // This marker is ok
527 // This marker is ok
528 m->setVisible(true);
528 m->setVisible(true);
529 m->setPos(x, y);
529 m->setPos(x, y);
530 x += xStep;
530 x += xStep;
531 column++;
531 column++;
532 }
532 }
533 }
533 }
534 maxColumns = column;
534 maxColumns = column;
535 }
535 }
536
536
537 m_scrollButtonLeft->setPos(m_pos.x() + m_margin, y);
537 m_scrollButtonLeft->setPos(m_pos.x() + m_margin, y);
538 m_scrollButtonRight->setPos(x + m_margin, y);
538 m_scrollButtonRight->setPos(x + m_margin, y);
539
539
540 totalWidth += maxColumns * markerMaxSize.width() + m_margin * 2;
540 totalWidth += maxColumns * markerMaxSize.width() + m_margin * 2;
541 totalHeight = markerMaxSize.height() + m_margin * 2;
541 totalHeight = markerMaxSize.height() + m_margin * 2;
542
542
543 break;
543 break;
544 }
544 }
545 // Both cases organize items vertically
545 // Both cases organize items vertically
546 case QLegend::LayoutLeft:
546 case QLegend::LayoutLeft:
547 case QLegend::LayoutRight: {
547 case QLegend::LayoutRight: {
548 qreal yStep = markerMaxSize.height();
548 qreal yStep = markerMaxSize.height();
549 qreal x = m_pos.x() + m_margin;
549 qreal x = m_pos.x() + m_margin;
550 qreal y = m_pos.y() + m_margin;
550 qreal y = m_pos.y() + m_margin;
551 int row = 1;
551 int row = 1;
552 int maxRows = 1;
552 int maxRows = 1;
553 qreal scrollButtonHeight = 0;
553 qreal scrollButtonHeight = 0;
554
554
555 // Set correct visibility for scroll scrollbuttons
555 // Set correct visibility for scroll scrollbuttons
556 if (scrollButtonsVisible()) {
556 if (scrollButtonsVisible()) {
557 m_scrollButtonUp->setVisible(true);
557 m_scrollButtonUp->setVisible(true);
558 m_scrollButtonDown->setVisible(true);
558 m_scrollButtonDown->setVisible(true);
559 totalHeight += (m_scrollButtonUp->boundingRect().height() + m_margin) * 2; // scrollbuttons visible, so add their height to total height
559 totalHeight += (m_scrollButtonUp->boundingRect().height() + m_margin) * 2; // scrollbuttons visible, so add their height to total height
560 scrollButtonHeight = m_scrollButtonUp->boundingRect().height();
560 scrollButtonHeight = m_scrollButtonUp->boundingRect().height();
561 y += scrollButtonHeight + m_margin; // start position changes by scrollbutton height
561 y += scrollButtonHeight + m_margin; // start position changes by scrollbutton height
562 } else {
562 } else {
563 m_scrollButtonUp->setVisible(false);
563 m_scrollButtonUp->setVisible(false);
564 m_scrollButtonDown->setVisible(false);
564 m_scrollButtonDown->setVisible(false);
565 }
565 }
566 m_scrollButtonLeft->setVisible(false);
566 m_scrollButtonLeft->setVisible(false);
567 m_scrollButtonRight->setVisible(false);
567 m_scrollButtonRight->setVisible(false);
568
568
569 for (int i=0; i < m_markers.count(); i++) {
569 for (int i=0; i < m_markers.count(); i++) {
570 LegendMarker* m = m_markers.at(i);
570 LegendMarker* m = m_markers.at(i);
571 if (i < mFirstMarker) {
571 if (i < mFirstMarker) {
572 // Markers before first are not visible.
572 // Markers before first are not visible.
573 m->setVisible(false);
573 m->setVisible(false);
574 } else {
574 } else {
575 if ((y + yStep + scrollButtonHeight) > (m_pos.y() + m_maximumSize.height())) {
575 if ((y + yStep + scrollButtonHeight) > (m_pos.y() + m_maximumSize.height())) {
576 // This marker would go outside legend rect.
576 // This marker would go outside legend rect.
577 m->setVisible(false);
577 m->setVisible(false);
578 } else {
578 } else {
579 // This marker is ok
579 // This marker is ok
580 m->setVisible(true);
580 m->setVisible(true);
581 m->setPos(x, y);
581 m->setPos(x, y);
582 y += yStep;
582 y += yStep;
583 row++;
583 row++;
584 }
584 }
585 }
585 }
586 maxRows = row;
586 maxRows = row;
587 }
587 }
588
588
589 m_scrollButtonUp->setPos(m_pos.x() + m_margin, m_pos.y() + m_margin);
589 m_scrollButtonUp->setPos(m_pos.x() + m_margin, m_pos.y() + m_margin);
590 m_scrollButtonDown->setPos(m_pos.x() + m_margin, y + m_margin);
590 m_scrollButtonDown->setPos(m_pos.x() + m_margin, y + m_margin);
591
591
592 totalWidth += markerMaxSize.width() + m_margin * 2;
592 totalWidth += markerMaxSize.width() + m_margin * 2;
593 totalHeight = maxRows * markerMaxSize.height() + m_margin * 4 + scrollButtonHeight; // TODO: check this
593 totalHeight = maxRows * markerMaxSize.height() + m_margin * 4 + scrollButtonHeight; // TODO: check this
594 break;
594 break;
595 }
595 }
596 default: {
596 default: {
597 break;
597 break;
598 }
598 }
599 }
599 }
600
600
601 m_size.setWidth(totalWidth);
601 m_size.setWidth(totalWidth);
602 m_size.setHeight(totalHeight);
602 m_size.setHeight(totalHeight);
603
603
604 update();
604 update();
605 }
605 }
606
606
607 /*!
607 /*!
608 \internal Sets the size of scroll buttons to \a size
608 \internal Sets the size of scroll buttons to \a size
609 */
609 */
610 void QLegend::rescaleScrollButtons(const QSize &size)
610 void QLegend::rescaleScrollButtons(const QSize &size)
611 {
611 {
612 QPolygonF left;
612 QPolygonF left;
613 left << QPointF(size.width(), 0) << QPointF(0, size.height() / 2) << QPointF(size.width(), size.height());
613 left << QPointF(size.width(), 0) << QPointF(0, size.height() / 2) << QPointF(size.width(), size.height());
614 QPolygonF right;
614 QPolygonF right;
615 right << QPointF(0, 0) << QPointF(size.width(), size.height() / 2) << QPointF(0, size.height());
615 right << QPointF(0, 0) << QPointF(size.width(), size.height() / 2) << QPointF(0, size.height());
616 QPolygonF up;
616 QPolygonF up;
617 up << QPointF(0, size.height()) << QPointF(size.width() / 2,0) << QPointF(size.width(), size.height());
617 up << QPointF(0, size.height()) << QPointF(size.width() / 2,0) << QPointF(size.width(), size.height());
618 QPolygonF down;
618 QPolygonF down;
619 down << QPointF(0, 0) << QPointF(size.width() / 2, size.height()) << QPointF(size.width(), 0);
619 down << QPointF(0, 0) << QPointF(size.width() / 2, size.height()) << QPointF(size.width(), 0);
620
620
621 m_scrollButtonLeft->setPolygon(left);
621 m_scrollButtonLeft->setPolygon(left);
622 m_scrollButtonRight->setPolygon(right);
622 m_scrollButtonRight->setPolygon(right);
623 m_scrollButtonUp->setPolygon(up);
623 m_scrollButtonUp->setPolygon(up);
624 m_scrollButtonDown->setPolygon(down);
624 m_scrollButtonDown->setPolygon(down);
625 }
625 }
626
626
627 /*!
627 /*!
628 \internal Finds out maximum size of single marker. Marker sizes depend on series names.
628 \internal Finds out maximum size of single marker. Marker sizes depend on series names.
629 */
629 */
630 QSizeF QLegend::maximumMarkerSize()
630 QSizeF QLegend::maximumMarkerSize()
631 {
631 {
632 QSizeF max(0,0);
632 QSizeF max(0,0);
633 foreach (LegendMarker* m, m_markers) {
633 foreach (LegendMarker* m, m_markers) {
634 if (m->boundingRect().width() > max.width())
634 if (m->boundingRect().width() > max.width())
635 max.setWidth(m->boundingRect().width());
635 max.setWidth(m->boundingRect().width());
636 if (m->boundingRect().height() > max.height())
636 if (m->boundingRect().height() > max.height())
637 max.setHeight(m->boundingRect().height());
637 max.setHeight(m->boundingRect().height());
638 }
638 }
639 return max;
639 return max;
640 }
640 }
641
641
642 /*!
642 /*!
643 \internal Checks that first marker is in acceptable bounds. Bounds range from 0 to (maximum number of markers - visible markers)
643 \internal Checks that first marker is in acceptable bounds. Bounds range from 0 to (maximum number of markers - visible markers)
644 If scrollbuttons are visible, they affect the number of visible markers.
644 If scrollbuttons are visible, they affect the number of visible markers.
645 */
645 */
646 void QLegend::checkFirstMarkerBounds()
646 void QLegend::checkFirstMarkerBounds()
647 {
647 {
648 if ((m_alignment == QLegend::LayoutLeft) || (m_alignment == QLegend::LayoutRight)) {
648 if ((m_alignment == QLegend::LayoutLeft) || (m_alignment == QLegend::LayoutRight)) {
649 // Bounds limited by height.
649 // Bounds limited by height.
650 int max;
650 int max;
651 if (scrollButtonsVisible()) {
651 if (scrollButtonsVisible()) {
652 max = (m_maximumSize.height() - m_scrollButtonLeft->boundingRect().height() * 2 - m_margin * 4) / maximumMarkerSize().height();
652 max = (m_maximumSize.height() - m_scrollButtonLeft->boundingRect().height() * 2 - m_margin * 4) / maximumMarkerSize().height();
653 } else {
653 } else {
654 max = m_maximumSize.height() / maximumMarkerSize().height();
654 max = m_maximumSize.height() / maximumMarkerSize().height();
655 }
655 }
656
656
657 if (mFirstMarker > m_markers.count() - max)
657 if (mFirstMarker > m_markers.count() - max)
658 mFirstMarker = m_markers.count() - max;
658 mFirstMarker = m_markers.count() - max;
659 } else {
659 } else {
660 // Bounds limited by width
660 // Bounds limited by width
661 int max;
661 int max;
662 if (scrollButtonsVisible()) {
662 if (scrollButtonsVisible()) {
663 max = (m_maximumSize.width() - m_scrollButtonLeft->boundingRect().width() * 2 - m_margin*4) / maximumMarkerSize().width();
663 max = (m_maximumSize.width() - m_scrollButtonLeft->boundingRect().width() * 2 - m_margin*4) / maximumMarkerSize().width();
664 } else {
664 } else {
665 max = m_maximumSize.width() / maximumMarkerSize().width();
665 max = m_maximumSize.width() / maximumMarkerSize().width();
666 }
666 }
667
667
668 if (mFirstMarker > m_markers.count() - max)
668 if (mFirstMarker > m_markers.count() - max)
669 mFirstMarker = m_markers.count() - max;
669 mFirstMarker = m_markers.count() - max;
670 }
670 }
671
671
672 if (mFirstMarker < 0)
672 if (mFirstMarker < 0)
673 mFirstMarker = 0;
673 mFirstMarker = 0;
674 }
674 }
675
675
676 /*!
676 /*!
677 \internal Helper function. Visibility of scroll buttons isn't quite obvious, so helper function clarifies the logic.
677 \internal Helper function. Visibility of scroll buttons isn't quite obvious, so helper function clarifies the logic.
678 */
678 */
679 bool QLegend::scrollButtonsVisible()
679 bool QLegend::scrollButtonsVisible()
680 {
680 {
681 // Just a helper to clarify, what the magic below means :)
681 // Just a helper to clarify, what the magic below means :)
682 if ((m_alignment == QLegend::LayoutTop) || (m_alignment == QLegend::LayoutBottom)) {
682 if ((m_alignment == QLegend::LayoutTop) || (m_alignment == QLegend::LayoutBottom)) {
683 return (maximumMarkerSize().width() * m_markers.count() + m_margin * 2 > m_maximumSize.width());
683 return (maximumMarkerSize().width() * m_markers.count() + m_margin * 2 > m_maximumSize.width());
684 } else if ((m_alignment == QLegend::LayoutLeft) || (m_alignment == QLegend::LayoutRight)) {
684 } else if ((m_alignment == QLegend::LayoutLeft) || (m_alignment == QLegend::LayoutRight)) {
685 return (maximumMarkerSize().height() * m_markers.count() + m_margin * 2 > m_maximumSize.height());
685 return (maximumMarkerSize().height() * m_markers.count() + m_margin * 2 > m_maximumSize.height());
686 }
686 }
687
687
688 return (maximumMarkerSize().height() * m_markers.count() + m_margin * 2 > m_maximumSize.height());
688 return (maximumMarkerSize().height() * m_markers.count() + m_margin * 2 > m_maximumSize.height());
689 }
689 }
690
690
691 #include "moc_qlegend.cpp"
691 #include "moc_qlegend.cpp"
692
692
693 QTCOMMERCIALCHART_END_NAMESPACE
693 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now