@@ -23,8 +23,6 | |||
|
23 | 23 | #include <QApplication> |
|
24 | 24 | #include <QMainWindow> |
|
25 | 25 | |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
27 | ||
|
28 | 26 | int main(int argc, char *argv[]) |
|
29 | 27 | { |
|
30 | 28 | QApplication a(argc, argv); |
@@ -44,8 +44,6 public: | |||
|
44 | 44 | void showLegendSpinbox(); |
|
45 | 45 | void hideLegendSpinbox(); |
|
46 | 46 | |
|
47 | signals: | |
|
48 | ||
|
49 | 47 | public slots: |
|
50 | 48 | void toggleAttached(); |
|
51 | 49 | void addSlice(); |
@@ -61,10 +59,8 public slots: | |||
|
61 | 59 | void fontSizeChanged(); |
|
62 | 60 | |
|
63 | 61 | void updateLegendLayout(); |
|
64 | ||
|
65 | 62 | void handleMarkerClicked(); |
|
66 | 63 | |
|
67 | ||
|
68 | 64 | private: |
|
69 | 65 | |
|
70 | 66 | QChart *m_chart; |
@@ -26,7 +26,6 | |||
|
26 | 26 | #include "chartdataset_p.h" |
|
27 | 27 | #include "charttheme_p.h" |
|
28 | 28 | #include "qvalueaxis.h" |
|
29 | ||
|
30 | 29 | #include "qarealegendmarker.h" |
|
31 | 30 | |
|
32 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -27,7 +27,6 | |||
|
27 | 27 | #include "charttheme_p.h" |
|
28 | 28 | #include "qvalueaxis.h" |
|
29 | 29 | #include "qbarcategoryaxis.h" |
|
30 | ||
|
31 | 30 | #include "qbarlegendmarker.h" |
|
32 | 31 | |
|
33 | 32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -117,7 +117,7 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
117 | 117 | |
|
118 | 118 | QSizeF size(0, 0); |
|
119 | 119 | |
|
120 |
if (m_legend->d_ptr-> |
|
|
120 | if (m_legend->d_ptr->markers().isEmpty()) { | |
|
121 | 121 | return; |
|
122 | 122 | } |
|
123 | 123 | |
@@ -133,7 +133,7 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
133 | 133 | case Qt::AlignTop: |
|
134 | 134 | case Qt::AlignBottom: { |
|
135 | 135 | QPointF point(0,0); |
|
136 |
foreach (QLegendMarker* marker, m_legend->d_ptr-> |
|
|
136 | foreach (QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
137 | 137 | LegendMarkerItem* item = marker->d_ptr->item(); |
|
138 | 138 | if (item->isVisible()) { |
|
139 | 139 | item->setGeometry(geometry); |
@@ -155,7 +155,7 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||
|
155 | 155 | case Qt::AlignLeft: |
|
156 | 156 | case Qt::AlignRight: { |
|
157 | 157 | QPointF point(0,0); |
|
158 |
foreach (QLegendMarker* marker, m_legend->d_ptr-> |
|
|
158 | foreach (QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
159 | 159 | LegendMarkerItem* item = marker->d_ptr->item(); |
|
160 | 160 | if (item->isVisible()) { |
|
161 | 161 | item->setGeometry(geometry); |
@@ -202,7 +202,7 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||
|
202 | 202 | |
|
203 | 203 | QSizeF size(0, 0); |
|
204 | 204 | |
|
205 |
QList<QLegendMarker *> markers = m_legend->d_ptr-> |
|
|
205 | QList<QLegendMarker *> markers = m_legend->d_ptr->markers(); | |
|
206 | 206 | |
|
207 | 207 | if (markers.isEmpty()) |
|
208 | 208 | return; |
@@ -359,7 +359,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||
|
359 | 359 | getContentsMargins(&left, &top, &right, &bottom); |
|
360 | 360 | |
|
361 | 361 | if(constraint.isValid()) { |
|
362 |
foreach(QLegendMarker* marker, m_legend->d_ptr-> |
|
|
362 | foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
363 | 363 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
364 | 364 | size = size.expandedTo(item->effectiveSizeHint(which)); |
|
365 | 365 | } |
@@ -368,7 +368,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||
|
368 | 368 | else if (constraint.width() >= 0) { |
|
369 | 369 | qreal width = 0; |
|
370 | 370 | qreal height = 0; |
|
371 |
foreach(QLegendMarker* marker, m_legend->d_ptr-> |
|
|
371 | foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
372 | 372 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
373 | 373 | width+=item->effectiveSizeHint(which).width(); |
|
374 | 374 | height=qMax(height,item->effectiveSizeHint(which).height()); |
@@ -379,7 +379,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||
|
379 | 379 | else if (constraint.height() >= 0) { |
|
380 | 380 | qreal width = 0; |
|
381 | 381 | qreal height = 0; |
|
382 |
foreach(QLegendMarker* marker, m_legend->d_ptr-> |
|
|
382 | foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
383 | 383 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
384 | 384 | width=qMax(width,item->effectiveSizeHint(which).width()); |
|
385 | 385 | height+=height,item->effectiveSizeHint(which).height(); |
@@ -387,7 +387,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||
|
387 | 387 | size = QSizeF(width,qMin(constraint.height(),height)); |
|
388 | 388 | } |
|
389 | 389 | else { |
|
390 |
foreach(QLegendMarker* marker, m_legend->d_ptr-> |
|
|
390 | foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { | |
|
391 | 391 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
392 | 392 | size = size.expandedTo(item->effectiveSizeHint(which)); |
|
393 | 393 | } |
@@ -63,8 +63,6 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSe | |||
|
63 | 63 | |
|
64 | 64 | QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate() |
|
65 | 65 | { |
|
66 | QObject::disconnect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated())); | |
|
67 | QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); | |
|
68 | 66 | } |
|
69 | 67 | |
|
70 | 68 | QAreaSeries* QAreaLegendMarkerPrivate::series() |
@@ -71,9 +71,6 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractB | |||
|
71 | 71 | |
|
72 | 72 | QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate() |
|
73 | 73 | { |
|
74 | QObject::disconnect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated())); | |
|
75 | QObject::disconnect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated())); | |
|
76 | QObject::disconnect(m_barset, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
77 | 74 | } |
|
78 | 75 | |
|
79 | 76 | QAbstractBarSeries* QBarLegendMarkerPrivate::series() |
@@ -61,7 +61,7 private: | |||
|
61 | 61 | QAbstractBarSeries* m_series; |
|
62 | 62 | QBarSet* m_barset; |
|
63 | 63 | |
|
64 |
friend class QLegendPrivate; |
|
|
64 | friend class QLegendPrivate; | |
|
65 | 65 | Q_DECLARE_PUBLIC(QBarLegendMarker) |
|
66 | 66 | }; |
|
67 | 67 |
@@ -268,12 +268,12 void QLegend::setFont(const QFont &font) | |||
|
268 | 268 | if (d_ptr->m_font != font) |
|
269 | 269 | d_ptr->m_font = font; |
|
270 | 270 | |
|
271 |
foreach (QLegendMarker *marker, d_ptr-> |
|
|
271 | foreach (QLegendMarker *marker, d_ptr->markers()) { | |
|
272 | 272 | marker->setFont(d_ptr->m_font); |
|
273 | } | |
|
273 | 274 |
|
|
274 | 275 |
|
|
275 | 276 | } |
|
276 | } | |
|
277 | 277 | |
|
278 | 278 | QFont QLegend::font() const |
|
279 | 279 | { |
@@ -301,7 +301,7 void QLegend::setLabelBrush(const QBrush &brush) | |||
|
301 | 301 | { |
|
302 | 302 | if (d_ptr->m_labelBrush != brush) { |
|
303 | 303 | d_ptr->m_labelBrush = brush; |
|
304 |
foreach (QLegendMarker *marker, d_ptr-> |
|
|
304 | foreach (QLegendMarker *marker, d_ptr->markers()) { | |
|
305 | 305 | marker->setLabelBrush(d_ptr->m_labelBrush); |
|
306 | 306 | // Note: The pen of the marker rectangle could be exposed in the public QLegend API |
|
307 | 307 | // instead of mapping it from label brush color |
@@ -397,16 +397,14 bool QLegend::isBackgroundVisible() const | |||
|
397 | 397 | return d_ptr->m_backgroundVisible; |
|
398 | 398 | } |
|
399 | 399 | |
|
400 | ||
|
401 | 400 | QList<QLegendMarker*> QLegend::markers() const |
|
402 | 401 | { |
|
403 | // TODO: name of PIMPL method will change. | |
|
404 | return d_ptr->legendMarkers(); | |
|
402 | return d_ptr->markers(); | |
|
405 | 403 | } |
|
406 | 404 | |
|
407 |
void QLegend::a |
|
|
405 | void QLegend::addSeries(QAbstractSeries* series) | |
|
408 | 406 | { |
|
409 |
d_ptr->a |
|
|
407 | d_ptr->addSeries(series); | |
|
410 | 408 | } |
|
411 | 409 | |
|
412 | 410 | void QLegend::removeSeries(QAbstractSeries* series) |
@@ -475,7 +473,7 int QLegendPrivate::roundness(qreal size) | |||
|
475 | 473 | return 100 * m_diameter / int(size); |
|
476 | 474 | } |
|
477 | 475 | |
|
478 |
void QLegendPrivate::a |
|
|
476 | void QLegendPrivate::addSeries(QAbstractSeries* series) | |
|
479 | 477 | { |
|
480 | 478 | // Only allow one instance of series |
|
481 | 479 | if (m_series.contains(series)) { |
@@ -532,7 +530,7 void QLegendPrivate::removeSeries(QAbstractSeries* series) | |||
|
532 | 530 | |
|
533 | 531 | // Find out, which markers to remove |
|
534 | 532 | QList<QLegendMarker *> removed; |
|
535 |
foreach (QLegendMarker *m, m_ |
|
|
533 | foreach (QLegendMarker *m, m_markers) { | |
|
536 | 534 | if (m->series() == series) { |
|
537 | 535 | removed << m; |
|
538 | 536 | } |
@@ -577,7 +575,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series) | |||
|
577 | 575 | { |
|
578 | 576 | // Moved to appendSeries |
|
579 | 577 | // This slot is just to make old code work for now. |
|
580 |
a |
|
|
578 | addSeries(series); | |
|
581 | 579 | } |
|
582 | 580 | |
|
583 | 581 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
@@ -592,7 +590,7 void QLegendPrivate::handleSeriesVisibleChanged() | |||
|
592 | 590 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); |
|
593 | 591 | Q_ASSERT(series); |
|
594 | 592 | |
|
595 |
foreach (QLegendMarker* marker, m_ |
|
|
593 | foreach (QLegendMarker* marker, m_markers) { | |
|
596 | 594 | if (marker->series() == series) { |
|
597 | 595 | marker->setVisible(series->isVisible()); |
|
598 | 596 | } |
@@ -610,7 +608,7 void QLegendPrivate::handleCountChanged() | |||
|
610 | 608 | |
|
611 | 609 | // Find out removed markers and created markers |
|
612 | 610 | QList<QLegendMarker *> removedMarkers; |
|
613 |
foreach (QLegendMarker *oldMarker, m_ |
|
|
611 | foreach (QLegendMarker *oldMarker, m_markers) { | |
|
614 | 612 | // we have marker, which is related to sender. |
|
615 | 613 | if (oldMarker->series() == series) { |
|
616 | 614 | bool found = false; |
@@ -642,7 +640,7 void QLegendPrivate::addMarkers(QList<QLegendMarker *> markers) | |||
|
642 | 640 | { |
|
643 | 641 | foreach (QLegendMarker* marker, markers) { |
|
644 | 642 | m_items->addToGroup(marker->d_ptr.data()->item()); |
|
645 |
m_ |
|
|
643 | m_markers << marker; | |
|
646 | 644 | } |
|
647 | 645 | } |
|
648 | 646 | |
@@ -652,7 +650,7 void QLegendPrivate::removeMarkers(QList<QLegendMarker *> markers) | |||
|
652 | 650 | marker->d_ptr->item()->setVisible(false); |
|
653 | 651 | m_items->removeFromGroup(marker->d_ptr->item()); |
|
654 | 652 | delete marker; |
|
655 |
m_ |
|
|
653 | m_markers.removeOne(marker); | |
|
656 | 654 | } |
|
657 | 655 | } |
|
658 | 656 |
@@ -81,7 +81,7 public: | |||
|
81 | 81 | |
|
82 | 82 | // New stuff: |
|
83 | 83 | QList <QLegendMarker*> markers() const; |
|
84 |
void a |
|
|
84 | void addSeries(QAbstractSeries* series); | |
|
85 | 85 | void removeSeries(QAbstractSeries* series); |
|
86 | 86 | |
|
87 | 87 | protected: |
@@ -55,8 +55,8 public: | |||
|
55 | 55 | QGraphicsItemGroup* items() { return m_items; } |
|
56 | 56 | |
|
57 | 57 | // New stuff: |
|
58 |
QList<QLegendMarker*> |
|
|
59 |
void a |
|
|
58 | QList<QLegendMarker*> markers() { return m_markers; } | |
|
59 | void addSeries(QAbstractSeries* series); | |
|
60 | 60 | void removeSeries(QAbstractSeries* series); |
|
61 | 61 | |
|
62 | 62 | public Q_SLOTS: |
@@ -89,7 +89,7 private: | |||
|
89 | 89 | |
|
90 | 90 | friend class QLegend; |
|
91 | 91 | friend class LegendLayout; |
|
92 | QList<QLegendMarker*> m_legendMarkers; // TODO: rename to m_markers eventually. | |
|
92 | QList<QLegendMarker*> m_markers; | |
|
93 | 93 | QList<QAbstractSeries*> m_series; |
|
94 | 94 | |
|
95 | 95 | friend class QLegend; |
@@ -71,9 +71,6 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries | |||
|
71 | 71 | |
|
72 | 72 | QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate() |
|
73 | 73 | { |
|
74 | QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); | |
|
75 | QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); | |
|
76 | QObject::disconnect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
77 | 74 | } |
|
78 | 75 | |
|
79 | 76 | QPieSeries* QPieLegendMarkerPrivate::series() |
@@ -63,8 +63,6 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *se | |||
|
63 | 63 | |
|
64 | 64 | QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate() |
|
65 | 65 | { |
|
66 | QObject::disconnect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated())); | |
|
67 | QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); | |
|
68 | 66 | } |
|
69 | 67 | |
|
70 | 68 | QAbstractSeries* QXYLegendMarkerPrivate::series() |
General Comments 0
You need to be logged in to leave comments.
Login now