##// END OF EJS Templates
commenting out usage of old marker implementation from legend. Legend now uses new markers.
sauimone -
r2170:3d497e4d0047
parent child
Show More
@@ -118,8 +118,10 void LegendLayout::setAttachedGeometry(const QRectF &rect)
118
118
119 QSizeF size(0, 0);
119 QSizeF size(0, 0);
120
120
121 if (m_legend->d_ptr->markers().isEmpty())
121 // if( m_legend->d_ptr->markers().isEmpty()) return;
122 if (m_legend->d_ptr->legendMarkers().isEmpty()) {
122 return;
123 return;
124 }
123
125
124 m_width = 0;
126 m_width = 0;
125 m_height = 0;
127 m_height = 0;
@@ -148,8 +150,9 void LegendLayout::setAttachedGeometry(const QRectF &rect)
148 */
150 */
149 // New markers -->>
151 // New markers -->>
150 foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
152 foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
151 if (marker->isVisible()) {
153 LegendMarkerItem* item = marker->d_ptr->item();
152 LegendMarkerItem* item = marker->d_ptr.data()->item();
154 if (item->isVisible()) {
155 // LegendMarkerItem* item = marker->d_ptr.data()->item();
153 item->setGeometry(geometry);
156 item->setGeometry(geometry);
154 item->setPos(point.x(),geometry.height()/2 - item->boundingRect().height()/2);
157 item->setPos(point.x(),geometry.height()/2 - item->boundingRect().height()/2);
155 const QRectF& rect = item->boundingRect();
158 const QRectF& rect = item->boundingRect();
@@ -185,8 +188,9 void LegendLayout::setAttachedGeometry(const QRectF &rect)
185 */
188 */
186 // New markers -->>
189 // New markers -->>
187 foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
190 foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
188 if (marker->isVisible()) {
191 LegendMarkerItem* item = marker->d_ptr->item();
189 LegendMarkerItem* item = marker->d_ptr.data()->item();
192 if (item->isVisible()) {
193 // LegendMarkerItem* item = marker->d_ptr->item();
190 item->setGeometry(geometry);
194 item->setGeometry(geometry);
191 item->setPos(point);
195 item->setPos(point);
192 const QRectF& rect = item->boundingRect();
196 const QRectF& rect = item->boundingRect();
@@ -232,7 +236,8 void LegendLayout::setDettachedGeometry(const QRectF &rect)
232
236
233 QSizeF size(0, 0);
237 QSizeF size(0, 0);
234
238
235 QList<LegendMarker *> markers = m_legend->d_ptr->markers();
239 // QList<LegendMarker *> markers = m_legend->d_ptr->markers();
240 QList<QLegendMarker *> markers = m_legend->d_ptr->legendMarkers();
236
241
237 if (markers.isEmpty())
242 if (markers.isEmpty())
238 return;
243 return;
@@ -243,21 +248,44 void LegendLayout::setDettachedGeometry(const QRectF &rect)
243 m_width = 0;
248 m_width = 0;
244 m_height = 0;
249 m_height = 0;
245 for (int i = 0; i < markers.count(); i++) {
250 for (int i = 0; i < markers.count(); i++) {
251 /*
246 LegendMarker *marker = markers.at(i);
252 LegendMarker *marker = markers.at(i);
247 if (marker->isVisible()) {
253 if (marker->isVisible()) {
248 marker->setGeometry(geometry);
254 marker->setGeometry(geometry);
249 marker->setPos(point.x(), point.y());
255 marker->setPos(point.x(),point.y());
250 const QRectF &boundingRect = marker->boundingRect();
256 const QRectF& boundingRect = marker->boundingRect();
251 qreal w = boundingRect.width();
257 qreal w = boundingRect.width();
252 qreal h = boundingRect.height();
258 qreal h = boundingRect.height();
253 m_width = qMax(m_width, w);
259 m_width = qMax(m_width,w);
254 m_height = qMax(m_height, h);
260 m_height = qMax(m_height,h);
255 point.setX(point.x() + w);
261 point.setX(point.x() + w);
256 if (point.x() + w > geometry.left() + geometry.width() - right) {
262 if (point.x() + w > geometry.left() + geometry.width() - right) {
257 // Next item would go off rect.
263 // Next item would go off rect.
258 point.setX(0);
264 point.setX(0);
259 point.setY(point.y() + h);
265 point.setY(point.y() + h);
260 if (i + 1 < markers.count()) {
266 if (i+1 < markers.count()) {
267 m_height += h;
268 }
269 }
270 }
271 */
272 // QLegendMarker *marker = markers.at(i);
273 LegendMarkerItem *item = markers.at(i)->d_ptr->item();
274 if (item->isVisible()) {
275 // LegendMarkerItem *item = marker->d_ptr->item();
276 item->setGeometry(geometry);
277 item->setPos(point.x(),point.y());
278 const QRectF& boundingRect = item->boundingRect();
279 qreal w = boundingRect.width();
280 qreal h = boundingRect.height();
281 m_width = qMax(m_width,w);
282 m_height = qMax(m_height,h);
283 point.setX(point.x() + w);
284 if (point.x() + w > geometry.left() + geometry.width() - right) {
285 // Next item would go off rect.
286 point.setX(0);
287 point.setY(point.y() + h);
288 if (i+1 < markers.count()) {
261 m_height += h;
289 m_height += h;
262 }
290 }
263 }
291 }
@@ -276,32 +304,54 void LegendLayout::setDettachedGeometry(const QRectF &rect)
276 m_width = 0;
304 m_width = 0;
277 m_height = 0;
305 m_height = 0;
278 for (int i = 0; i < markers.count(); i++) {
306 for (int i = 0; i < markers.count(); i++) {
307 /*
279 LegendMarker *marker = markers.at(i);
308 LegendMarker *marker = markers.at(i);
280 if (marker->isVisible()) {
309 if (marker->isVisible()) {
281 marker->setGeometry(geometry);
310 marker->setGeometry(geometry);
282 const QRectF &boundingRect = marker->boundingRect();
311 const QRectF& boundingRect = marker->boundingRect();
283 qreal w = boundingRect.width();
312 qreal w = boundingRect.width();
284 qreal h = boundingRect.height();
313 qreal h = boundingRect.height();
285 m_width = qMax(m_width, w);
314 m_width = qMax(m_width,w);
286 m_height = qMax(m_height, h);
315 m_height = qMax(m_height,h);
287 marker->setPos(point.x(), point.y() - h);
316 marker->setPos(point.x(),point.y() - h);
288 point.setX(point.x() + w);
317 point.setX(point.x() + w);
289 if (point.x() + w > geometry.left() + geometry.width() - right) {
318 if (point.x() + w > geometry.left() + geometry.width() - right) {
290 // Next item would go off rect.
319 // Next item would go off rect.
291 point.setX(0);
320 point.setX(0);
292 point.setY(point.y() - h);
321 point.setY(point.y() - h);
293 if (i + 1 < markers.count()) {
322 if (i+1 < markers.count()) {
323 m_height += h;
324 }
325 }
326 }
327 */
328 // QLegendMarker *marker = markers.at(i);
329 LegendMarkerItem *item = markers.at(i)->d_ptr->item();
330 if (item->isVisible()) {
331 item->setGeometry(geometry);
332 const QRectF& boundingRect = item->boundingRect();
333 qreal w = boundingRect.width();
334 qreal h = boundingRect.height();
335 m_width = qMax(m_width,w);
336 m_height = qMax(m_height,h);
337 item->setPos(point.x(),point.y() - h);
338 point.setX(point.x() + w);
339 if (point.x() + w > geometry.left() + geometry.width() - right) {
340 // Next item would go off rect.
341 point.setX(0);
342 point.setY(point.y() - h);
343 if (i+1 < markers.count()) {
294 m_height += h;
344 m_height += h;
295 }
345 }
296 }
346 }
297 }
347 }
298 }
348 }
299 m_legend->d_ptr->items()->setPos(geometry.topLeft());
349 m_legend->d_ptr->items()->setPos(geometry.topLeft());
300
350
301 m_minOffsetX = -left;
351 m_minOffsetX = -left;
302 m_minOffsetY = -m_height + geometry.height() - top;
352 m_minOffsetY = -m_height + geometry.height() - top;
303 m_maxOffsetX = m_width - geometry.width() - right;
353 m_maxOffsetX = m_width - geometry.width() - right;
304 m_maxOffsetY = -bottom;
354 m_maxOffsetY = -bottom;
305 }
355 }
306 break;
356 break;
307 case Qt::AlignLeft: {
357 case Qt::AlignLeft: {
@@ -310,34 +360,58 void LegendLayout::setDettachedGeometry(const QRectF &rect)
310 m_height = 0;
360 m_height = 0;
311 qreal maxWidth = 0;
361 qreal maxWidth = 0;
312 for (int i = 0; i < markers.count(); i++) {
362 for (int i = 0; i < markers.count(); i++) {
363 /*
313 LegendMarker *marker = markers.at(i);
364 LegendMarker *marker = markers.at(i);
314 if (marker->isVisible()) {
365 if (marker->isVisible()) {
315 marker->setGeometry(geometry);
366 marker->setGeometry(geometry);
316 const QRectF &boundingRect = marker->boundingRect();
367 const QRectF& boundingRect = marker->boundingRect();
368 qreal w = boundingRect.width();
369 qreal h = boundingRect.height();
370 m_height = qMax(m_height,h);
371 maxWidth = qMax(maxWidth,w);
372 marker->setPos(point.x(),point.y());
373 point.setY(point.y() + h);
374 if (point.y() + h > geometry.bottom() - bottom) {
375 // Next item would go off rect.
376 point.setX(point.x() + maxWidth);
377 point.setY(0);
378 if (i+1 < markers.count()) {
379 m_width += maxWidth;
380 maxWidth = 0;
381 }
382 }
383 }
384 */
385 // QLegendMarker *marker = markers.at(i);
386 LegendMarkerItem *item = markers.at(i)->d_ptr->item();
387 if (item->isVisible()) {
388 // LegendMarkerItem *item = marker->d_ptr->item();
389 item->setGeometry(geometry);
390 const QRectF& boundingRect = item->boundingRect();
317 qreal w = boundingRect.width();
391 qreal w = boundingRect.width();
318 qreal h = boundingRect.height();
392 qreal h = boundingRect.height();
319 m_height = qMax(m_height, h);
393 m_height = qMax(m_height,h);
320 maxWidth = qMax(maxWidth, w);
394 maxWidth = qMax(maxWidth,w);
321 marker->setPos(point.x(), point.y());
395 item->setPos(point.x(),point.y());
322 point.setY(point.y() + h);
396 point.setY(point.y() + h);
323 if (point.y() + h > geometry.bottom() - bottom) {
397 if (point.y() + h > geometry.bottom() - bottom) {
324 // Next item would go off rect.
398 // Next item would go off rect.
325 point.setX(point.x() + maxWidth);
399 point.setX(point.x() + maxWidth);
326 point.setY(0);
400 point.setY(0);
327 if (i + 1 < markers.count()) {
401 if (i+1 < markers.count()) {
328 m_width += maxWidth;
402 m_width += maxWidth;
329 maxWidth = 0;
403 maxWidth = 0;
330 }
404 }
331 }
405 }
332 }
406 }
333 }
407 }
334 m_width += maxWidth;
408 m_width += maxWidth;
335 m_legend->d_ptr->items()->setPos(geometry.topLeft());
409 m_legend->d_ptr->items()->setPos(geometry.topLeft());
336
410
337 m_minOffsetX = -left;
411 m_minOffsetX = -left;
338 m_minOffsetY = -top;
412 m_minOffsetY = -top;
339 m_maxOffsetX = m_width - geometry.width() - right;
413 m_maxOffsetX = m_width - geometry.width() - right;
340 m_maxOffsetY = m_height - geometry.height() - bottom;
414 m_maxOffsetY = m_height - geometry.height() - bottom;
341 }
415 }
342 break;
416 break;
343 case Qt::AlignRight: {
417 case Qt::AlignRight: {
@@ -346,34 +420,58 void LegendLayout::setDettachedGeometry(const QRectF &rect)
346 m_height = 0;
420 m_height = 0;
347 qreal maxWidth = 0;
421 qreal maxWidth = 0;
348 for (int i = 0; i < markers.count(); i++) {
422 for (int i = 0; i < markers.count(); i++) {
423 /*
349 LegendMarker *marker = markers.at(i);
424 LegendMarker *marker = markers.at(i);
350 if (marker->isVisible()) {
425 if (marker->isVisible()) {
351 marker->setGeometry(geometry);
426 marker->setGeometry(geometry);
352 const QRectF &boundingRect = marker->boundingRect();
427 const QRectF& boundingRect = marker->boundingRect();
353 qreal w = boundingRect.width();
428 qreal w = boundingRect.width();
354 qreal h = boundingRect.height();
429 qreal h = boundingRect.height();
355 m_height = qMax(m_height, h);
430 m_height = qMax(m_height,h);
356 maxWidth = qMax(maxWidth, w);
431 maxWidth = qMax(maxWidth,w);
357 marker->setPos(point.x() - w, point.y());
432 marker->setPos(point.x() - w,point.y());
358 point.setY(point.y() + h);
433 point.setY(point.y() + h);
359 if (point.y() + h > geometry.bottom() - bottom) {
434 if (point.y() + h > geometry.bottom()-bottom) {
435 // Next item would go off rect.
436 point.setX(point.x() - maxWidth);
437 point.setY(0);
438 if (i+1 < markers.count()) {
439 m_width += maxWidth;
440 maxWidth = 0;
441 }
442 }
443 }
444 */
445 // QLegendMarker *marker = markers.at(i);
446 LegendMarkerItem *item = markers.at(i)->d_ptr->item();
447 if (item->isVisible()) {
448 // LegendMarkerItem *item = marker->d_ptr->item();
449 item->setGeometry(geometry);
450 const QRectF& boundingRect = item->boundingRect();
451 qreal w = boundingRect.width();
452 qreal h = boundingRect.height();
453 m_height = qMax(m_height,h);
454 maxWidth = qMax(maxWidth,w);
455 item->setPos(point.x() - w,point.y());
456 point.setY(point.y() + h);
457 if (point.y() + h > geometry.bottom()-bottom) {
360 // Next item would go off rect.
458 // Next item would go off rect.
361 point.setX(point.x() - maxWidth);
459 point.setX(point.x() - maxWidth);
362 point.setY(0);
460 point.setY(0);
363 if (i + 1 < markers.count()) {
461 if (i+1 < markers.count()) {
364 m_width += maxWidth;
462 m_width += maxWidth;
365 maxWidth = 0;
463 maxWidth = 0;
366 }
464 }
367 }
465 }
368 }
466 }
369 }
467 }
370 m_width += maxWidth;
468 m_width += maxWidth;
371 m_legend->d_ptr->items()->setPos(geometry.topLeft());
469 m_legend->d_ptr->items()->setPos(geometry.topLeft());
372
470
373 m_minOffsetX = - m_width + geometry.width() - left;
471 m_minOffsetX = - m_width + geometry.width() - left;
374 m_minOffsetY = -top;
472 m_minOffsetY = -top;
375 m_maxOffsetX = - right;
473 m_maxOffsetX = - right;
376 m_maxOffsetY = m_height - geometry.height() - bottom;
474 m_maxOffsetY = m_height - geometry.height() - bottom;
377 }
475 }
378 break;
476 break;
379 default:
477 default:
@@ -424,7 +522,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons
424
522
425 if(constraint.isValid()) {
523 if(constraint.isValid()) {
426 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
524 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
427 LegendMarkerItem *item = marker->d_ptr.data()->item();
525 LegendMarkerItem *item = marker->d_ptr->item();
428 size = size.expandedTo(item->effectiveSizeHint(which));
526 size = size.expandedTo(item->effectiveSizeHint(which));
429 }
527 }
430 size = size.boundedTo(constraint);
528 size = size.boundedTo(constraint);
@@ -433,7 +531,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons
433 qreal width = 0;
531 qreal width = 0;
434 qreal height = 0;
532 qreal height = 0;
435 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
533 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
436 LegendMarkerItem *item = marker->d_ptr.data()->item();
534 LegendMarkerItem *item = marker->d_ptr->item();
437 width+=item->effectiveSizeHint(which).width();
535 width+=item->effectiveSizeHint(which).width();
438 height=qMax(height,item->effectiveSizeHint(which).height());
536 height=qMax(height,item->effectiveSizeHint(which).height());
439 }
537 }
@@ -444,7 +542,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons
444 qreal width = 0;
542 qreal width = 0;
445 qreal height = 0;
543 qreal height = 0;
446 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
544 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
447 LegendMarkerItem *item = marker->d_ptr.data()->item();
545 LegendMarkerItem *item = marker->d_ptr->item();
448 width=qMax(width,item->effectiveSizeHint(which).width());
546 width=qMax(width,item->effectiveSizeHint(which).width());
449 height+=height,item->effectiveSizeHint(which).height();
547 height+=height,item->effectiveSizeHint(which).height();
450 }
548 }
@@ -452,7 +550,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons
452 }
550 }
453 else {
551 else {
454 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
552 foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) {
455 LegendMarkerItem *item = marker->d_ptr.data()->item();
553 LegendMarkerItem *item = marker->d_ptr->item();
456 size = size.expandedTo(item->effectiveSizeHint(which));
554 size = size.expandedTo(item->effectiveSizeHint(which));
457 }
555 }
458 }
556 }
@@ -33,17 +33,13 LegendMarkerItem::LegendMarkerItem(QLegendMarkerPrivate *marker, QGraphicsObject
33 QGraphicsObject(parent),
33 QGraphicsObject(parent),
34 m_marker(marker),
34 m_marker(marker),
35 m_markerRect(0,0,10.0,10.0),
35 m_markerRect(0,0,10.0,10.0),
36 m_boundingRect(0,0,10,10),
36 m_boundingRect(0,0,0,0),
37 m_textItem(new QGraphicsSimpleTextItem(this)),
37 m_textItem(new QGraphicsSimpleTextItem(this)),
38 m_rectItem(new QGraphicsRectItem(this)),
38 m_rectItem(new QGraphicsRectItem(this)),
39 m_margin(4),
39 m_margin(4),
40 m_space(4)
40 m_space(4)
41 {
41 {
42 // qDebug() << "LegendMarkerItem created for marker:" << m_marker;
43 // setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
44 m_rectItem->setRect(m_markerRect);
42 m_rectItem->setRect(m_markerRect);
45 // setZValue(zValue() + 20);
46 // qDebug() << "z:" << this->zValue();
47 }
43 }
48
44
49 void LegendMarkerItem::setPen(const QPen &pen)
45 void LegendMarkerItem::setPen(const QPen &pen)
@@ -81,7 +77,6 QFont LegendMarkerItem::font() const
81
77
82 void LegendMarkerItem::setLabel(const QString label)
78 void LegendMarkerItem::setLabel(const QString label)
83 {
79 {
84 qDebug() << "LegendMarkerItem::setlabel" << label;
85 m_text = label;
80 m_text = label;
86 updateGeometry();
81 updateGeometry();
87 }
82 }
@@ -476,26 +476,18 int QLegendPrivate::roundness(qreal size)
476
476
477 void QLegendPrivate::appendSeries(QAbstractSeries* series)
477 void QLegendPrivate::appendSeries(QAbstractSeries* series)
478 {
478 {
479 Q_UNUSED(series);
480 // TODO:
481 /*
482 if (!m_series.contains(series)) {
479 if (!m_series.contains(series)) {
483 m_series.append(series);
480 m_series.append(series);
484 handleSeriesAdded(series,0); // Dummy domain
481 handleSeriesAdded(series,0);
485 }
482 }
486 */
487 }
483 }
488
484
489 void QLegendPrivate::removeSeries(QAbstractSeries* series)
485 void QLegendPrivate::removeSeries(QAbstractSeries* series)
490 {
486 {
491 Q_UNUSED(series);
492 // TODO:
493 /*
494 if (m_series.contains(series)) {
487 if (m_series.contains(series)) {
495 m_series.removeOne(series);
488 m_series.removeOne(series);
496 handleSeriesRemoved(series);
489 handleSeriesRemoved(series);
497 }
490 }
498 */
499 }
491 }
500
492
501 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
493 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
@@ -517,6 +509,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
517 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
509 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
518 // <--- New markers
510 // <--- New markers
519
511
512 /*
520 QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr);
513 QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr);
521
514
522 foreach (LegendMarker *marker, markers) {
515 foreach (LegendMarker *marker, markers) {
@@ -526,6 +519,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
526 m_items->addToGroup(marker);
519 m_items->addToGroup(marker);
527 m_markers << marker;
520 m_markers << marker;
528 }
521 }
522 */
529
523
530 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
524 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
531 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
525 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
@@ -539,6 +533,8 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
539 // New markers --->
533 // New markers --->
540 foreach (QLegendMarker *marker, m_legendMarkers) {
534 foreach (QLegendMarker *marker, m_legendMarkers) {
541 if (marker->series() == series) {
535 if (marker->series() == series) {
536 marker->d_ptr.data()->item()->setVisible(false);
537 m_items->removeFromGroup(marker->d_ptr.data()->item());
542 delete marker;
538 delete marker;
543 m_legendMarkers.removeAll(marker);
539 m_legendMarkers.removeAll(marker);
544 }
540 }
@@ -547,13 +543,14 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
547 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
543 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
548 // <--- New markers
544 // <--- New markers
549
545
546 /*
550 foreach (LegendMarker *marker, m_markers) {
547 foreach (LegendMarker *marker, m_markers) {
551 if (marker->series() == series) {
548 if (marker->series() == series) {
552 delete marker;
549 delete marker;
553 m_markers.removeAll(marker);
550 m_markers.removeAll(marker);
554 }
551 }
555 }
552 }
556
553 */
557 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
554 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
558 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
555 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
559 m_layout->invalidate();
556 m_layout->invalidate();
@@ -572,17 +569,19 void QLegendPrivate::handleSeriesVisibleChanged()
572 }
569 }
573
570
574 // <--- New markers
571 // <--- New markers
575
572 /*
576 foreach (LegendMarker* marker, m_markers) {
573 foreach (LegendMarker* marker, m_markers) {
577 if (marker->series() == series) {
574 if (marker->series() == series) {
578 marker->setVisible(series->isVisible());
575 marker->setVisible(series->isVisible());
579 }
576 }
577 */
580 m_layout->invalidate();
578 m_layout->invalidate();
581 }
579 }
582
580
583 void QLegendPrivate::handleCountChanged()
581 void QLegendPrivate::handleCountChanged()
584 {
582 {
585 // With new markers, the series shoud notify markers directly?
583 // With new markers, the series shoud notify markers directly?
584 qDebug() << "handleLegendPropertiesUpdated";
586
585
587 // Handle new or removed markers
586 // Handle new or removed markers
588 // Handle changes of marker pen/brush/label. every property that legend is interested
587 // Handle changes of marker pen/brush/label. every property that legend is interested
@@ -113,6 +113,7 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q) :
113
113
114 QLegendMarkerPrivate::~QLegendMarkerPrivate()
114 QLegendMarkerPrivate::~QLegendMarkerPrivate()
115 {
115 {
116 // delete m_item;
116 }
117 }
117
118
118 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event)
119 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event)
@@ -32,6 +32,7 QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject
32
32
33 QPieLegendMarker::~QPieLegendMarker()
33 QPieLegendMarker::~QPieLegendMarker()
34 {
34 {
35 qDebug() << "deleting pie marker" << this;
35 }
36 }
36
37
37 /*!
38 /*!
@@ -61,7 +62,7 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieSeries *series, QPieSlice *
61 m_series(series),
62 m_series(series),
62 m_slice(slice)
63 m_slice(slice)
63 {
64 {
64 qDebug() << "QPieLegendMarkerPrivate created";
65 // qDebug() << "QPieLegendMarkerPrivate created";
65 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
67 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
67 updated();
68 updated();
@@ -75,7 +76,7 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
75
76
76 void QPieLegendMarkerPrivate::updated()
77 void QPieLegendMarkerPrivate::updated()
77 {
78 {
78 qDebug() << "QPieLegendMarkerPrivate::updated";
79 // qDebug() << "QPieLegendMarkerPrivate::updated";
79 m_item->setBrush(m_slice->brush());
80 m_item->setBrush(m_slice->brush());
80 m_item->setLabel(m_slice->label());
81 m_item->setLabel(m_slice->label());
81 m_item->setPen(m_slice->pen());
82 m_item->setPen(m_slice->pen());
General Comments 0
You need to be logged in to leave comments. Login now