##// END OF EJS Templates
Bugfix for destruction of qlineseries
Michal Klocek -
r1069:c2064d29f258
parent child
Show More
@@ -1,116 +1,120
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 "qlineseries.h"
22 22 #include "qlineseries_p.h"
23 23 #include "linechartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 /*!
31 31 \class QLineSeries
32 32 \brief The QLineSeries class is used for making line charts.
33 33
34 34 \mainclass
35 35
36 36 A line chart is used to show information as a series of data points
37 37 connected by straight lines.
38 38
39 39 \image examples_linechart.png
40 40
41 41 Creating basic line chart is simple:
42 42 \code
43 43 QLineSeries* series = new QLineSeries();
44 44 series->append(0, 6);
45 45 series->append(2, 4);
46 46 ...
47 47 chart->addSeries(series);
48 48 \endcode
49 49 */
50 50
51 51 /*!
52 52 \fn virtual QSeriesType QLineSeries::type() const
53 53 \brief Returns type of series.
54 54 \sa QAbstractSeries, QSeriesType
55 55 */
56 56
57 57 /*!
58 58 Constructs empty series object which is a child of \a parent.
59 59 When series object is added to QChartView or QChart instance ownerships is transferred.
60 60 */
61 61 QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent)
62 62 {
63 63
64 64 }
65 65
66 66 /*!
67 67 \internal
68 68 */
69 69 QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent)
70 70 {
71 71
72 72 }
73 73 /*!
74 74 Destroys the object. Series added to QChartView or QChart instances are owned by those,
75 75 and are deleted when mentioned object are destroyed.
76 76 */
77 77 QLineSeries::~QLineSeries()
78 78 {
79 Q_D(QLineSeries);
80 if(d->m_dataset){
81 d->m_dataset->removeSeries(this);
82 }
79 83 }
80 84
81 85 QAbstractSeries::QSeriesType QLineSeries::type() const
82 86 {
83 87 return QAbstractSeries::SeriesTypeLine;
84 88 }
85 89
86 90 /*
87 91 QDebug operator<< (QDebug debug, const QLineSeries series)
88 92 {
89 93 Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size());
90 94 int size = series.d_func()->m_x.size();
91 95 for (int i=0; i<size; i++) {
92 96 debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") ";
93 97 }
94 98 return debug.space();
95 99 }
96 100 */
97 101
98 102 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
99 103
100 104 QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q)
101 105 {
102 106
103 107 };
104 108
105 109 Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter)
106 110 {
107 111 Q_Q(QLineSeries);
108 112 LineChartItem* line = new LineChartItem(q,presenter);
109 113 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
110 114 presenter->animator()->addAnimation(line);
111 115 }
112 116 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
113 117 return line;
114 118 }
115 119
116 120 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,158 +1,156
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 "qabstractseries.h"
22 22 #include "qabstractseries_p.h"
23 23 #include "chartdataset_p.h"
24 24
25 25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 26
27 27 /*!
28 28 \class QAbstractSeries
29 29 \brief Base class for all QtCommercial Chart series.
30 30 \mainclass
31 31
32 32 Usually you use the series type specific inherited classes instead of the base class.
33 33 \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QBarSeries, QStackedBarSeries,
34 34 QPercentBarSeries, QPieSeries
35 35 */
36 36
37 37 /*!
38 38 \enum QAbstractSeries::QSeriesType
39 39
40 40 The type of the series object.
41 41
42 42 \value SeriesTypeLine
43 43 \value SeriesTypeArea
44 44 \value SeriesTypeBar
45 45 \value SeriesTypeStackedBar
46 46 \value SeriesTypePercentBar
47 47 \value SeriesTypePie
48 48 \value SeriesTypeScatter
49 49 \value SeriesTypeSpline
50 50 */
51 51
52 52 /*!
53 53 \fn QSeriesType QAbstractSeries::type() const
54 54 \brief The type of the series.
55 55 */
56 56
57 57 /*!
58 58 \fn bool QAbstractSeries::setModel(QAbstractItemModel *model)
59 59 \brief Use the \a model to provide data for the series. The model overrides possible user data
60 60 set with QChartSeries type specific data setters. For example if you call both
61 61 QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is
62 62 used by the series. Returns true if the model is valid for the series.
63 63 */
64 64
65 65 /*!
66 66 \property QAbstractSeries::name
67 67 \brief name of the series property
68 68 */
69 69
70 70 /*!
71 71 \fn void QAbstractSeries::setName(const QString& name)
72 72 \brief Sets a \a name for the series.
73 73
74 74 The name of a series is shown in the legend for QXYSeries.
75 75 \sa QChart::setTitle()
76 76 \sa QPieSlice::setLabel()
77 77 \sa QBarSet::setName()
78 78 */
79 79
80 80 /*!
81 81 \internal
82 82 \brief Constructs ChartSeries object with \a parent.
83 83 */
84 84 QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) :
85 85 QObject(parent),
86 86 d_ptr(&d)
87 87 {
88 88 }
89 89
90 90 /*!
91 91 \brief Virtual destructor for the chart series.
92 92 */
93 93 QAbstractSeries::~QAbstractSeries()
94 94 {
95 if(d_ptr->m_dataset){
96 d_ptr->m_dataset->removeSeries(this);
97 }
95 if(d_ptr->m_dataset) qFatal("Still binded series detected !");
98 96 }
99 97
100 98 /*!
101 99 \brief Returns the pointer to the model that is used as the series data source
102 100 */
103 101 QAbstractItemModel* QAbstractSeries::model() const
104 102 {
105 103 return d_ptr->m_model;
106 104 }
107 105
108 106 int QAbstractSeries::mapFirst() const
109 107 {
110 108 return d_ptr->m_mapFirst;
111 109 }
112 110
113 111 int QAbstractSeries::mapCount() const
114 112 {
115 113 return d_ptr->m_mapCount;
116 114 }
117 115
118 116 int QAbstractSeries::mapOrientation() const
119 117 {
120 118 return d_ptr->m_mapOrientation;
121 119 }
122 120
123 121 void QAbstractSeries::setName(const QString& name)
124 122 {
125 123 d_ptr->m_name = name;
126 124 }
127 125
128 126 /*!
129 127 \brief Returns the name of the series.
130 128 \sa setName()
131 129 */
132 130 QString QAbstractSeries::name() const
133 131 {
134 132 return d_ptr->m_name;
135 133 }
136 134
137 135 ///////////////////////////////////////////////////////////////////////////////////////////////////
138 136
139 137 QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q):
140 138 q_ptr(q),
141 139 m_model(0),
142 140 m_dataset(0),
143 141 m_mapFirst(0),
144 142 m_mapCount(-1),
145 143 m_mapOrientation(Qt::Vertical)
146 144 {
147 145 }
148 146
149 147 QAbstractSeriesPrivate::~QAbstractSeriesPrivate()
150 148 {
151 149 }
152 150
153 151 #include "moc_qabstractseries.cpp"
154 152 #include "moc_qabstractseries_p.cpp"
155 153
156 154 QTCOMMERCIALCHART_END_NAMESPACE
157 155
158 156
General Comments 0
You need to be logged in to leave comments. Login now