##// END OF EJS Templates
added LegendMarkerItem. Updated new legend example to test clicked of LegendMarker
sauimone -
r2164:7e465403ab2c
parent child
Show More
@@ -0,0 +1,253
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "legendmarkeritem_p.h"
22 #include "qxyseries.h"
23 #include "qxyseries_p.h"
24 #include "qlegend.h"
25 #include "qabstractbarseries.h"
26 #include "qpieseries.h"
27 #include "qpieslice.h"
28 #include "qbarset.h"
29 #include "qbarset_p.h"
30 #include "qareaseries.h"
31 #include "qareaseries_p.h"
32 #include <QPainter>
33 #include <QGraphicsSceneEvent>
34 #include <QGraphicsSimpleTextItem>
35 #include <QDebug>
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
39 LegendMarkerItem::LegendMarkerItem(QAbstractSeries *series, QGraphicsObject *parent) :
40 QGraphicsObject(parent),
41 m_series(series),
42 m_markerRect(0,0,10.0,10.0),
43 m_boundingRect(0,0,0,0),
44 m_textItem(new QGraphicsSimpleTextItem(this)),
45 m_rectItem(new QGraphicsRectItem(this)),
46 m_margin(4),
47 m_space(4)
48 {
49 //setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
50 m_rectItem->setRect(m_markerRect);
51 }
52
53 void LegendMarkerItem::setPen(const QPen &pen)
54 {
55 m_rectItem->setPen(pen);
56 }
57
58 QPen LegendMarkerItem::pen() const
59 {
60 return m_rectItem->pen();
61 }
62
63 void LegendMarkerItem::setBrush(const QBrush &brush)
64 {
65 m_rectItem->setBrush(brush);
66 }
67
68 QBrush LegendMarkerItem::brush() const
69 {
70 return m_rectItem->brush();
71 }
72
73 void LegendMarkerItem::setFont(const QFont &font)
74 {
75 m_textItem->setFont(font);
76 QFontMetrics fn(font);
77 m_markerRect = QRectF(0,0,fn.height()/2,fn.height()/2);
78 updateGeometry();
79 }
80
81 QFont LegendMarkerItem::font() const
82 {
83 return m_textItem->font();
84 }
85
86 void LegendMarkerItem::setLabel(const QString label)
87 {
88 m_text = label;
89 updateGeometry();
90 }
91
92 QString LegendMarkerItem::label() const
93 {
94 return m_text;
95 }
96
97 QRectF LegendMarkerItem::boundingRect() const
98 {
99 return m_boundingRect;
100 }
101
102 void LegendMarkerItem::setLabelBrush(const QBrush &brush)
103 {
104 m_textItem->setBrush(brush);
105 }
106
107 QBrush LegendMarkerItem::labelBrush() const
108 {
109 return m_textItem->brush();
110 }
111
112
113 void LegendMarkerItem::setGeometry(const QRectF& rect)
114 {
115 QFontMetrics fn (font());
116
117 int width = rect.width();
118 qreal x = m_margin + m_markerRect.width() + m_space + m_margin;
119 qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin);
120
121 if (fn.boundingRect(m_text).width() + x > width)
122 {
123 QString string = m_text + "...";
124 while(fn.boundingRect(string).width() + x > width && string.length() > 3)
125 string.remove(string.length() - 4, 1);
126 m_textItem->setText(string);
127 }
128 else
129 m_textItem->setText(m_text);
130
131 const QRectF& textRect = m_textItem->boundingRect();
132
133
134 m_textItem->setPos(x-m_margin,y/2 - textRect.height()/2);
135 m_rectItem->setRect(m_markerRect);
136 m_rectItem->setPos(m_margin,y/2 - m_markerRect.height()/2);
137
138 prepareGeometryChange();
139 m_boundingRect = QRectF(0,0,x+textRect.width()+m_margin,y);
140 }
141
142 void LegendMarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
143 {
144 Q_UNUSED(option)
145 Q_UNUSED(widget)
146 Q_UNUSED(painter)
147 }
148
149 QSizeF LegendMarkerItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const
150 {
151 Q_UNUSED(constraint)
152
153 QFontMetrics fn(m_textItem->font());
154 QSizeF sh;
155
156 switch (which) {
157 case Qt::MinimumSize:
158 sh = QSizeF(fn.boundingRect("...").width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
159 break;
160 case Qt::PreferredSize:
161 sh = QSizeF(fn.boundingRect(m_text).width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
162 break;
163 default:
164 break;
165 }
166
167 return sh;
168 }
169
170 void LegendMarkerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
171 {
172 qDebug() << "LegendMarkerItem::mousePressEvent";
173 QGraphicsObject::mousePressEvent(event);
174 //TODO: selected signal removed for now
175 }
176
177 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
178
179 AreaLegendMarkerItem::AreaLegendMarkerItem(QAreaSeries *series,QLegend *legend) : LegendMarkerItem(series,legend),
180 m_series(series)
181 {
182 //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected()));
183 // QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
184 // QObject::connect(series, SIGNAL(nameChanged()), this, SLOT(updated()));
185 updated();
186 }
187
188 void AreaLegendMarkerItem::updated()
189 {
190 setBrush(m_series->brush());
191 setLabel(m_series->name());
192 }
193
194 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
195
196 BarLegendMarkerItem::BarLegendMarkerItem(QAbstractBarSeries *barseries,QBarSet *barset, QLegend *legend) : LegendMarkerItem(barseries,legend),
197 m_barset(barset)
198 {
199 //QObject::connect(this, SIGNAL(selected()),barset->d_ptr.data(), SIGNAL(selected()));
200 // QObject::connect(barset->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(updated()));
201 updated();
202 }
203
204 void BarLegendMarkerItem::updated()
205 {
206 setBrush(m_barset->brush());
207 setLabel(m_barset->label());
208 }
209
210 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
211
212 PieLegendMarkerItem::PieLegendMarkerItem(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarkerItem(series,legend),
213 m_pieslice(pieslice)
214 {
215 // QObject::connect(pieslice, SIGNAL(labelChanged()), this, SLOT(updated()));
216 // QObject::connect(pieslice, SIGNAL(brushChanged()), this, SLOT(updated()));
217 updated();
218 }
219
220 void PieLegendMarkerItem::updated()
221 {
222 setBrush(m_pieslice->brush());
223 setLabel(m_pieslice->label());
224 }
225
226 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
227
228 XYLegendMarkerItem::XYLegendMarkerItem(QXYSeries *series, QLegend *legend) : LegendMarkerItem(series,legend),
229 m_series(series)
230 {
231 //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected()));
232 // QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
233 // QObject::connect(series, SIGNAL(nameChanged()), this, SLOT(updated()));
234 updated();
235 }
236
237 void XYLegendMarkerItem::updated()
238 {
239 setLabel(m_series->name());
240
241 if(m_series->type()== QAbstractSeries::SeriesTypeScatter)
242 {
243 setBrush(m_series->brush());
244
245 }
246 else {
247 setBrush(QBrush(m_series->pen().color()));
248 }
249 }
250
251 #include "moc_legendmarkeritem_p.cpp"
252
253 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,146
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef LEGENDMARKERITEM_P_H
31 #define LEGENDMARKERITEM_P_H
32
33 #include "qchartglobal.h"
34 #include <QGraphicsObject>
35 #include <QBrush>
36 #include <QPen>
37 #include <QGraphicsSimpleTextItem>
38 #include <QGraphicsLayoutItem>
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
42 class QAbstractSeries;
43 class QAreaSeries;
44 class QXYSeries;
45 class QBarSet;
46 class QAbstractBarSeries;
47 class QPieSlice;
48 class QLegend;
49 class QPieSeries;
50
51 class LegendMarkerItem : public QGraphicsObject, public QGraphicsLayoutItem
52 {
53 Q_OBJECT
54 Q_INTERFACES(QGraphicsLayoutItem)
55 public:
56 explicit LegendMarkerItem(QAbstractSeries *m_series, QGraphicsObject *parent);
57
58 void setPen(const QPen &pen);
59 QPen pen() const;
60
61 void setBrush(const QBrush &brush);
62 QBrush brush() const;
63
64 void setFont(const QFont &font);
65 QFont font() const;
66
67 void setLabel(const QString label);
68 QString label() const;
69
70 void setLabelBrush(const QBrush &brush);
71 QBrush labelBrush() const;
72
73 QAbstractSeries *series() const { return m_series;}
74
75 void setGeometry(const QRectF& rect);
76
77 QRectF boundingRect() const;
78
79 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
80
81 QSizeF sizeHint (Qt::SizeHint which, const QSizeF& constraint) const;
82
83 protected:
84 // From QGraphicsObject
85 void mousePressEvent(QGraphicsSceneMouseEvent *event);
86
87 //public Q_SLOTS:
88 //virtual void updated() = 0;
89
90 protected:
91 QAbstractSeries *m_series;
92 QRectF m_markerRect;
93 QRectF m_boundingRect;
94 // QLegend* m_legend;
95 QGraphicsSimpleTextItem *m_textItem;
96 QGraphicsRectItem *m_rectItem;
97 qreal m_margin;
98 qreal m_space;
99 QString m_text;
100
101 };
102
103 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
104 class XYLegendMarkerItem : public LegendMarkerItem
105 {
106 public:
107 XYLegendMarkerItem(QXYSeries *series, QLegend *legend);
108 protected:
109 void updated();
110 private:
111 QXYSeries *m_series;
112 };
113 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
114 class AreaLegendMarkerItem : public LegendMarkerItem
115 {
116 public:
117 AreaLegendMarkerItem(QAreaSeries *series, QLegend *legend);
118 protected:
119 void updated();
120 private:
121 QAreaSeries *m_series;
122 };
123 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
124 class BarLegendMarkerItem : public LegendMarkerItem
125 {
126 public:
127 BarLegendMarkerItem(QAbstractBarSeries *barseries, QBarSet *barset,QLegend *legend);
128 protected:
129 void updated();
130 private:
131 QBarSet *m_barset;
132 };
133 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
134 class PieLegendMarkerItem : public LegendMarkerItem
135 {
136 public:
137 PieLegendMarkerItem(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend);
138 protected:
139 void updated();
140 private:
141 QPieSlice *m_pieslice;
142 };
143
144 QTCOMMERCIALCHART_END_NAMESPACE
145
146 #endif // LEGENDMARKERITEM_P_H
@@ -64,6 +64,15 MainWidget::MainWidget(QWidget *parent) :
64 connect(infoButton, SIGNAL(clicked()), this, SLOT(showDebugInfo()));
64 connect(infoButton, SIGNAL(clicked()), this, SLOT(showDebugInfo()));
65 m_buttonLayout->addWidget(infoButton, 7, 0);
65 m_buttonLayout->addWidget(infoButton, 7, 0);
66
66
67 QPushButton *connectButton = new QPushButton("Connect markers");
68 connect(connectButton, SIGNAL(clicked()), this, SLOT(connectMarkers()));
69 m_buttonLayout->addWidget(connectButton, 8, 0);
70
71 QPushButton *disConnectButton = new QPushButton("Disconnect markers");
72 connect(disConnectButton, SIGNAL(clicked()), this, SLOT(disconnectMarkers()));
73 m_buttonLayout->addWidget(connectButton, 8, 0);
74
75
67 m_legendPosX = new QDoubleSpinBox();
76 m_legendPosX = new QDoubleSpinBox();
68 m_legendPosY = new QDoubleSpinBox();
77 m_legendPosY = new QDoubleSpinBox();
69 m_legendWidth = new QDoubleSpinBox();
78 m_legendWidth = new QDoubleSpinBox();
@@ -178,7 +187,6 void MainWidget::toggleAttached()
178 void MainWidget::addSlice()
187 void MainWidget::addSlice()
179 {
188 {
180 QPieSlice* slice = new QPieSlice(QString("slice " + QString::number(m_series->count())), m_series->count()+1);
189 QPieSlice* slice = new QPieSlice(QString("slice " + QString::number(m_series->count())), m_series->count()+1);
181 // slice->setValue();
182 m_series->append(slice);
190 m_series->append(slice);
183 }
191 }
184
192
@@ -190,6 +198,26 void MainWidget::removeSlice()
190 }
198 }
191 }
199 }
192
200
201 void MainWidget::connectMarkers()
202 {
203 // Example use case.
204 // Explode slice via marker.
205 // Should be doable via public api.
206
207 foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
208 // Disconnect possible existing connection to avoid multiple connections
209 QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
210 QObject::connect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
211 }
212 }
213
214 void MainWidget::disconnectMarkers()
215 {
216 foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
217 QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
218 }
219 }
220
193 void MainWidget::setLegendAlignment()
221 void MainWidget::setLegendAlignment()
194 {
222 {
195 QPushButton *button = qobject_cast<QPushButton *>(sender());
223 QPushButton *button = qobject_cast<QPushButton *>(sender());
@@ -236,6 +264,8 void MainWidget::showDebugInfo()
236 {
264 {
237 qDebug() << "marker count:" << m_chart->legend()->markers().count();
265 qDebug() << "marker count:" << m_chart->legend()->markers().count();
238 foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
266 foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
267 qDebug() << "marker series type:" << marker->series()->type();
268 qDebug() << "peer object:" << marker->peerObject();
239 qDebug() << "label:" << marker->label();
269 qDebug() << "label:" << marker->label();
240 }
270 }
241 }
271 }
@@ -257,3 +287,15 void MainWidget::updateLegendLayout()
257 m_chart->legend()->update();
287 m_chart->legend()->update();
258 //![4]
288 //![4]
259 }
289 }
290
291 void MainWidget::handleMarkerClicked()
292 {
293 QLegendMarker* marker = qobject_cast<QLegendMarker*> (sender());
294
295 qDebug() << "marker clicked:" << marker;
296
297 QPieSlice* slice = qobject_cast<QPieSlice*> (marker->peerObject());
298 Q_ASSERT(slice);
299
300 slice->setExploded(!slice->isExploded());
301 }
@@ -50,6 +50,8 public slots:
50 void toggleAttached();
50 void toggleAttached();
51 void addSlice();
51 void addSlice();
52 void removeSlice();
52 void removeSlice();
53 void connectMarkers();
54 void disconnectMarkers();
53
55
54 void setLegendAlignment();
56 void setLegendAlignment();
55
57
@@ -60,6 +62,8 public slots:
60
62
61 void updateLegendLayout();
63 void updateLegendLayout();
62
64
65 void handleMarkerClicked();
66
63
67
64 private:
68 private:
65
69
@@ -6,14 +6,16 SOURCES += \
6 $$PWD/legendmarker.cpp \
6 $$PWD/legendmarker.cpp \
7 $$PWD/legendlayout.cpp \
7 $$PWD/legendlayout.cpp \
8 $$PWD/qlegendmarker.cpp \
8 $$PWD/qlegendmarker.cpp \
9 $$PWD/qpielegendmarker.cpp
9 $$PWD/qpielegendmarker.cpp \
10 $$PWD/legendmarkeritem.cpp
10
11
11 PRIVATE_HEADERS += \
12 PRIVATE_HEADERS += \
12 $$PWD/legendmarker_p.h \
13 $$PWD/legendmarker_p.h \
13 $$PWD/legendscroller_p.h \
14 $$PWD/legendscroller_p.h \
14 $$PWD/qlegend_p.h \
15 $$PWD/qlegend_p.h \
15 $$PWD/legendlayout_p.h \
16 $$PWD/legendlayout_p.h \
16 $$PWD/qlegendmarker_p.h
17 $$PWD/qlegendmarker_p.h \
18 $$PWD/legendmarkeritem_p.h
17
19
18
20
19 PUBLIC_HEADERS += \
21 PUBLIC_HEADERS += \
@@ -467,6 +467,8 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
467 {
467 {
468 Q_UNUSED(domain)
468 Q_UNUSED(domain)
469
469
470 qDebug() << "QLegendPrivate::handleSeriesAdded";
471
470 // New markers --->
472 // New markers --->
471 QList<QLegendMarker*> newMarkers = series->d_ptr->createLegendMarkers(q_ptr);
473 QList<QLegendMarker*> newMarkers = series->d_ptr->createLegendMarkers(q_ptr);
472 foreach (QLegendMarker* marker, newMarkers) {
474 foreach (QLegendMarker* marker, newMarkers) {
@@ -474,7 +476,8 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
474 marker->setLabelBrush(m_labelBrush);
476 marker->setLabelBrush(m_labelBrush);
475 marker->setVisible(series->isVisible());
477 marker->setVisible(series->isVisible());
476 // TODO: QLegendMarker has QGraphicsItem vs QLegendMarker is QGraphicsItem
478 // TODO: QLegendMarker has QGraphicsItem vs QLegendMarker is QGraphicsItem
477 // m_items->addToGroup(marker);
479 // TODO: possible hazard. What if marker is deleted and group still has pointer?
480 // m_items->addToGroup(marker->d_ptr.data());
478 m_legendMarkers << marker;
481 m_legendMarkers << marker;
479 }
482 }
480
483
@@ -20,6 +20,7
20
20
21 #include "qlegendmarker.h"
21 #include "qlegendmarker.h"
22 #include "qlegendmarker_p.h"
22 #include "qlegendmarker_p.h"
23 #include "legendmarkeritem_p.h"
23 #include <QDebug>
24 #include <QDebug>
24 #include <QFontMetrics>
25 #include <QFontMetrics>
25
26
@@ -106,7 +107,7 QLegendMarkerPrivate::QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarke
106 q_ptr(q),
107 q_ptr(q),
107 m_series(series)
108 m_series(series)
108 {
109 {
109
110 m_item = new LegendMarkerItem(m_series,this);
110 }
111 }
111
112
112 void QLegendMarkerPrivate::setGeometry(const QRectF& rect)
113 void QLegendMarkerPrivate::setGeometry(const QRectF& rect)
@@ -174,6 +175,7 QSizeF QLegendMarkerPrivate::sizeHint(Qt::SizeHint which, const QSizeF& constrai
174
175
175 void QLegendMarkerPrivate::mousePressEvent(QGraphicsSceneMouseEvent *event)
176 void QLegendMarkerPrivate::mousePressEvent(QGraphicsSceneMouseEvent *event)
176 {
177 {
178 qDebug() << "QLegendMarkerPrivate::mousePressEvent" << event;
177 QGraphicsObject::mousePressEvent(event);
179 QGraphicsObject::mousePressEvent(event);
178 //TODO: selected signal removed for now
180 //TODO: selected signal removed for now
179 }
181 }
@@ -50,6 +50,7 class QLegend;
50 class QPieSeries;
50 class QPieSeries;
51
51
52 class QLegendMarker;
52 class QLegendMarker;
53 class LegendMarkerItem;
53
54
54 class QLegendMarkerPrivate : public QGraphicsObject, public QGraphicsLayoutItem
55 class QLegendMarkerPrivate : public QGraphicsObject, public QGraphicsLayoutItem
55 {
56 {
@@ -91,6 +92,8 public Q_SLOTS:
91 private:
92 private:
92 QLegendMarker *q_ptr;
93 QLegendMarker *q_ptr;
93
94
95 LegendMarkerItem *m_item;
96
94 /*
97 /*
95 QLegend* m_legend;
98 QLegend* m_legend;
96 */
99 */
@@ -32,6 +32,11 QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject
32 updated();
32 updated();
33 }
33 }
34
34
35 QPieSlice* QPieLegendMarker::peerObject()
36 {
37 return m_slice;
38 }
39
35 void QPieLegendMarker::updated()
40 void QPieLegendMarker::updated()
36 {
41 {
37 // TODO: to PIMPL.
42 // TODO: to PIMPL.
@@ -34,9 +34,9 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker
34 public:
34 public:
35 explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject *parent = 0);
35 explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QObject *parent = 0);
36
36
37 virtual QPieSlice* peerObject() { return m_slice; }
37 virtual QPieSlice* peerObject();
38
38
39 // TODO: to pimp.
39 // TODO: to pimpl.
40 void updated();
40 void updated();
41
41
42 //Q_SIGNALS:
42 //Q_SIGNALS:
@@ -48,6 +48,7 private:
48 // QScopedPointer<QPieLegendMarkerPrivate> d_ptr;
48 // QScopedPointer<QPieLegendMarkerPrivate> d_ptr;
49 Q_DISABLE_COPY(QPieLegendMarker)
49 Q_DISABLE_COPY(QPieLegendMarker)
50
50
51 // TODO: PIMPL
51 QPieSlice* m_slice;
52 QPieSlice* m_slice;
52
53
53 };
54 };
@@ -865,10 +865,11 QList<LegendMarker *> QPieSeriesPrivate::createLegendMarker(QLegend *legend)
865
865
866 QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend)
866 QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend)
867 {
867 {
868 Q_UNUSED(legend);
868 Q_Q(QPieSeries);
869 Q_Q(QPieSeries);
869 QList<QLegendMarker*> markers;
870 QList<QLegendMarker*> markers;
870 foreach(QPieSlice* slice, q->slices()) {
871 foreach(QPieSlice* slice, q->slices()) {
871 QPieLegendMarker* marker = new QPieLegendMarker(q,slice,legend);
872 QPieLegendMarker* marker = new QPieLegendMarker(q,slice);
872 markers << marker;
873 markers << marker;
873 }
874 }
874 return markers;
875 return markers;
General Comments 0
You need to be logged in to leave comments. Login now