@@ -133,12 +133,12 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||||
133 | case Qt::AlignTop: |
|
133 | case Qt::AlignTop: | |
134 | case Qt::AlignBottom: { |
|
134 | case Qt::AlignBottom: { | |
135 | QPointF point(0,0); |
|
135 | QPointF point(0,0); | |
136 |
foreach (QLegendMarker* |
|
136 | foreach (QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
137 |
LegendMarkerItem* |
|
137 | LegendMarkerItem *item = marker->d_ptr->item(); | |
138 | if (item->isVisible()) { |
|
138 | if (item->isVisible()) { | |
139 | item->setGeometry(geometry); |
|
139 | item->setGeometry(geometry); | |
140 | item->setPos(point.x(),geometry.height()/2 - item->boundingRect().height()/2); |
|
140 | item->setPos(point.x(),geometry.height()/2 - item->boundingRect().height()/2); | |
141 |
const QRectF& |
|
141 | const QRectF &rect = item->boundingRect(); | |
142 | size = size.expandedTo(rect.size()); |
|
142 | size = size.expandedTo(rect.size()); | |
143 | qreal w = rect.width(); |
|
143 | qreal w = rect.width(); | |
144 | m_width+=w; |
|
144 | m_width+=w; | |
@@ -155,12 +155,12 void LegendLayout::setAttachedGeometry(const QRectF &rect) | |||||
155 | case Qt::AlignLeft: |
|
155 | case Qt::AlignLeft: | |
156 | case Qt::AlignRight: { |
|
156 | case Qt::AlignRight: { | |
157 | QPointF point(0,0); |
|
157 | QPointF point(0,0); | |
158 |
foreach (QLegendMarker* |
|
158 | foreach (QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
159 |
LegendMarkerItem* |
|
159 | LegendMarkerItem *item = marker->d_ptr->item(); | |
160 | if (item->isVisible()) { |
|
160 | if (item->isVisible()) { | |
161 | item->setGeometry(geometry); |
|
161 | item->setGeometry(geometry); | |
162 | item->setPos(point); |
|
162 | item->setPos(point); | |
163 |
const QRectF& |
|
163 | const QRectF &rect = item->boundingRect(); | |
164 | qreal h = rect.height(); |
|
164 | qreal h = rect.height(); | |
165 | size = size.expandedTo(rect.size()); |
|
165 | size = size.expandedTo(rect.size()); | |
166 | m_height+=h; |
|
166 | m_height+=h; | |
@@ -217,7 +217,7 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||||
217 | if (item->isVisible()) { |
|
217 | if (item->isVisible()) { | |
218 | item->setGeometry(geometry); |
|
218 | item->setGeometry(geometry); | |
219 | item->setPos(point.x(),point.y()); |
|
219 | item->setPos(point.x(),point.y()); | |
220 |
const QRectF& |
|
220 | const QRectF &boundingRect = item->boundingRect(); | |
221 | qreal w = boundingRect.width(); |
|
221 | qreal w = boundingRect.width(); | |
222 | qreal h = boundingRect.height(); |
|
222 | qreal h = boundingRect.height(); | |
223 | m_width = qMax(m_width,w); |
|
223 | m_width = qMax(m_width,w); | |
@@ -249,7 +249,7 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||||
249 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
249 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); | |
250 | if (item->isVisible()) { |
|
250 | if (item->isVisible()) { | |
251 | item->setGeometry(geometry); |
|
251 | item->setGeometry(geometry); | |
252 |
const QRectF& |
|
252 | const QRectF &boundingRect = item->boundingRect(); | |
253 | qreal w = boundingRect.width(); |
|
253 | qreal w = boundingRect.width(); | |
254 | qreal h = boundingRect.height(); |
|
254 | qreal h = boundingRect.height(); | |
255 | m_width = qMax(m_width,w); |
|
255 | m_width = qMax(m_width,w); | |
@@ -283,7 +283,7 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||||
283 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
283 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); | |
284 | if (item->isVisible()) { |
|
284 | if (item->isVisible()) { | |
285 | item->setGeometry(geometry); |
|
285 | item->setGeometry(geometry); | |
286 |
const QRectF& |
|
286 | const QRectF &boundingRect = item->boundingRect(); | |
287 | qreal w = boundingRect.width(); |
|
287 | qreal w = boundingRect.width(); | |
288 | qreal h = boundingRect.height(); |
|
288 | qreal h = boundingRect.height(); | |
289 | m_height = qMax(m_height,h); |
|
289 | m_height = qMax(m_height,h); | |
@@ -319,7 +319,7 void LegendLayout::setDettachedGeometry(const QRectF &rect) | |||||
319 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); |
|
319 | LegendMarkerItem *item = markers.at(i)->d_ptr->item(); | |
320 | if (item->isVisible()) { |
|
320 | if (item->isVisible()) { | |
321 | item->setGeometry(geometry); |
|
321 | item->setGeometry(geometry); | |
322 |
const QRectF& |
|
322 | const QRectF &boundingRect = item->boundingRect(); | |
323 | qreal w = boundingRect.width(); |
|
323 | qreal w = boundingRect.width(); | |
324 | qreal h = boundingRect.height(); |
|
324 | qreal h = boundingRect.height(); | |
325 | m_height = qMax(m_height,h); |
|
325 | m_height = qMax(m_height,h); | |
@@ -359,7 +359,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||||
359 | getContentsMargins(&left, &top, &right, &bottom); |
|
359 | getContentsMargins(&left, &top, &right, &bottom); | |
360 |
|
360 | |||
361 | if(constraint.isValid()) { |
|
361 | if(constraint.isValid()) { | |
362 |
foreach(QLegendMarker* |
|
362 | foreach(QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
363 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
363 | LegendMarkerItem *item = marker->d_ptr->item(); | |
364 | size = size.expandedTo(item->effectiveSizeHint(which)); |
|
364 | size = size.expandedTo(item->effectiveSizeHint(which)); | |
365 | } |
|
365 | } | |
@@ -368,7 +368,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||||
368 | else if (constraint.width() >= 0) { |
|
368 | else if (constraint.width() >= 0) { | |
369 | qreal width = 0; |
|
369 | qreal width = 0; | |
370 | qreal height = 0; |
|
370 | qreal height = 0; | |
371 |
foreach(QLegendMarker* |
|
371 | foreach(QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
372 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
372 | LegendMarkerItem *item = marker->d_ptr->item(); | |
373 | width+=item->effectiveSizeHint(which).width(); |
|
373 | width+=item->effectiveSizeHint(which).width(); | |
374 | height=qMax(height,item->effectiveSizeHint(which).height()); |
|
374 | height=qMax(height,item->effectiveSizeHint(which).height()); | |
@@ -379,7 +379,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||||
379 | else if (constraint.height() >= 0) { |
|
379 | else if (constraint.height() >= 0) { | |
380 | qreal width = 0; |
|
380 | qreal width = 0; | |
381 | qreal height = 0; |
|
381 | qreal height = 0; | |
382 |
foreach(QLegendMarker* |
|
382 | foreach(QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
383 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
383 | LegendMarkerItem *item = marker->d_ptr->item(); | |
384 | width=qMax(width,item->effectiveSizeHint(which).width()); |
|
384 | width=qMax(width,item->effectiveSizeHint(which).width()); | |
385 | height+=height,item->effectiveSizeHint(which).height(); |
|
385 | height+=height,item->effectiveSizeHint(which).height(); | |
@@ -387,7 +387,7 QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons | |||||
387 | size = QSizeF(width,qMin(constraint.height(),height)); |
|
387 | size = QSizeF(width,qMin(constraint.height(),height)); | |
388 | } |
|
388 | } | |
389 | else { |
|
389 | else { | |
390 |
foreach(QLegendMarker* |
|
390 | foreach(QLegendMarker *marker, m_legend->d_ptr->markers()) { | |
391 | LegendMarkerItem *item = marker->d_ptr->item(); |
|
391 | LegendMarkerItem *item = marker->d_ptr->item(); | |
392 | size = size.expandedTo(item->effectiveSizeHint(which)); |
|
392 | size = size.expandedTo(item->effectiveSizeHint(which)); | |
393 | } |
|
393 | } |
@@ -98,7 +98,7 QBrush LegendMarkerItem::labelBrush() const | |||||
98 | return m_textItem->brush(); |
|
98 | return m_textItem->brush(); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 |
void LegendMarkerItem::setGeometry(const QRectF& |
|
101 | void LegendMarkerItem::setGeometry(const QRectF &rect) | |
102 | { |
|
102 | { | |
103 | QFontMetrics fn (m_font); |
|
103 | QFontMetrics fn (m_font); | |
104 |
|
104 | |||
@@ -116,7 +116,7 void LegendMarkerItem::setGeometry(const QRectF& rect) | |||||
116 | else |
|
116 | else | |
117 | m_textItem->setText(m_label); |
|
117 | m_textItem->setText(m_label); | |
118 |
|
118 | |||
119 |
const QRectF& |
|
119 | const QRectF &textRect = m_textItem->boundingRect(); | |
120 |
|
120 | |||
121 |
|
121 | |||
122 | m_textItem->setPos(x-m_margin,y/2 - textRect.height()/2); |
|
122 | m_textItem->setPos(x-m_margin,y/2 - textRect.height()/2); |
@@ -65,13 +65,13 public: | |||||
65 | void setLabelBrush(const QBrush &brush); |
|
65 | void setLabelBrush(const QBrush &brush); | |
66 | QBrush labelBrush() const; |
|
66 | QBrush labelBrush() const; | |
67 |
|
67 | |||
68 |
void setGeometry(const QRectF& |
|
68 | void setGeometry(const QRectF &rect); | |
69 |
|
69 | |||
70 | QRectF boundingRect() const; |
|
70 | QRectF boundingRect() const; | |
71 |
|
71 | |||
72 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
72 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
73 |
|
73 | |||
74 |
QSizeF sizeHint (Qt::SizeHint which, const QSizeF& |
|
74 | QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint) const; | |
75 |
|
75 | |||
76 | // Event handlers, logic delegated to MouseEventHandler |
|
76 | // Event handlers, logic delegated to MouseEventHandler | |
77 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
77 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
@@ -39,14 +39,14 void MouseEventHandler::setMoveTreshold(qreal treshold) | |||||
39 | m_treshold = treshold; |
|
39 | m_treshold = treshold; | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 |
void MouseEventHandler::handleMousePressEvent(QGraphicsSceneMouseEvent* |
|
42 | void MouseEventHandler::handleMousePressEvent(QGraphicsSceneMouseEvent *event) | |
43 | { |
|
43 | { | |
44 | m_lastPos = event->screenPos(); |
|
44 | m_lastPos = event->screenPos(); | |
45 | m_state = Pressed; |
|
45 | m_state = Pressed; | |
46 | event->accept(); |
|
46 | event->accept(); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 |
void MouseEventHandler::handleMouseMoveEvent(QGraphicsSceneMouseEvent* |
|
49 | void MouseEventHandler::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) | |
50 | { |
|
50 | { | |
51 | QPointF delta = event->screenPos() - m_lastPos; |
|
51 | QPointF delta = event->screenPos() - m_lastPos; | |
52 |
|
52 | |||
@@ -75,7 +75,7 void MouseEventHandler::handleMouseMoveEvent(QGraphicsSceneMouseEvent* event) | |||||
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 |
void MouseEventHandler::handleMouseReleaseEvent(QGraphicsSceneMouseEvent* |
|
78 | void MouseEventHandler::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) | |
79 | { |
|
79 | { | |
80 | m_lastPos = event->screenPos(); |
|
80 | m_lastPos = event->screenPos(); | |
81 |
|
81 |
@@ -74,9 +74,9 public: | |||||
74 | virtual void mouseMoved(const QPointF &delta) = 0; |
|
74 | virtual void mouseMoved(const QPointF &delta) = 0; | |
75 | virtual void mouseReleased(const QPointF &pos) = 0; |
|
75 | virtual void mouseReleased(const QPointF &pos) = 0; | |
76 |
|
76 | |||
77 |
void handleMousePressEvent(QGraphicsSceneMouseEvent* |
|
77 | void handleMousePressEvent(QGraphicsSceneMouseEvent *event); | |
78 |
void handleMouseMoveEvent(QGraphicsSceneMouseEvent* |
|
78 | void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event); | |
79 |
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent* |
|
79 | void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event); | |
80 |
|
80 | |||
81 | private: |
|
81 | private: | |
82 | QPointF m_lastPos; |
|
82 | QPointF m_lastPos; |
@@ -25,7 +25,7 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
QAreaLegendMarker::QAreaLegendMarker(QAreaSeries* |
|
28 | QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) : | |
29 | QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent) |
|
29 | QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } |
@@ -34,7 +34,7 class QTCOMMERCIALCHART_EXPORT QAreaLegendMarker : public QLegendMarker | |||||
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 |
explicit QAreaLegendMarker(QAreaSeries* |
|
37 | explicit QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent = 0); | |
38 | virtual ~QAreaLegendMarker(); |
|
38 | virtual ~QAreaLegendMarker(); | |
39 |
|
39 | |||
40 | virtual LegendMarkerType type() { return LegendMarkerTypeArea; } |
|
40 | virtual LegendMarkerType type() { return LegendMarkerTypeArea; } |
@@ -54,7 +54,7 public Q_SLOTS: | |||||
54 |
|
54 | |||
55 | private: |
|
55 | private: | |
56 | QAreaLegendMarker *q_ptr; |
|
56 | QAreaLegendMarker *q_ptr; | |
57 |
QAreaSeries* |
|
57 | QAreaSeries *m_series; | |
58 |
|
58 | |||
59 | Q_DECLARE_PUBLIC(QAreaLegendMarker) |
|
59 | Q_DECLARE_PUBLIC(QAreaLegendMarker) | |
60 | }; |
|
60 | }; |
@@ -25,7 +25,7 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries* |
|
28 | QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) : | |
29 | QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent) |
|
29 | QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } |
@@ -34,7 +34,7 class QTCOMMERCIALCHART_EXPORT QBarLegendMarker : public QLegendMarker | |||||
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | public: |
|
36 | public: | |
37 |
explicit QBarLegendMarker(QAbstractBarSeries* |
|
37 | explicit QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent = 0); | |
38 | virtual ~QBarLegendMarker(); |
|
38 | virtual ~QBarLegendMarker(); | |
39 |
|
39 | |||
40 | virtual LegendMarkerType type() { return LegendMarkerTypeBar; } |
|
40 | virtual LegendMarkerType type() { return LegendMarkerTypeBar; } |
@@ -55,8 +55,8 public Q_SLOTS: | |||||
55 |
|
55 | |||
56 | private: |
|
56 | private: | |
57 | QBarLegendMarker *q_ptr; |
|
57 | QBarLegendMarker *q_ptr; | |
58 |
QAbstractBarSeries* |
|
58 | QAbstractBarSeries *m_series; | |
59 |
QBarSet* |
|
59 | QBarSet *m_barset; | |
60 |
|
60 | |||
61 | Q_DECLARE_PUBLIC(QBarLegendMarker) |
|
61 | Q_DECLARE_PUBLIC(QBarLegendMarker) | |
62 | }; |
|
62 | }; |
@@ -24,29 +24,14 | |||||
24 | #include "qabstractseries_p.h" |
|
24 | #include "qabstractseries_p.h" | |
25 | #include "qchart_p.h" |
|
25 | #include "qchart_p.h" | |
26 | #include "legendlayout_p.h" |
|
26 | #include "legendlayout_p.h" | |
27 | #include "qxyseries.h" |
|
|||
28 | #include "qlineseries.h" |
|
|||
29 | #include "qareaseries.h" |
|
|||
30 | #include "qscatterseries.h" |
|
|||
31 | #include "qsplineseries.h" |
|
|||
32 | #include "qabstractbarseries.h" |
|
|||
33 | #include "qstackedbarseries.h" |
|
|||
34 | #include "qpercentbarseries.h" |
|
|||
35 | #include "qbarset.h" |
|
|||
36 | #include "qpieseries.h" |
|
|||
37 | #include "qpieseries_p.h" |
|
|||
38 | #include "qpieslice.h" |
|
|||
39 | #include "chartpresenter_p.h" |
|
27 | #include "chartpresenter_p.h" | |
40 | #include "chartlayout_p.h" |
|
28 | #include "chartlayout_p.h" | |
41 | #include <QPainter> |
|
|||
42 | #include <QPen> |
|
|||
43 | #include <QTimer> |
|
|||
44 | #include <QGraphicsSceneEvent> |
|
|||
45 | #include <QGraphicsItemGroup> |
|
|||
46 |
|
||||
47 | #include "qlegendmarker.h" |
|
29 | #include "qlegendmarker.h" | |
48 | #include "qlegendmarker_p.h" |
|
30 | #include "qlegendmarker_p.h" | |
49 | #include "legendmarkeritem_p.h" |
|
31 | #include "legendmarkeritem_p.h" | |
|
32 | #include <QPainter> | |||
|
33 | #include <QPen> | |||
|
34 | #include <QGraphicsItemGroup> | |||
50 |
|
35 | |||
51 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
52 |
|
37 | |||
@@ -396,17 +381,17 bool QLegend::isBackgroundVisible() const | |||||
396 | return d_ptr->m_backgroundVisible; |
|
381 | return d_ptr->m_backgroundVisible; | |
397 | } |
|
382 | } | |
398 |
|
383 | |||
399 | QList<QLegendMarker*> QLegend::markers() const |
|
384 | QList<QLegendMarker*> QLegend::markers(QAbstractSeries *series) const | |
400 | { |
|
385 | { | |
401 | return d_ptr->markers(); |
|
386 | return d_ptr->markers(series); | |
402 | } |
|
387 | } | |
403 |
|
388 | |||
404 |
void QLegend::addSeries(QAbstractSeries* |
|
389 | void QLegend::addSeries(QAbstractSeries *series) | |
405 | { |
|
390 | { | |
406 | d_ptr->addSeries(series); |
|
391 | d_ptr->addSeries(series); | |
407 | } |
|
392 | } | |
408 |
|
393 | |||
409 |
void QLegend::removeSeries(QAbstractSeries* |
|
394 | void QLegend::removeSeries(QAbstractSeries *series) | |
410 | { |
|
395 | { | |
411 | d_ptr->removeSeries(series); |
|
396 | d_ptr->removeSeries(series); | |
412 | } |
|
397 | } | |
@@ -472,7 +457,24 int QLegendPrivate::roundness(qreal size) | |||||
472 | return 100 * m_diameter / int(size); |
|
457 | return 100 * m_diameter / int(size); | |
473 | } |
|
458 | } | |
474 |
|
459 | |||
475 |
|
|
460 | QList<QLegendMarker*> QLegendPrivate::markers(QAbstractSeries *series) | |
|
461 | { | |||
|
462 | // Return all markers | |||
|
463 | if (!series) { | |||
|
464 | return m_markers; | |||
|
465 | } | |||
|
466 | ||||
|
467 | // Create filtered list | |||
|
468 | QList<QLegendMarker *> markers; | |||
|
469 | foreach (QLegendMarker *marker, m_markers) { | |||
|
470 | if (marker->series() == series) { | |||
|
471 | markers.append(marker); | |||
|
472 | } | |||
|
473 | } | |||
|
474 | return markers; | |||
|
475 | } | |||
|
476 | ||||
|
477 | void QLegendPrivate::addSeries(QAbstractSeries *series) | |||
476 | { |
|
478 | { | |
477 | // Only allow one instance of series |
|
479 | // Only allow one instance of series | |
478 | if (m_series.contains(series)) { |
|
480 | if (m_series.contains(series)) { | |
@@ -491,7 +493,7 void QLegendPrivate::addSeries(QAbstractSeries* series) | |||||
491 | m_layout->invalidate(); |
|
493 | m_layout->invalidate(); | |
492 | } |
|
494 | } | |
493 |
|
495 | |||
494 |
void QLegendPrivate::removeSeries(QAbstractSeries* |
|
496 | void QLegendPrivate::removeSeries(QAbstractSeries *series) | |
495 | { |
|
497 | { | |
496 | if (m_series.contains(series)) { |
|
498 | if (m_series.contains(series)) { | |
497 | m_series.removeOne(series); |
|
499 | m_series.removeOne(series); | |
@@ -531,7 +533,7 void QLegendPrivate::handleSeriesVisibleChanged() | |||||
531 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); |
|
533 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); | |
532 | Q_ASSERT(series); |
|
534 | Q_ASSERT(series); | |
533 |
|
535 | |||
534 |
foreach (QLegendMarker* |
|
536 | foreach (QLegendMarker *marker, m_markers) { | |
535 | if (marker->series() == series) { |
|
537 | if (marker->series() == series) { | |
536 | marker->setVisible(series->isVisible()); |
|
538 | marker->setVisible(series->isVisible()); | |
537 | } |
|
539 | } | |
@@ -579,7 +581,7 void QLegendPrivate::handleCountChanged() | |||||
579 |
|
581 | |||
580 | void QLegendPrivate::addMarkers(QList<QLegendMarker *> markers) |
|
582 | void QLegendPrivate::addMarkers(QList<QLegendMarker *> markers) | |
581 | { |
|
583 | { | |
582 |
foreach (QLegendMarker* |
|
584 | foreach (QLegendMarker *marker, markers) { | |
583 | m_items->addToGroup(marker->d_ptr.data()->item()); |
|
585 | m_items->addToGroup(marker->d_ptr.data()->item()); | |
584 | m_markers << marker; |
|
586 | m_markers << marker; | |
585 | } |
|
587 | } | |
@@ -597,7 +599,7 void QLegendPrivate::removeMarkers(QList<QLegendMarker *> markers) | |||||
597 |
|
599 | |||
598 | void QLegendPrivate::decorateMarkers(QList<QLegendMarker *> markers) |
|
600 | void QLegendPrivate::decorateMarkers(QList<QLegendMarker *> markers) | |
599 | { |
|
601 | { | |
600 |
foreach (QLegendMarker* |
|
602 | foreach (QLegendMarker *marker, markers) { | |
601 | marker->setFont(m_font); |
|
603 | marker->setFont(m_font); | |
602 | marker->setLabelBrush(m_labelBrush); |
|
604 | marker->setLabelBrush(m_labelBrush); | |
603 | } |
|
605 | } |
@@ -80,9 +80,9 public: | |||||
80 | bool isBackgroundVisible() const; |
|
80 | bool isBackgroundVisible() const; | |
81 |
|
81 | |||
82 | // New stuff: |
|
82 | // New stuff: | |
83 | QList <QLegendMarker*> markers() const; |
|
83 | QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const; | |
84 |
void addSeries(QAbstractSeries* |
|
84 | void addSeries(QAbstractSeries *series); | |
85 |
void removeSeries(QAbstractSeries* |
|
85 | void removeSeries(QAbstractSeries *series); | |
86 |
|
86 | |||
87 | protected: |
|
87 | protected: | |
88 | void hideEvent(QHideEvent *event); |
|
88 | void hideEvent(QHideEvent *event); |
@@ -55,10 +55,9 public: | |||||
55 |
|
55 | |||
56 | QGraphicsItemGroup* items() { return m_items; } |
|
56 | QGraphicsItemGroup* items() { return m_items; } | |
57 |
|
57 | |||
58 | // New stuff: |
|
58 | QList<QLegendMarker*> markers(QAbstractSeries *series = 0); | |
59 | QList<QLegendMarker*> markers() { return m_markers; } |
|
59 | void addSeries(QAbstractSeries *series); | |
60 |
void |
|
60 | void removeSeries(QAbstractSeries *series); | |
61 | void removeSeries(QAbstractSeries* series); |
|
|||
62 |
|
61 | |||
63 | public Q_SLOTS: |
|
62 | public Q_SLOTS: | |
64 | void handleSeriesAdded(QAbstractSeries *series); |
|
63 | void handleSeriesAdded(QAbstractSeries *series); | |
@@ -76,8 +75,8 private: | |||||
76 | QLegend *q_ptr; |
|
75 | QLegend *q_ptr; | |
77 | ChartPresenter *m_presenter; |
|
76 | ChartPresenter *m_presenter; | |
78 | LegendLayout *m_layout; |
|
77 | LegendLayout *m_layout; | |
79 |
QChart* |
|
78 | QChart *m_chart; | |
80 |
QGraphicsItemGroup* |
|
79 | QGraphicsItemGroup *m_items; | |
81 | Qt::Alignment m_alignment; |
|
80 | Qt::Alignment m_alignment; | |
82 | QBrush m_brush; |
|
81 | QBrush m_brush; | |
83 | QPen m_pen; |
|
82 | QPen m_pen; | |
@@ -88,13 +87,12 private: | |||||
88 | bool m_attachedToChart; |
|
87 | bool m_attachedToChart; | |
89 | bool m_backgroundVisible; |
|
88 | bool m_backgroundVisible; | |
90 |
|
89 | |||
91 | friend class QLegend; |
|
90 | QList<QLegendMarker *> m_markers; | |
92 | friend class LegendLayout; |
|
91 | QList<QAbstractSeries *> m_series; | |
93 | QList<QLegendMarker*> m_markers; |
|
|||
94 | QList<QAbstractSeries*> m_series; |
|
|||
95 |
|
92 | |||
96 | friend class QLegend; |
|
93 | friend class QLegend; | |
97 | friend class LegendMarkerItem; |
|
94 | friend class LegendMarkerItem; | |
|
95 | friend class LegendLayout; | |||
98 | }; |
|
96 | }; | |
99 |
|
97 | |||
100 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -70,7 +70,7 public Q_SLOTS: | |||||
70 |
|
70 | |||
71 | protected: |
|
71 | protected: | |
72 | LegendMarkerItem *m_item; |
|
72 | LegendMarkerItem *m_item; | |
73 |
QLegend* |
|
73 | QLegend *m_legend; | |
74 |
|
74 | |||
75 | private: |
|
75 | private: | |
76 | QLegendMarker *q_ptr; |
|
76 | QLegendMarker *q_ptr; |
@@ -25,7 +25,7 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
QPieLegendMarker::QPieLegendMarker(QPieSeries* |
|
28 | QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) : | |
29 | QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent) |
|
29 | QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } |
@@ -35,7 +35,7 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker | |||||
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 |
|
36 | |||
37 | public: |
|
37 | public: | |
38 |
explicit QPieLegendMarker(QPieSeries* |
|
38 | explicit QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent = 0); | |
39 | virtual ~QPieLegendMarker(); |
|
39 | virtual ~QPieLegendMarker(); | |
40 |
|
40 | |||
41 | virtual LegendMarkerType type() { return LegendMarkerTypePie; } |
|
41 | virtual LegendMarkerType type() { return LegendMarkerTypePie; } |
@@ -57,8 +57,8 public Q_SLOTS: | |||||
57 | private: |
|
57 | private: | |
58 | QPieLegendMarker *q_ptr; |
|
58 | QPieLegendMarker *q_ptr; | |
59 |
|
59 | |||
60 |
QPieSeries* |
|
60 | QPieSeries *m_series; | |
61 |
QPieSlice* |
|
61 | QPieSlice *m_slice; | |
62 |
|
62 | |||
63 | Q_DECLARE_PUBLIC(QPieLegendMarker) |
|
63 | Q_DECLARE_PUBLIC(QPieLegendMarker) | |
64 | }; |
|
64 | }; |
@@ -25,7 +25,7 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
QXYLegendMarker::QXYLegendMarker(QXYSeries* |
|
28 | QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) : | |
29 | QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent) |
|
29 | QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } |
@@ -33,7 +33,7 class QTCOMMERCIALCHART_EXPORT QXYLegendMarker : public QLegendMarker | |||||
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | public: |
|
35 | public: | |
36 |
explicit QXYLegendMarker(QXYSeries* |
|
36 | explicit QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent = 0); | |
37 | virtual ~QXYLegendMarker(); |
|
37 | virtual ~QXYLegendMarker(); | |
38 |
|
38 | |||
39 | virtual LegendMarkerType type() { return LegendMarkerTypeXY; } |
|
39 | virtual LegendMarkerType type() { return LegendMarkerTypeXY; } |
General Comments 0
You need to be logged in to leave comments.
Login now