@@ -20,7 +20,7 | |||
|
20 | 20 | |
|
21 | 21 | #include "legendlayout_p.h" |
|
22 | 22 | #include "chartpresenter_p.h" |
|
23 | #include "legendmarker_p.h" | |
|
23 | //#include "legendmarker_p.h" | |
|
24 | 24 | #include "qlegend_p.h" |
|
25 | 25 | #include "chartlayout_p.h" |
|
26 | 26 | |
@@ -118,7 +118,6 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
118 | 118 | |
|
119 | 119 | QSizeF size(0, 0); |
|
120 | 120 | |
|
121 | // if( m_legend->d_ptr->markers().isEmpty()) return; | |
|
122 | 121 | if (m_legend->d_ptr->legendMarkers().isEmpty()) { |
|
123 | 122 | return; |
|
124 | 123 | } |
@@ -135,24 +134,9 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
135 | 134 | case Qt::AlignTop: |
|
136 | 135 | case Qt::AlignBottom: { |
|
137 | 136 | QPointF point(0,0); |
|
138 | /* | |
|
139 | foreach (LegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
140 | if (marker->isVisible()) { | |
|
141 | marker->setGeometry(geometry); | |
|
142 | marker->setPos(point.x(),geometry.height()/2 - marker->boundingRect().height()/2); | |
|
143 | const QRectF& rect = marker->boundingRect(); | |
|
144 | size = size.expandedTo(rect.size()); | |
|
145 | qreal w = rect.width(); | |
|
146 | m_width+=w; | |
|
147 | point.setX(point.x() + w); | |
|
148 | } | |
|
149 | } | |
|
150 | */ | |
|
151 | // New markers -->> | |
|
152 | 137 | foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { |
|
153 | 138 | LegendMarkerItem* item = marker->d_ptr->item(); |
|
154 | 139 | if (item->isVisible()) { |
|
155 | // LegendMarkerItem* item = marker->d_ptr.data()->item(); | |
|
156 | 140 | item->setGeometry(geometry); |
|
157 | 141 | item->setPos(point.x(),geometry.height()/2 - item->boundingRect().height()/2); |
|
158 | 142 | const QRectF& rect = item->boundingRect(); |
@@ -162,7 +146,6 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
162 | 146 | point.setX(point.x() + w); |
|
163 | 147 | } |
|
164 | 148 | } |
|
165 | // <<-- New markers | |
|
166 | 149 | if (m_width < geometry.width()) |
|
167 | 150 | m_legend->d_ptr->items()->setPos(geometry.width() / 2 - m_width / 2, geometry.top()); |
|
168 | 151 | else |
@@ -173,24 +156,9 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
173 | 156 | case Qt::AlignLeft: |
|
174 | 157 | case Qt::AlignRight: { |
|
175 | 158 | QPointF point(0,0); |
|
176 | /* | |
|
177 | foreach (LegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
178 | if (marker->isVisible()) { | |
|
179 | marker->setGeometry(geometry); | |
|
180 | marker->setPos(point); | |
|
181 | const QRectF& rect = marker->boundingRect(); | |
|
182 | qreal h = rect.height(); | |
|
183 | size = size.expandedTo(rect.size()); | |
|
184 | m_height+=h; | |
|
185 | point.setY(point.y() + h); | |
|
186 | } | |
|
187 | } | |
|
188 | */ | |
|
189 | // New markers -->> | |
|
190 | 159 | foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { |
|
191 | 160 | LegendMarkerItem* item = marker->d_ptr->item(); |
|
192 | 161 | if (item->isVisible()) { |
|
193 | // LegendMarkerItem* item = marker->d_ptr->item(); | |
|
194 | 162 | item->setGeometry(geometry); |
|
195 | 163 | item->setPos(point); |
|
196 | 164 | const QRectF& rect = item->boundingRect(); |
@@ -200,7 +168,6 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
200 | 168 | point.setY(point.y() + h); |
|
201 | 169 | } |
|
202 | 170 | } |
|
203 | // <<--- New markers | |
|
204 | 171 | |
|
205 | 172 | if (m_height < geometry.height()) |
|
206 | 173 | m_legend->d_ptr->items()->setPos(geometry.left(), geometry.height() / 2 - m_height / 2); |
@@ -236,7 +203,6 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
236 | 203 | |
|
237 | 204 | QSizeF size(0, 0); |
|
238 | 205 | |
|
239 | // QList<LegendMarker *> markers = m_legend->d_ptr->markers(); | |
|
240 | 206 | QList<QLegendMarker *> markers = m_legend->d_ptr->legendMarkers(); |
|
241 | 207 | |
|
242 | 208 | if (markers.isEmpty()) |
@@ -248,31 +214,8 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
248 | 214 | m_width = 0; |
|
249 | 215 | m_height = 0; |
|
250 | 216 | for (int i = 0; i < markers.count(); i++) { |
|
251 | /* | |
|
252 | LegendMarker *marker = markers.at(i); | |
|
253 | if (marker->isVisible()) { | |
|
254 | marker->setGeometry(geometry); | |
|
255 | marker->setPos(point.x(),point.y()); | |
|
256 | const QRectF& boundingRect = marker->boundingRect(); | |
|
257 | qreal w = boundingRect.width(); | |
|
258 | qreal h = boundingRect.height(); | |
|
259 | m_width = qMax(m_width,w); | |
|
260 | m_height = qMax(m_height,h); | |
|
261 | point.setX(point.x() + w); | |
|
262 | if (point.x() + w > geometry.left() + geometry.width() - right) { | |
|
263 | // Next item would go off rect. | |
|
264 | point.setX(0); | |
|
265 | point.setY(point.y() + h); | |
|
266 | if (i+1 < markers.count()) { | |
|
267 | m_height += h; | |
|
268 | } | |
|
269 | } | |
|
270 | } | |
|
271 | */ | |
|
272 | // QLegendMarker *marker = markers.at(i); | |
|
273 | 217 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
274 | 218 | if (item->isVisible()) { |
|
275 | // LegendMarkerItem *item = marker->d_ptr->item(); | |
|
276 | 219 | item->setGeometry(geometry); |
|
277 | 220 | item->setPos(point.x(),point.y()); |
|
278 | 221 | const QRectF& boundingRect = item->boundingRect(); |
@@ -304,28 +247,6 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
304 | 247 | m_width = 0; |
|
305 | 248 | m_height = 0; |
|
306 | 249 | for (int i = 0; i < markers.count(); i++) { |
|
307 | /* | |
|
308 | LegendMarker *marker = markers.at(i); | |
|
309 | if (marker->isVisible()) { | |
|
310 | marker->setGeometry(geometry); | |
|
311 | const QRectF& boundingRect = marker->boundingRect(); | |
|
312 | qreal w = boundingRect.width(); | |
|
313 | qreal h = boundingRect.height(); | |
|
314 | m_width = qMax(m_width,w); | |
|
315 | m_height = qMax(m_height,h); | |
|
316 | marker->setPos(point.x(),point.y() - h); | |
|
317 | point.setX(point.x() + w); | |
|
318 | if (point.x() + w > geometry.left() + geometry.width() - right) { | |
|
319 | // Next item would go off rect. | |
|
320 | point.setX(0); | |
|
321 | point.setY(point.y() - h); | |
|
322 | if (i+1 < markers.count()) { | |
|
323 | m_height += h; | |
|
324 | } | |
|
325 | } | |
|
326 | } | |
|
327 | */ | |
|
328 | // QLegendMarker *marker = markers.at(i); | |
|
329 | 250 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
330 | 251 | if (item->isVisible()) { |
|
331 | 252 | item->setGeometry(geometry); |
@@ -360,32 +281,8 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
360 | 281 | m_height = 0; |
|
361 | 282 | qreal maxWidth = 0; |
|
362 | 283 | for (int i = 0; i < markers.count(); i++) { |
|
363 | /* | |
|
364 | LegendMarker *marker = markers.at(i); | |
|
365 | if (marker->isVisible()) { | |
|
366 | marker->setGeometry(geometry); | |
|
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 | 284 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
387 | 285 | if (item->isVisible()) { |
|
388 | // LegendMarkerItem *item = marker->d_ptr->item(); | |
|
389 | 286 | item->setGeometry(geometry); |
|
390 | 287 | const QRectF& boundingRect = item->boundingRect(); |
|
391 | 288 | qreal w = boundingRect.width(); |
@@ -420,32 +317,8 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
420 | 317 | m_height = 0; |
|
421 | 318 | qreal maxWidth = 0; |
|
422 | 319 | for (int i = 0; i < markers.count(); i++) { |
|
423 | /* | |
|
424 | LegendMarker *marker = markers.at(i); | |
|
425 | if (marker->isVisible()) { | |
|
426 | marker->setGeometry(geometry); | |
|
427 | const QRectF& boundingRect = marker->boundingRect(); | |
|
428 | qreal w = boundingRect.width(); | |
|
429 | qreal h = boundingRect.height(); | |
|
430 | m_height = qMax(m_height,h); | |
|
431 | maxWidth = qMax(maxWidth,w); | |
|
432 | marker->setPos(point.x() - w,point.y()); | |
|
433 | point.setY(point.y() + h); | |
|
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 | 320 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
447 | 321 | if (item->isVisible()) { |
|
448 | // LegendMarkerItem *item = marker->d_ptr->item(); | |
|
449 | 322 | item->setGeometry(geometry); |
|
450 | 323 | const QRectF& boundingRect = item->boundingRect(); |
|
451 | 324 | qreal w = boundingRect.width(); |
@@ -482,40 +355,6 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
482 | 355 | |
|
483 | 356 | QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
484 | 357 | { |
|
485 | /* | |
|
486 | QSizeF size(0, 0); | |
|
487 | qreal left, top, right, bottom; | |
|
488 | getContentsMargins(&left, &top, &right, &bottom); | |
|
489 | ||
|
490 | if (constraint.isValid()) { | |
|
491 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) | |
|
492 | size = size.expandedTo(marker->effectiveSizeHint(which)); | |
|
493 | size = size.boundedTo(constraint); | |
|
494 | } else if (constraint.width() >= 0) { | |
|
495 | qreal width = 0; | |
|
496 | qreal height = 0; | |
|
497 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) { | |
|
498 | width += marker->effectiveSizeHint(which).width(); | |
|
499 | height = qMax(height, marker->effectiveSizeHint(which).height()); | |
|
500 | } | |
|
501 | ||
|
502 | size = QSizeF(qMin(constraint.width(), width), height); | |
|
503 | } else if (constraint.height() >= 0) { | |
|
504 | qreal width = 0; | |
|
505 | qreal height = 0; | |
|
506 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) { | |
|
507 | width = qMax(width, marker->effectiveSizeHint(which).width()); | |
|
508 | height += height, marker->effectiveSizeHint(which).height(); | |
|
509 | } | |
|
510 | size = QSizeF(width, qMin(constraint.height(), height)); | |
|
511 | } else { | |
|
512 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) | |
|
513 | size = size.expandedTo(marker->effectiveSizeHint(which)); | |
|
514 | } | |
|
515 | size += QSize(left + right, top + bottom); | |
|
516 | return size; | |
|
517 | */ | |
|
518 | // New markers -->> | |
|
519 | 358 | QSizeF size(0, 0); |
|
520 | 359 | qreal left, top, right, bottom; |
|
521 | 360 | getContentsMargins(&left, &top, &right, &bottom); |
@@ -556,7 +395,6 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||
|
556 | 395 | } |
|
557 | 396 | size += QSize(left + right, top + bottom); |
|
558 | 397 | return size; |
|
559 | // <<-- New markers | |
|
560 | 398 | } |
|
561 | 399 | |
|
562 | 400 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -176,7 +176,7 QLegend::QLegend(QChart *chart): QGraphicsWidget(chart), | |||
|
176 | 176 | { |
|
177 | 177 | setZValue(ChartPresenter::LegendZValue); |
|
178 | 178 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
179 | QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
|
179 | QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*/*,Domain**/))); | |
|
180 | 180 | QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
181 | 181 | // QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*))); |
|
182 | 182 | setLayout(d_ptr->m_layout); |
@@ -476,9 +476,10 int QLegendPrivate::roundness(qreal size) | |||
|
476 | 476 | |
|
477 | 477 | void QLegendPrivate::appendSeries(QAbstractSeries* series) |
|
478 | 478 | { |
|
479 | // Only allow one instance of series | |
|
479 | 480 | if (!m_series.contains(series)) { |
|
480 | 481 | m_series.append(series); |
|
481 | handleSeriesAdded(series,0); | |
|
482 | handleSeriesAdded(series/*,0*/); | |
|
482 | 483 | } |
|
483 | 484 | } |
|
484 | 485 | |
@@ -490,13 +491,12 void QLegendPrivate::removeSeries(QAbstractSeries* series) | |||
|
490 | 491 | } |
|
491 | 492 | } |
|
492 | 493 | |
|
493 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
|
494 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series/*, Domain *domain*/) | |
|
494 | 495 | { |
|
495 | Q_UNUSED(domain) | |
|
496 | // Q_UNUSED(domain) | |
|
496 | 497 | |
|
497 | qDebug() << "QLegendPrivate::handleSeriesAdded"; | |
|
498 | qDebug() << "QLegendPrivate::handleSeriesAdded" << series; | |
|
498 | 499 | |
|
499 | // New markers ---> | |
|
500 | 500 | QList<QLegendMarker*> newMarkers = series->d_ptr->createLegendMarkers(q_ptr); |
|
501 | 501 | foreach (QLegendMarker* marker, newMarkers) { |
|
502 | 502 | marker->setFont(m_font); |
@@ -507,22 +507,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||
|
507 | 507 | } |
|
508 | 508 | |
|
509 | 509 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
510 | // <--- New markers | |
|
511 | ||
|
512 | /* | |
|
513 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); | |
|
514 | ||
|
515 | foreach (LegendMarker *marker, markers) { | |
|
516 | marker->setFont(m_font); | |
|
517 | marker->setLabelBrush(m_labelBrush); | |
|
518 | marker->setVisible(series->isVisible()); | |
|
519 | m_items->addToGroup(marker); | |
|
520 | m_markers << marker; | |
|
521 | } | |
|
522 | */ | |
|
523 | ||
|
524 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
|
525 | QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); | |
|
510 | // QObject::connect(series->d_ptr.data(), SIGNAL(legendPropertiesUpdated(QAbstractSeries*)), this, SLOT(handleLegendPropertiesUpdated(QAbstractSeries*))); | |
|
526 | 511 | |
|
527 | 512 | m_items->setVisible(false); |
|
528 | 513 | m_layout->invalidate(); |
@@ -530,7 +515,8 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||
|
530 | 515 | |
|
531 | 516 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
|
532 | 517 | { |
|
533 | // New markers ---> | |
|
518 | qDebug() << "QLegendPrivate::handleSeriesRemoved" << series; | |
|
519 | ||
|
534 | 520 | foreach (QLegendMarker *marker, m_legendMarkers) { |
|
535 | 521 | if (marker->series() == series) { |
|
536 | 522 | marker->d_ptr.data()->item()->setVisible(false); |
@@ -541,18 +527,8 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |||
|
541 | 527 | } |
|
542 | 528 | |
|
543 | 529 | QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
544 | // <--- New markers | |
|
530 | // QObject::disconnect(series->d_ptr.data(), SIGNAL(legendPropertiesUpdated(QAbstractSeries*)), this, SLOT(handleLegendPropertiesUpdated(QAbstractSeries*))); | |
|
545 | 531 | |
|
546 | /* | |
|
547 | foreach (LegendMarker *marker, m_markers) { | |
|
548 | if (marker->series() == series) { | |
|
549 | delete marker; | |
|
550 | m_markers.removeAll(marker); | |
|
551 | } | |
|
552 | } | |
|
553 | */ | |
|
554 | QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
|
555 | QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged())); | |
|
556 | 532 | m_layout->invalidate(); |
|
557 | 533 | } |
|
558 | 534 | |
@@ -561,33 +537,25 void QLegendPrivate::handleSeriesVisibleChanged() | |||
|
561 | 537 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); |
|
562 | 538 | Q_ASSERT(series); |
|
563 | 539 | |
|
564 | // New markers ---> | |
|
565 | 540 | foreach (QLegendMarker* marker, m_legendMarkers) { |
|
566 | 541 | if (marker->series() == series) { |
|
567 | 542 | marker->setVisible(series->isVisible()); |
|
568 | 543 | } |
|
569 | 544 | } |
|
570 | ||
|
571 | // <--- New markers | |
|
572 | /* | |
|
573 | foreach (LegendMarker* marker, m_markers) { | |
|
574 | if (marker->series() == series) { | |
|
575 | marker->setVisible(series->isVisible()); | |
|
576 | } | |
|
577 | */ | |
|
578 | 545 | m_layout->invalidate(); |
|
579 | 546 | } |
|
580 | 547 | |
|
581 | 548 | void QLegendPrivate::handleCountChanged() |
|
582 | 549 | { |
|
583 |
// With new markers, the series shoud notify markers directly |
|
|
584 | qDebug() << "handleLegendPropertiesUpdated"; | |
|
550 | // TODO: With new markers, the series should notify markers directly. | |
|
551 | // TODO: This is not a good way to handle updates. | |
|
552 | qDebug() << "handleLegendPropertiesUpdated" << series; | |
|
585 | 553 | |
|
586 | 554 | // Handle new or removed markers |
|
587 | 555 | // Handle changes of marker pen/brush/label. every property that legend is interested |
|
588 | 556 | handleSeriesRemoved(series); |
|
589 | Domain domain; | |
|
590 | handleSeriesAdded(series, &domain); | |
|
557 | // Domain domain; | |
|
558 | handleSeriesAdded(series/*, &domain*/); | |
|
591 | 559 | } |
|
592 | 560 | |
|
593 | 561 | #include "moc_qlegend.cpp" |
@@ -62,7 +62,7 public: | |||
|
62 | 62 | void removeSeries(QAbstractSeries* series); |
|
63 | 63 | |
|
64 | 64 | public Q_SLOTS: |
|
65 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |
|
65 | void handleSeriesAdded(QAbstractSeries *series/*, Domain *domain*/); | |
|
66 | 66 | void handleSeriesRemoved(QAbstractSeries *series); |
|
67 | 67 | void handleSeriesVisibleChanged(); |
|
68 | 68 | void handleCountChanged(); |
@@ -21,6 +21,7 | |||
|
21 | 21 | #include "qlegendmarker.h" |
|
22 | 22 | #include "qlegendmarker_p.h" |
|
23 | 23 | #include "legendmarkeritem_p.h" |
|
24 | #include "qlegend.h" | |
|
24 | 25 | #include <QDebug> |
|
25 | 26 | #include <QFontMetrics> |
|
26 | 27 | #include <QGraphicsSceneEvent> |
@@ -104,8 +105,9 void QLegendMarker::setVisible(bool visible) | |||
|
104 | 105 | } |
|
105 | 106 | |
|
106 | 107 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
107 | QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q) : | |
|
108 | q_ptr(q) | |
|
108 | QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) : | |
|
109 | q_ptr(q), | |
|
110 | m_legend(legend) | |
|
109 | 111 | { |
|
110 | 112 | // qDebug() << "QLegendMarkerPrivate created"; |
|
111 | 113 | m_item = new LegendMarkerItem(this); |
@@ -113,7 +115,6 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q) : | |||
|
113 | 115 | |
|
114 | 116 | QLegendMarkerPrivate::~QLegendMarkerPrivate() |
|
115 | 117 | { |
|
116 | // delete m_item; | |
|
117 | 118 | } |
|
118 | 119 | |
|
119 | 120 | void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event) |
@@ -31,6 +31,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | |
|
32 | 32 | class QLegendMarkerPrivate; |
|
33 | 33 | class QAbstractSeries; |
|
34 | class QLegend; | |
|
34 | 35 | |
|
35 | 36 | // TODO: should this be QAbstractLegendMarker? |
|
36 | 37 | class QTCOMMERCIALCHART_EXPORT QLegendMarker : public QObject |
@@ -58,9 +58,10 class QLegendMarkerPrivate : public QObject | |||
|
58 | 58 | Q_OBJECT |
|
59 | 59 | public: |
|
60 | 60 | // explicit QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q); |
|
61 | explicit QLegendMarkerPrivate(QLegendMarker *q); | |
|
61 | explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend); | |
|
62 | 62 | virtual ~QLegendMarkerPrivate(); |
|
63 | 63 | |
|
64 | // TODO: remove temporary setters/getters and use the m_item directly from public class via d_ptr | |
|
64 | 65 | void setPen(const QPen &pen); |
|
65 | 66 | QPen pen() const; |
|
66 | 67 | |
@@ -90,14 +91,13 public Q_SLOTS: | |||
|
90 | 91 | |
|
91 | 92 | protected: |
|
92 | 93 | LegendMarkerItem *m_item; |
|
94 | QLegend* m_legend; | |
|
93 | 95 | |
|
94 | 96 | private: |
|
95 | 97 | QLegendMarker *q_ptr; |
|
96 | /* | |
|
97 | QLegend* m_legend; | |
|
98 | */ | |
|
99 | 98 | |
|
100 | 99 | // New legend marker properties |
|
100 | // Moved to item. | |
|
101 | 101 | /* |
|
102 | 102 | QString m_label; |
|
103 | 103 | QBrush m_labelBrush; |
@@ -25,8 +25,8 | |||
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject *parent) : | |
|
29 |
QLegendMarker(*new QPieLegendMarkerPrivate(series,slice, |
|
|
28 | QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent) : | |
|
29 | QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent) | |
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
@@ -57,10 +57,11 QPieSlice* QPieLegendMarker::peerObject() | |||
|
57 | 57 | |
|
58 | 58 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
59 | 59 | |
|
60 |
QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieSeries *series, QPieSlice *slice, Q |
|
|
61 | QLegendMarkerPrivate(q), | |
|
60 | QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) : | |
|
61 | QLegendMarkerPrivate(q,legend), | |
|
62 | 62 | m_series(series), |
|
63 | 63 | m_slice(slice) |
|
64 | // m_legend(legend) | |
|
64 | 65 | { |
|
65 | 66 | // qDebug() << "QPieLegendMarkerPrivate created"; |
|
66 | 67 | QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); |
@@ -33,7 +33,7 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker | |||
|
33 | 33 | Q_OBJECT |
|
34 | 34 | |
|
35 | 35 | public: |
|
36 | explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject *parent = 0); | |
|
36 | explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent = 0); | |
|
37 | 37 | virtual ~QPieLegendMarker(); |
|
38 | 38 | |
|
39 | 39 | virtual QAbstractSeries* series(); |
@@ -47,7 +47,7 class QPieLegendMarkerPrivate : public QLegendMarkerPrivate | |||
|
47 | 47 | Q_OBJECT |
|
48 | 48 | public: |
|
49 | 49 | // explicit QPieLegendMarkerPrivate(QAbstractSeries *series, QPieLegendMarker *q); |
|
50 |
explicit QPieLegendMarkerPrivate(QPieSeries *series, QPieSlice *slice, Q |
|
|
50 | explicit QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend); | |
|
51 | 51 | virtual ~QPieLegendMarkerPrivate(); |
|
52 | 52 | |
|
53 | 53 | public Q_SLOTS: |
General Comments 0
You need to be logged in to leave comments.
Login now