##// END OF EJS Templates
added QXYLegendMarker
sauimone -
r2175:ff7965e6f308
parent child
Show More
@@ -0,0 +1,91
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 "qxylegendmarker.h"
22 #include "qxylegendmarker_p.h"
23 #include "qxyseries_p.h"
24 #include <QXYSeries>
25 #include <QDebug>
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
29 QXYLegendMarker::QXYLegendMarker(QXYSeries* series, QLegend *legend, QObject *parent) :
30 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
31 {
32 }
33
34 QXYLegendMarker::~QXYLegendMarker()
35 {
36 // qDebug() << "deleting xy marker" << this;
37 }
38
39 /*!
40 \internal
41 */
42 QXYLegendMarker::QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent) :
43 QLegendMarker(d, parent)
44 {
45 }
46
47 QXYSeries* QXYLegendMarker::series()
48 {
49 Q_D(QXYLegendMarker);
50 return d->m_series;
51 }
52
53 QXYSeries* QXYLegendMarker::peerObject()
54 {
55 Q_D(QXYLegendMarker);
56 return d->m_series;
57 }
58
59 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60
61 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
62 QLegendMarkerPrivate(q,legend),
63 m_series(series)
64 {
65 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
66 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
67 updated();
68 }
69
70 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
71 {
72 QObject::disconnect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
73 QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
74 }
75
76 void QXYLegendMarkerPrivate::updated()
77 {
78 m_item->setLabel(m_series->name());
79
80 if (m_series->type()== QAbstractSeries::SeriesTypeScatter) {
81 m_item->setBrush(m_series->brush());
82 } else {
83 m_item->setBrush(QBrush(m_series->pen().color()));
84 }
85 }
86
87 #include "moc_qxylegendmarker.cpp"
88 #include "moc_qxylegendmarker_p.cpp"
89
90 QTCOMMERCIALCHART_END_NAMESPACE
91
@@ -0,0 +1,57
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 #ifndef QXYLEGENDMARKER_H
22 #define QXYLEGENDMARKER_H
23
24 #include <QChartGlobal>
25 #include <QLegendMarker>
26 #include <QXYSeries>
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 class QXYLegendMarkerPrivate;
31
32 class QTCOMMERCIALCHART_EXPORT QXYLegendMarker : public QLegendMarker
33 {
34 Q_OBJECT
35 public:
36 explicit QXYLegendMarker(QXYSeries* series, QLegend *legend, QObject *parent = 0);
37 virtual ~QXYLegendMarker();
38
39 virtual QXYSeries* series();
40 virtual QXYSeries* peerObject(); // TODO: rename to slice and remove these virtuals from base class?
41
42 protected:
43 QXYLegendMarker(QXYLegendMarkerPrivate &d, QObject *parent = 0);
44
45 //Q_SIGNALS:
46
47 //public Q_SLOTS:
48
49 private:
50 Q_DECLARE_PRIVATE(QXYLegendMarker)
51 Q_DISABLE_COPY(QXYLegendMarker)
52
53 };
54
55 QTCOMMERCIALCHART_END_NAMESPACE
56
57 #endif // QXYLEGENDMARKER_H
@@ -0,0 +1,65
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 QXYLEGENDMARKER_P_H
31 #define QXYLEGENDMARKER_P_H
32
33 #include "qchartglobal.h"
34 #include "qlegendmarker_p.h"
35 #include "legendmarkeritem_p.h"
36 #include <QXYSeries>
37
38 #include <QDebug>
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
42 class QXYLegendMarker;
43
44 class QXYLegendMarkerPrivate : public QLegendMarkerPrivate
45 {
46 Q_OBJECT
47 public:
48 explicit QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend);
49 virtual ~QXYLegendMarkerPrivate();
50
51 public Q_SLOTS:
52 virtual void updated();
53
54 private:
55 QXYLegendMarker *q_ptr;
56
57 QXYSeries* m_series;
58
59 friend class QLegendPrivate; // TODO: Is this needed?
60 Q_DECLARE_PUBLIC(QXYLegendMarker)
61 };
62
63 QTCOMMERCIALCHART_END_NAMESPACE
64
65 #endif // QXYLEGENDMARKER_P_H
@@ -1,28 +1,31
1 1 INCLUDEPATH += $$PWD
2 2 DEPENDPATH += $$PWD
3 3
4 4 SOURCES += \
5 5 $$PWD/qlegend.cpp \
6 6 $$PWD/legendmarker.cpp \
7 7 $$PWD/legendlayout.cpp \
8 8 $$PWD/qlegendmarker.cpp \
9 9 $$PWD/qpielegendmarker.cpp \
10 10 $$PWD/legendmarkeritem.cpp \
11 $$PWD/qbarlegendmarker.cpp
11 $$PWD/qbarlegendmarker.cpp \
12 $$PWD/qxylegendmarker.cpp
12 13
13 14 PRIVATE_HEADERS += \
14 15 $$PWD/legendmarker_p.h \
15 16 $$PWD/legendscroller_p.h \
16 17 $$PWD/qlegend_p.h \
17 18 $$PWD/legendlayout_p.h \
18 19 $$PWD/qlegendmarker_p.h \
19 20 $$PWD/legendmarkeritem_p.h \
20 21 $$PWD/qpielegendmarker_p.h \
21 $$PWD/qbarlegendmarker_p.h
22 $$PWD/qbarlegendmarker_p.h \
23 $$PWD/qxylegendmarker_p.h
22 24
23 25
24 26 PUBLIC_HEADERS += \
25 27 $$PWD/qlegend.h \
26 28 $$PWD/qlegendmarker.h \
27 29 $$PWD/qpielegendmarker.h \
28 $$PWD/qbarlegendmarker.h
30 $$PWD/qbarlegendmarker.h \
31 $$PWD/qxylegendmarker.h
@@ -1,481 +1,480
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qxyseries.h"
22 22 #include "qxyseries_p.h"
23 23 #include "domain_p.h"
24 24 #include "legendmarker_p.h"
25 25 #include "qvalueaxis.h"
26 26
27 #include "qxylegendmarker.h"
28
27 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 30
29 31 /*!
30 32 \class QXYSeries
31 33 \brief The QXYSeries class is a base class for line, spline and scatter series.
32 34 */
33 35 /*!
34 36 \qmlclass XYSeries
35 37 \inherits AbstractSeries
36 38 The XYSeries class is a base class for line, spline and scatter series.
37 39
38 40 The class cannot be instantiated directly.
39 41 */
40 42
41 43 /*!
42 44 \property QXYSeries::pointsVisible
43 45 Controls if the data points are visible and should be drawn.
44 46 */
45 47 /*!
46 48 \qmlproperty bool XYSeries::pointsVisible
47 49 Controls if the data points are visible and should be drawn.
48 50 */
49 51
50 52 /*!
51 53 \fn QPen QXYSeries::pen() const
52 54 \brief Returns pen used to draw points for series.
53 55 \sa setPen()
54 56 */
55 57
56 58 /*!
57 59 \fn QBrush QXYSeries::brush() const
58 60 \brief Returns brush used to draw points for series.
59 61 \sa setBrush()
60 62 */
61 63
62 64 /*!
63 65 \property QXYSeries::color
64 66 The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and
65 67 fill (brush) color in case of QScatterSeries or QAreaSeries.
66 68 \sa QXYSeries::pen(), QXYSeries::brush()
67 69 */
68 70 /*!
69 71 \qmlproperty color XYSeries::color
70 72 The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and
71 73 fill (brush) color in case of ScatterSeries or AreaSeries.
72 74 */
73 75
74 76 /*!
75 77 \fn void QXYSeries::clicked(const QPointF& point)
76 78 \brief Signal is emitted when user clicks the \a point on chart.
77 79 */
78 80 /*!
79 81 \qmlsignal XYSeries::onClicked(QPointF point)
80 82 Signal is emitted when user clicks the \a point on chart. For example:
81 83 \code
82 84 LineSeries {
83 85 XYPoint { x: 0; y: 0 }
84 86 XYPoint { x: 1.1; y: 2.1 }
85 87 onClicked: console.log("onClicked: " + point.x + ", " + point.y);
86 88 }
87 89 \endcode
88 90 */
89 91
90 92 /*!
91 93 \fn void QXYSeries::pointReplaced(int index)
92 94 Signal is emitted when a point has been replaced at \a index.
93 95 \sa replace()
94 96 */
95 97 /*!
96 98 \qmlsignal XYSeries::onPointReplaced(int index)
97 99 Signal is emitted when a point has been replaced at \a index.
98 100 */
99 101
100 102 /*!
101 103 \fn void QXYSeries::pointsReplaced()
102 104 Signal is emitted when all points have been replaced with another points.
103 105 \sa replace()
104 106 */
105 107 /*!
106 108 \qmlsignal XYSeries::onPointsReplaced()
107 109 */
108 110
109 111 /*!
110 112 \fn void QXYSeries::pointAdded(int index)
111 113 Signal is emitted when a point has been added at \a index.
112 114 \sa append(), insert()
113 115 */
114 116 /*!
115 117 \qmlsignal XYSeries::onPointAdded(int index)
116 118 Signal is emitted when a point has been added at \a index.
117 119 */
118 120
119 121 /*!
120 122 \fn void QXYSeries::pointRemoved(int index)
121 123 Signal is emitted when a point has been removed from \a index.
122 124 \sa remove()
123 125 */
124 126 /*!
125 127 \qmlsignal XYSeries::onPointRemoved(int index)
126 128 Signal is emitted when a point has been removed from \a index.
127 129 */
128 130
129 131 /*!
130 132 \fn void QXYSeries::colorChanged(QColor color)
131 133 \brief Signal is emitted when the line (pen) color has changed to \a color.
132 134 */
133 135 /*!
134 136 \qmlsignal XYSeries::onColorChanged(color color)
135 137 Signal is emitted when the line (pen) color has changed to \a color.
136 138 */
137 139
138 140 /*!
139 141 \fn void QXYSeriesPrivate::updated()
140 142 \brief \internal
141 143 */
142 144
143 145 /*!
144 146 \qmlmethod XYSeries::append(real x, real y)
145 147 Append point (\a x, \a y) to the series
146 148 */
147 149
148 150 /*!
149 151 \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY)
150 152 Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not
151 153 exist.
152 154 */
153 155
154 156 /*!
155 157 \qmlmethod XYSeries::remove(real x, real y)
156 158 Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist.
157 159 */
158 160
159 161 /*!
160 162 \qmlmethod XYSeries::insert(int index, real x, real y)
161 163 Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of
162 164 points. If index is the same as or bigger than count, the point is appended to the list of points.
163 165 */
164 166
165 167 /*!
166 168 \qmlmethod QPointF XYSeries::at(int index)
167 169 Returns point at \a index. Returns (0, 0) if the index is not valid.
168 170 */
169 171
170 172 /*!
171 173 \internal
172 174
173 175 Constructs empty series object which is a child of \a parent.
174 176 When series object is added to QChartView or QChart instance ownerships is transferred.
175 177 */
176 178 QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent)
177 179 : QAbstractSeries(d, parent)
178 180 {
179 181 }
180 182
181 183 /*!
182 184 Destroys the object. Series added to QChartView or QChart instances are owned by those,
183 185 and are deleted when mentioned object are destroyed.
184 186 */
185 187 QXYSeries::~QXYSeries()
186 188 {
187 189 }
188 190
189 191 /*!
190 192 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
191 193 */
192 194 void QXYSeries::append(qreal x, qreal y)
193 195 {
194 196 append(QPointF(x, y));
195 197 }
196 198
197 199 /*!
198 200 This is an overloaded function.
199 201 Adds data \a point to the series. Points are connected with lines on the chart.
200 202 */
201 203 void QXYSeries::append(const QPointF &point)
202 204 {
203 205 Q_D(QXYSeries);
204 206 d->m_points << point;
205 207 emit pointAdded(d->m_points.count() - 1);
206 208 }
207 209
208 210 /*!
209 211 This is an overloaded function.
210 212 Adds list of data \a points to the series. Points are connected with lines on the chart.
211 213 */
212 214 void QXYSeries::append(const QList<QPointF> &points)
213 215 {
214 216 foreach (const QPointF &point , points)
215 217 append(point);
216 218 }
217 219
218 220 /*!
219 221 Replaces data point \a oldX \a oldY with data point \a newX \a newY.
220 222 \sa QXYSeries::pointReplaced()
221 223 */
222 224 void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
223 225 {
224 226 replace(QPointF(oldX, oldY), QPointF(newX, newY));
225 227 }
226 228
227 229 /*!
228 230 Replaces \a oldPoint with \a newPoint.
229 231 \sa QXYSeries::pointReplaced()
230 232 */
231 233 void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint)
232 234 {
233 235 Q_D(QXYSeries);
234 236 int index = d->m_points.indexOf(oldPoint);
235 237 if (index == -1)
236 238 return;
237 239 d->m_points[index] = newPoint;
238 240 emit pointReplaced(index);
239 241 }
240 242
241 243 /*!
242 244 Replaces the current points with \a points. This is faster than replacing data points one by one,
243 245 or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced()
244 246 when the points have been replaced.
245 247 \sa QXYSeries::pointsReplaced()
246 248 */
247 249 void QXYSeries::replace(QList<QPointF> points)
248 250 {
249 251 Q_D(QXYSeries);
250 252 d->m_points = points.toVector();
251 253 emit pointsReplaced();
252 254 }
253 255
254 256 /*!
255 257 Removes current \a x and \a y value.
256 258 */
257 259 void QXYSeries::remove(qreal x, qreal y)
258 260 {
259 261 remove(QPointF(x, y));
260 262 }
261 263
262 264 /*!
263 265 Removes current \a point x value.
264 266
265 267 Note: point y value is ignored.
266 268 */
267 269 void QXYSeries::remove(const QPointF &point)
268 270 {
269 271 Q_D(QXYSeries);
270 272 int index = d->m_points.indexOf(point);
271 273 if (index == -1)
272 274 return;
273 275 d->m_points.remove(index);
274 276 emit pointRemoved(index);
275 277 }
276 278
277 279 /*!
278 280 Inserts a \a point in the series at \a index position.
279 281 */
280 282 void QXYSeries::insert(int index, const QPointF &point)
281 283 {
282 284 Q_D(QXYSeries);
283 285 d->m_points.insert(index, point);
284 286 emit pointAdded(index);
285 287 }
286 288
287 289 /*!
288 290 Removes all points from the series.
289 291 */
290 292 void QXYSeries::clear()
291 293 {
292 294 Q_D(QXYSeries);
293 295 for (int i = d->m_points.size() - 1; i >= 0; i--)
294 296 remove(d->m_points.at(i));
295 297 }
296 298
297 299 /*!
298 300 Returns list of points in the series.
299 301 */
300 302 QList<QPointF> QXYSeries::points() const
301 303 {
302 304 Q_D(const QXYSeries);
303 305 return d->m_points.toList();
304 306 }
305 307
306 308 /*!
307 309 Returns number of data points within series.
308 310 */
309 311 int QXYSeries::count() const
310 312 {
311 313 Q_D(const QXYSeries);
312 314 return d->m_points.count();
313 315 }
314 316
315 317
316 318 /*!
317 319 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
318 320 pen from chart theme is used.
319 321 \sa QChart::setTheme()
320 322 */
321 323 void QXYSeries::setPen(const QPen &pen)
322 324 {
323 325 Q_D(QXYSeries);
324 326 if (d->m_pen != pen) {
325 327 bool emitColorChanged = d->m_pen.color() != pen.color();
326 328 d->m_pen = pen;
327 329 emit d->updated();
328 330 if (emitColorChanged)
329 331 emit colorChanged(pen.color());
330 332 }
331 333 }
332 334
333 335 QPen QXYSeries::pen() const
334 336 {
335 337 Q_D(const QXYSeries);
336 338 return d->m_pen;
337 339 }
338 340
339 341 /*!
340 342 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
341 343 from chart theme setting is used.
342 344 \sa QChart::setTheme()
343 345 */
344 346 void QXYSeries::setBrush(const QBrush &brush)
345 347 {
346 348 Q_D(QXYSeries);
347 349 if (d->m_brush != brush) {
348 350 d->m_brush = brush;
349 351 emit d->updated();
350 352 }
351 353 }
352 354
353 355 QBrush QXYSeries::brush() const
354 356 {
355 357 Q_D(const QXYSeries);
356 358 return d->m_brush;
357 359 }
358 360
359 361 void QXYSeries::setColor(const QColor &color)
360 362 {
361 363 QPen p = pen();
362 364 if (p.color() != color) {
363 365 p.setColor(color);
364 366 setPen(p);
365 367 }
366 368 }
367 369
368 370 QColor QXYSeries::color() const
369 371 {
370 372 return pen().color();
371 373 }
372 374
373 375 void QXYSeries::setPointsVisible(bool visible)
374 376 {
375 377 Q_D(QXYSeries);
376 378 if (d->m_pointsVisible != visible) {
377 379 d->m_pointsVisible = visible;
378 380 emit d->updated();
379 381 }
380 382 }
381 383
382 384 bool QXYSeries::pointsVisible() const
383 385 {
384 386 Q_D(const QXYSeries);
385 387 return d->m_pointsVisible;
386 388 }
387 389
388 390
389 391 /*!
390 392 Stream operator for adding a data \a point to the series.
391 393 \sa append()
392 394 */
393 395 QXYSeries &QXYSeries::operator<< (const QPointF &point)
394 396 {
395 397 append(point);
396 398 return *this;
397 399 }
398 400
399 401
400 402 /*!
401 403 Stream operator for adding a list of \a points to the series.
402 404 \sa append()
403 405 */
404 406
405 407 QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points)
406 408 {
407 409 append(points);
408 410 return *this;
409 411 }
410 412
411 413 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
412 414
413 415
414 416 QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q)
415 417 : QAbstractSeriesPrivate(q),
416 418 m_pointsVisible(false)
417 419 {
418 420 }
419 421
420 422 void QXYSeriesPrivate::scaleDomain(Domain &domain)
421 423 {
422 424 qreal minX(0);
423 425 qreal minY(0);
424 426 qreal maxX(1);
425 427 qreal maxY(1);
426 428
427 429 Q_Q(QXYSeries);
428 430
429 431 const QList<QPointF>& points = q->points();
430 432
431 433 if (!points.isEmpty()) {
432 434 minX = points[0].x();
433 435 minY = points[0].y();
434 436 maxX = minX;
435 437 maxY = minY;
436 438
437 439 for (int i = 0; i < points.count(); i++) {
438 440 qreal x = points[i].x();
439 441 qreal y = points[i].y();
440 442 minX = qMin(minX, x);
441 443 minY = qMin(minY, y);
442 444 maxX = qMax(maxX, x);
443 445 maxY = qMax(maxY, y);
444 446 }
445 447 }
446 448
447 449 domain.setRange(minX, maxX, minY, maxY);
448 450 }
449 451
450 452 QList<LegendMarker *> QXYSeriesPrivate::createLegendMarker(QLegend *legend)
451 453 {
452 454 Q_Q(QXYSeries);
453 455 QList<LegendMarker *> list;
454 456 return list << new XYLegendMarker(q, legend);
455 457 }
456 458
457 459 QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend)
458 460 {
459 Q_UNUSED(legend);
460 // Q_Q(QXYSeries);
461 Q_Q(QXYSeries);
461 462 QList<QLegendMarker*> list;
462 // TODO:
463 // return list << new QXYLegendMarker(q,legend);
464 return list;
463 return list << new QXYLegendMarker(q,legend);
465 464 }
466 465
467 466 void QXYSeriesPrivate::initializeAxis(QAbstractAxis *axis)
468 467 {
469 468 Q_UNUSED(axis);
470 469 }
471 470
472 471 QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
473 472 {
474 473 Q_UNUSED(orientation);
475 474 return QAbstractAxis::AxisTypeValue;
476 475 }
477 476
478 477 #include "moc_qxyseries.cpp"
479 478 #include "moc_qxyseries_p.cpp"
480 479
481 480 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,94 +1,95
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QXYSERIES_H
22 22 #define QXYSERIES_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <qabstractseries.h>
26 26 #include <QPen>
27 27 #include <QBrush>
28 28
29 29 class QModelIndex;
30 30
31 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 class QXYSeriesPrivate;
34 34 class QXYModelMapper;
35 35
36 36 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries
37 37 {
38 38 Q_OBJECT
39 39 Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
40 40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
41 41
42 42 protected:
43 43 explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0);
44 44
45 45 public:
46 46 ~QXYSeries();
47 47 void append(qreal x, qreal y);
48 48 void append(const QPointF &point);
49 49 void append(const QList<QPointF> &points);
50 50 void replace(qreal oldX, qreal oldY, qreal newX, qreal newY);
51 51 void replace(const QPointF &oldPoint, const QPointF &newPoint);
52 52 void remove(qreal x, qreal y);
53 53 void remove(const QPointF &point);
54 54 void insert(int index, const QPointF &point);
55 55 void clear();
56 56
57 57 int count() const;
58 58 QList<QPointF> points() const;
59 59
60 60 QXYSeries &operator << (const QPointF &point);
61 61 QXYSeries &operator << (const QList<QPointF> &points);
62 62
63 63 virtual void setPen(const QPen &pen);
64 64 QPen pen() const;
65 65
66 66 virtual void setBrush(const QBrush &brush);
67 67 QBrush brush() const;
68 68
69 69 virtual void setColor(const QColor &color);
70 70 virtual QColor color() const;
71 71
72 72 void setPointsVisible(bool visible = true);
73 73 bool pointsVisible() const;
74 74
75 75 void replace(QList<QPointF> points);
76 76
77 77 Q_SIGNALS:
78 78 void clicked(const QPointF &point);
79 79 void pointReplaced(int index);
80 80 void pointRemoved(int index);
81 81 void pointAdded(int index);
82 82 void colorChanged(QColor color);
83 83 void pointsReplaced();
84 84
85 85 private:
86 86 Q_DECLARE_PRIVATE(QXYSeries)
87 87 Q_DISABLE_COPY(QXYSeries)
88 friend class QXYLegendMarkerPrivate;
88 89 friend class XYLegendMarker;
89 90 friend class XYChart;
90 91 };
91 92
92 93 QTCOMMERCIALCHART_END_NAMESPACE
93 94
94 95 #endif // QXYSERIES_H
General Comments 0
You need to be logged in to leave comments. Login now