##// END OF EJS Templates
Docs updated
Marek Rosa -
r908:803e57309061
parent child
Show More
@@ -1,29 +1,29
1 /*!
1 /*!
2 \example examples/splinechart
2 \example examples/splinechart
3 \title SplineChart Example
3 \title SplineChart Example
4 \subtitle
4 \subtitle
5
5
6 The example shows how to create simple spline chart.
6 The example shows how to create simple spline chart.
7
7
8 \image splinechart_example
8 \image splinechart_example
9
9
10 To create spline chart we need to put our data into QSplineSeries. QSplineSeries automatically calculates spline segment control points that are needed to properly draw the spline.
10 To create spline chart we need to put our data into QSplineSeries. QSplineSeries automatically calculates spline segment control points that are needed to properly draw the spline.
11
11
12 \snippet ../examples/splinechart/main.cpp 1
12 \snippet ../examples/splinechart/main.cpp 1
13
13
14 Now lets add some data points to the series.
14 Now let's add some data points to the series.
15
15
16 \snippet ../examples/splinechart/main.cpp 3
16 \snippet ../examples/splinechart/main.cpp 2
17
17
18 The data series has been populated. To display it on a chart we create QChart object and add the data series to it. We also set the title and the values range on y axis, so that our chart is better visible.
18 The data series has been populated. To display it on a chart we create QChart object and add the data series to it. We also set the title and the values range on y axis, so that our chart is better visible.
19
19
20 \snippet ../examples/splinechart/main.cpp 4
20 \snippet ../examples/splinechart/main.cpp 3
21
21
22 Then we create a QChartView object with QChart as a parameter. This way we don't need to create QGraphicsView scene ourselves. We also set the Antialiasing on to have the rendered lines look nicer.
22 Then we create a QChartView object with QChart as a parameter. This way we don't need to create QGraphicsView scene ourselves. We also set the Antialiasing on to have the rendered lines look nicer.
23
23
24 \snippet ../examples/splinechart/main.cpp 5
24 \snippet ../examples/splinechart/main.cpp 4
25
25
26 In the end we set the QChartView as the windows's central widget.
26 In the end we set the QChartView as the windows's central widget.
27
27
28 \snippet ../examples/splinechart/main.cpp 6
28 \snippet ../examples/splinechart/main.cpp 5
29 */
29 */
@@ -1,71 +1,65
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QApplication>
21 #include <QApplication>
22 #include <QMainWindow>
22 #include <QMainWindow>
23 #include <QChartView>
23 #include <QChartView>
24 #include <QSplineSeries>
24 #include <QSplineSeries>
25
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
27
28 int main(int argc, char *argv[])
28 int main(int argc, char *argv[])
29 {
29 {
30 QApplication a(argc, argv);
30 QApplication a(argc, argv);
31
31
32 //![1]
32 //![1]
33 QSplineSeries* series = new QSplineSeries();
33 QSplineSeries* series = new QSplineSeries();
34 //![1]
34 //![1]
35
35
36 //![2]
36 //![2]
37 // QPen red(Qt::red);
38 // red.setWidth(3);
39 // series->setPen(red);
40 //![2]
41
42 //![3]
43 series->append(0, 6);
37 series->append(0, 6);
44 series->append(2, 4);
38 series->append(2, 4);
45 series->append(3, 8);
39 series->append(3, 8);
46 series->append(7, 4);
40 series->append(7, 4);
47 series->append(10, 5);
41 series->append(10, 5);
48 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
42 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
49 //![3]
43 //![2]
50
44
51 //![4]
45 //![3]
52 QChart* chart = new QChart();
46 QChart* chart = new QChart();
53 chart->addSeries(series);
47 chart->addSeries(series);
54 chart->setTitle("Simple spline chart example");
48 chart->setTitle("Simple spline chart example");
55 chart->axisY()->setRange(0, 10);
49 chart->axisY()->setRange(0, 10);
56 //![4]
50 //![3]
57
51
58 //![5]
52 //![4]
59 QChartView* chartView = new QChartView(chart);
53 QChartView* chartView = new QChartView(chart);
60 chartView->setRenderHint(QPainter::Antialiasing);
54 chartView->setRenderHint(QPainter::Antialiasing);
61 //![5]
55 //![4]
62
56
63 //![6]
57 //![5]
64 QMainWindow window;
58 QMainWindow window;
65 window.setCentralWidget(chartView);
59 window.setCentralWidget(chartView);
66 window.resize(400, 300);
60 window.resize(400, 300);
67 window.show();
61 window.show();
68 //![6]
62 //![5]
69
63
70 return a.exec();
64 return a.exec();
71 }
65 }
@@ -1,283 +1,279
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qbarset.h"
21 #include "qbarset.h"
22 #include <QDebug>
22 #include <QDebug>
23 #include <QToolTip>
23 #include <QToolTip>
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 /*!
27 /*!
28 \class QBarSet
28 \class QBarSet
29 \brief part of QtCommercial chart API.
29 \brief part of QtCommercial chart API.
30
30
31 QBarSet represents one set of bars. Set of bars contains one data value for each category.
31 QBarSet represents one set of bars. Set of bars contains one data value for each category.
32 First value of set is assumed to belong to first category, second to second category and so on.
32 First value of set is assumed to belong to first category, second to second category and so on.
33 If set has fewer values than there are categories, then the missing values are assumed to be
33 If set has fewer values than there are categories, then the missing values are assumed to be
34 at the end of set. For missing values in middle of a set, numerical value of zero is used.
34 at the end of set. For missing values in middle of a set, numerical value of zero is used.
35
35
36 \mainclass
36 \mainclass
37
37
38 \sa QBarSeries, QStackedBarSeries, QPercentBarSeries
38 \sa QBarSeries, QStackedBarSeries, QPercentBarSeries
39 */
39 */
40
40
41 /*!
41 /*!
42 \fn void QBarSet::clicked(QString category, Qt::MouseButtons button)
42 \fn void QBarSet::clicked(QString category, Qt::MouseButtons button)
43 \brief signals that set has been clicked
43 \brief signals that set has been clicked
44 Parameter \a category describes on which category was clicked
44 Parameter \a category describes on which category was clicked
45 Parameter \a button mouse button
45 Parameter \a button mouse button
46 */
46 */
47
47
48 /*!
48 /*!
49 \fn void QBarSet::hoverEnter(QPoint pos)
49 \fn void QBarSet::hoverEnter(QPoint pos)
50 \brief signals that mouse has entered over the set at position \a pos.
50 \brief signals that mouse has entered over the set at position \a pos.
51 */
51 */
52
52
53 /*!
53 /*!
54 \fn void QBarSet::hoverLeave()
54 \fn void QBarSet::hoverLeave()
55 \brief signals that mouse has left from the set.
55 \brief signals that mouse has left from the set.
56 */
56 */
57
57
58 /*!
58 /*!
59 \fn void QBarSet::setLabelssVisible(bool visible = true)
60 \brief Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets.
61 */
62
63 /*!
64 \fn void QBarSet::showToolTip(QPoint pos, QString tip)
59 \fn void QBarSet::showToolTip(QPoint pos, QString tip)
65 \brief \internal \a pos \a tip
60 \brief \internal \a pos \a tip
66 */
61 */
67
62
68
63
69 /*!
64 /*!
70 Constructs QBarSet with a name of \a name and with parent of \a parent
65 Constructs QBarSet with a name of \a name and with parent of \a parent
71 */
66 */
72 QBarSet::QBarSet(QString name, QObject *parent)
67 QBarSet::QBarSet(QString name, QObject *parent)
73 : QObject(parent)
68 : QObject(parent)
74 ,m_name(name)
69 ,m_name(name)
75 ,m_labelsVisible(false)
70 ,m_labelsVisible(false)
76 {
71 {
77 }
72 }
78
73
79 /*!
74 /*!
80 Sets new \a name for set.
75 Sets new \a name for set.
81 */
76 */
82 void QBarSet::setName(QString name)
77 void QBarSet::setName(QString name)
83 {
78 {
84 m_name = name;
79 m_name = name;
85 }
80 }
86
81
87 /*!
82 /*!
88 Returns name of the set.
83 Returns name of the set.
89 */
84 */
90 QString QBarSet::name() const
85 QString QBarSet::name() const
91 {
86 {
92 return m_name;
87 return m_name;
93 }
88 }
94
89
95 /*!
90 /*!
96 Appends new value \a value to the end of set.
91 Appends new value \a value to the end of set.
97 */
92 */
98 QBarSet& QBarSet::operator << (const qreal &value)
93 QBarSet& QBarSet::operator << (const qreal &value)
99 {
94 {
100 m_values.append(value);
95 m_values.append(value);
101 emit structureChanged();
96 emit structureChanged();
102 return *this;
97 return *this;
103 }
98 }
104
99
105 /*!
100 /*!
106 Inserts new \a value on the \a i position.
101 Inserts new \a value on the \a i position.
107 The value that is currently at this postion is moved to postion i + 1
102 The value that is currently at this postion is moved to postion i + 1
108 \sa removeValue()
103 \sa removeValue()
109 */
104 */
110 void QBarSet::insertValue(int i, qreal value)
105 void QBarSet::insertValue(int i, qreal value)
111 {
106 {
112 m_values.insert(i, value);
107 m_values.insert(i, value);
113 }
108 }
114
109
115 /*!
110 /*!
116 Removes the value specified by \a i
111 Removes the value specified by \a i
117 \sa insertValue()
112 \sa insertValue()
118 */
113 */
119 void QBarSet::removeValue(int i)
114 void QBarSet::removeValue(int i)
120 {
115 {
121 m_values.removeAt(i);
116 m_values.removeAt(i);
122 }
117 }
123
118
124 /*!
119 /*!
125 Returns count of values in set.
120 Returns count of values in set.
126 */
121 */
127 int QBarSet::count() const
122 int QBarSet::count() const
128 {
123 {
129 return m_values.count();
124 return m_values.count();
130 }
125 }
131
126
132 /*!
127 /*!
133 Returns value of set indexed by \a index
128 Returns value of set indexed by \a index
134 */
129 */
135 qreal QBarSet::valueAt(int index) const
130 qreal QBarSet::valueAt(int index) const
136 {
131 {
137 return m_values.at(index);
132 return m_values.at(index);
138 }
133 }
139
134
140 /*!
135 /*!
141 Sets a new value \a value to set, indexed by \a index
136 Sets a new value \a value to set, indexed by \a index
142 */
137 */
143 void QBarSet::setValue(int index, qreal value)
138 void QBarSet::setValue(int index, qreal value)
144 {
139 {
145 m_values.replace(index,value);
140 m_values.replace(index,value);
146 emit valueChanged();
141 emit valueChanged();
147 }
142 }
148
143
149 /*!
144 /*!
150 Returns total sum of all values in barset.
145 Returns total sum of all values in barset.
151 */
146 */
152 qreal QBarSet::total() const
147 qreal QBarSet::total() const
153 {
148 {
154 qreal total(0);
149 qreal total(0);
155 for (int i=0; i < m_values.count(); i++) {
150 for (int i=0; i < m_values.count(); i++) {
156 total += m_values.at(i);
151 total += m_values.at(i);
157 }
152 }
158 return total;
153 return total;
159 }
154 }
160
155
161 /*!
156 /*!
162 Sets pen for set. Bars of this set are drawn using \a pen
157 Sets pen for set. Bars of this set are drawn using \a pen
163 */
158 */
164 void QBarSet::setPen(const QPen &pen)
159 void QBarSet::setPen(const QPen &pen)
165 {
160 {
166 m_pen = pen;
161 m_pen = pen;
167 emit valueChanged();
162 emit valueChanged();
168 }
163 }
169
164
170 /*!
165 /*!
171 Returns pen of the set.
166 Returns pen of the set.
172 */
167 */
173 QPen QBarSet::pen() const
168 QPen QBarSet::pen() const
174 {
169 {
175 return m_pen;
170 return m_pen;
176 }
171 }
177
172
178 /*!
173 /*!
179 Sets brush for the set. Bars of this set are drawn using \a brush
174 Sets brush for the set. Bars of this set are drawn using \a brush
180 */
175 */
181 void QBarSet::setBrush(const QBrush &brush)
176 void QBarSet::setBrush(const QBrush &brush)
182 {
177 {
183 m_brush = brush;
178 m_brush = brush;
184 emit valueChanged();
179 emit valueChanged();
185 }
180 }
186
181
187 /*!
182 /*!
188 Returns brush of the set.
183 Returns brush of the set.
189 */
184 */
190 QBrush QBarSet::brush() const
185 QBrush QBarSet::brush() const
191 {
186 {
192 return m_brush;
187 return m_brush;
193 }
188 }
194
189
195 /*!
190 /*!
196 Sets \a pen of the values that are drawn on top of this barset
191 Sets \a pen of the values that are drawn on top of this barset
197 */
192 */
198 void QBarSet::setLabelPen(const QPen &pen)
193 void QBarSet::setLabelPen(const QPen &pen)
199 {
194 {
200 m_labelPen = pen;
195 m_labelPen = pen;
201 emit valueChanged();
196 emit valueChanged();
202 }
197 }
203
198
204 /*!
199 /*!
205 Returns pen of the values that are drawn on top of this barset
200 Returns pen of the values that are drawn on top of this barset
206 */
201 */
207 QPen QBarSet::labelPen() const
202 QPen QBarSet::labelPen() const
208 {
203 {
209 return m_labelPen;
204 return m_labelPen;
210 }
205 }
211
206
212 /*!
207 /*!
213 Sets \a brush of the values that are drawn on top of this barset
208 Sets \a brush of the values that are drawn on top of this barset
214 */
209 */
215 void QBarSet::setLabelBrush(const QBrush &brush)
210 void QBarSet::setLabelBrush(const QBrush &brush)
216 {
211 {
217 m_labelBrush = brush;
212 m_labelBrush = brush;
218 emit valueChanged();
213 emit valueChanged();
219 }
214 }
220
215
221 /*!
216 /*!
222 Returns brush of the values that are drawn on top of this barset
217 Returns brush of the values that are drawn on top of this barset
223 */
218 */
224 QBrush QBarSet::labelBrush() const
219 QBrush QBarSet::labelBrush() const
225 {
220 {
226 return m_labelBrush;
221 return m_labelBrush;
227 }
222 }
228
223
229 /*!
224 /*!
230 Sets the \a font for values that are drawn on top of this barset
225 Sets the \a font for values that are drawn on top of this barset
231 */
226 */
232 void QBarSet::setLabelFont(const QFont &font)
227 void QBarSet::setLabelFont(const QFont &font)
233 {
228 {
234 m_labelFont = font;
229 m_labelFont = font;
235 emit valueChanged();
230 emit valueChanged();
236 }
231 }
237
232
238 /*!
233 /*!
239 Returns the pen for values that are drawn on top of this set
234 Returns the pen for values that are drawn on top of this set
240 */
235 */
241 QFont QBarSet::labelFont() const
236 QFont QBarSet::labelFont() const
242 {
237 {
243 return m_labelFont;
238 return m_labelFont;
244 }
239 }
245
240
246 /*!
241 /*!
247 Sets the visibility of barset values to \a visible
242 Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets.
248 */
243 */
244
249 void QBarSet::setLabelsVisible(bool visible)
245 void QBarSet::setLabelsVisible(bool visible)
250 {
246 {
251 m_labelsVisible = visible;
247 m_labelsVisible = visible;
252 emit labelsVisibleChanged(visible);
248 emit labelsVisibleChanged(visible);
253 }
249 }
254
250
255 /*!
251 /*!
256 Returns the visibility of values
252 Returns the visibility of values
257 */
253 */
258 bool QBarSet::labelsVisible() const
254 bool QBarSet::labelsVisible() const
259 {
255 {
260 return m_labelsVisible;
256 return m_labelsVisible;
261 }
257 }
262
258
263 /*!
259 /*!
264 \internal \a pos
260 \internal \a pos
265 */
261 */
266 void QBarSet::barHoverEnterEvent(QPoint pos)
262 void QBarSet::barHoverEnterEvent(QPoint pos)
267 {
263 {
268 emit showToolTip(pos, m_name);
264 emit showToolTip(pos, m_name);
269 emit hoverEnter(pos);
265 emit hoverEnter(pos);
270 }
266 }
271
267
272 /*!
268 /*!
273 \internal
269 \internal
274 */
270 */
275 void QBarSet::barHoverLeaveEvent()
271 void QBarSet::barHoverLeaveEvent()
276 {
272 {
277 // Emit signal to user of charts
273 // Emit signal to user of charts
278 emit hoverLeave();
274 emit hoverLeave();
279 }
275 }
280
276
281 #include "moc_qbarset.cpp"
277 #include "moc_qbarset.cpp"
282
278
283 QTCOMMERCIALCHART_END_NAMESPACE
279 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,86 +1,92
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qseries.h"
21 #include "qseries.h"
22
22
23 /*!
23 /*!
24 \class QSeries
24 \class QSeries
25 \brief Base class for all QtCommercial Chart series.
25 \brief Base class for all QtCommercial Chart series.
26 \mainclass
26 \mainclass
27
27
28 Usually you use the series type specific inherited classes instead of the base class.
28 Usually you use the series type specific inherited classes instead of the base class.
29 \sa QScatterSeries
29 \sa QScatterSeries
30 */
30 */
31
31
32 /*!
32 /*!
33 \enum QSeries::QSeriesType
33 \enum QSeries::QSeriesType
34
34
35 The type of the series object.
35 The type of the series object.
36
36
37 \value SeriesTypeLine
37 \value SeriesTypeLine
38 \value SeriesTypeArea
38 \value SeriesTypeArea
39 \value SeriesTypeBar
39 \value SeriesTypeBar
40 \value SeriesTypeStackedBar
40 \value SeriesTypeStackedBar
41 \value SeriesTypePercentBar
41 \value SeriesTypePercentBar
42 \value SeriesTypePie
42 \value SeriesTypePie
43 \value SeriesTypeScatter
43 \value SeriesTypeScatter
44 \value SeriesTypeSpline
44 \value SeriesTypeSpline
45 */
45 */
46
46
47 /*!
47 /*!
48 \fn QSeries::QSeries(QObject *parent)
48 \fn QSeries::QSeries(QObject *parent)
49 \brief Constructs ChartSeries object with \a parent.
49 \brief Constructs ChartSeries object with \a parent.
50 */
50 */
51
51
52 /*!
52 /*!
53 \fn QSeries::~QSeries()
53 \fn QSeries::~QSeries()
54 \brief Virtual destructor for the chart series.
54 \brief Virtual destructor for the chart series.
55 */
55 */
56
56
57 /*!
57 /*!
58 \fn QSeriesType QSeries::type() const
58 \fn QSeriesType QSeries::type() const
59 \brief The type of the series.
59 \brief The type of the series.
60 */
60 */
61
61
62 /*!
62 /*!
63 \fn bool QSeries::setModel(QAbstractItemModel *model)
63 \fn bool QSeries::setModel(QAbstractItemModel *model)
64 \brief Use the \a model to provide data for the series. The model overrides possible user data
64 \brief Use the \a model to provide data for the series. The model overrides possible user data
65 set with QChartSeries type specific data setters. For example if you call both
65 set with QChartSeries type specific data setters. For example if you call both
66 QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is
66 QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is
67 used by the series. Returns true if the model is valid for the series.
67 used by the series. Returns true if the model is valid for the series.
68 */
68 */
69
69
70 /*!
70 /*!
71 \property QString QSeries::name
72 \brief name of the series property
73 */
74
75 /*!
71 \fn void QSeries::setName(QString name)
76 \fn void QSeries::setName(QString name)
72 \brief Sets a \a name for the series.
77 \brief Sets a \a name for the series.
73
78
74 The name of a series is shown in the legend for QXYSeries.
79 The name of a series is shown in the legend for QXYSeries.
75 \sa QChart::setTitle()
80 \sa QChart::setTitle()
76 \sa QPieSlice::setLabel()
81 \sa QPieSlice::setLabel()
77 \sa QBarSet::setName()
82 \sa QBarSet::setName()
78 */
83 */
79
84
80 /*!
85 /*!
81 \fn QString QSeries::name()
86 \fn QString QSeries::name() const
82 \brief Returns the name of the series.
87 \brief Returns the name of the series.
88 \sa setName()
83 */
89 */
84
90
85 QTCOMMERCIALCHART_USE_NAMESPACE
91 QTCOMMERCIALCHART_USE_NAMESPACE
86 #include "moc_qseries.cpp"
92 #include "moc_qseries.cpp"
@@ -1,198 +1,198
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qsplineseries.h"
21 #include "qsplineseries.h"
22
22
23 /*!
23 /*!
24 \class QSplineSeries
24 \class QSplineSeries
25 \brief Series type used to store data needed to draw a spline.
25 \brief Series type used to store data needed to draw a spline.
26
26
27 QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline
27 QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline
28 Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn.
28 Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn.
29 */
29 */
30
30
31 /*!
31 /*!
32 \fn QSeriesType QSplineSeries::type() const
32 \fn QSeriesType QSplineSeries::type() const
33 Returns the type of the series
33 Returns the type of the series
34 */
34 */
35
35
36 /*!
36 /*!
37 \fn QSeriesType QSplineSeries::controlPoint(int index) const
37 \fn QSeriesType QSplineSeries::controlPoint(int index) const
38 Returns the control point specified by \a index
38 Returns the control point specified by \a index
39 */
39 */
40
40
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
42
43 /*!
43 /*!
44 Constructs empty series object which is a child of \a parent.
44 Constructs empty series object which is a child of \a parent.
45 When series object is added to QChartView or QChart instance then the ownerships is transfered.
45 When series object is added to QChartView or QChart instance then the ownerships is transfered.
46 */
46 */
47
47
48 QSplineSeries::QSplineSeries(QObject *parent) :
48 QSplineSeries::QSplineSeries(QObject *parent) :
49 QLineSeries(parent)
49 QLineSeries(parent)
50 {
50 {
51 connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints()));
51 connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints()));
52 connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints()));
52 connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints()));
53 connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints()));
53 connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints()));
54 }
54 }
55
55
56 /*!
56 /*!
57 \internal
57 \internal
58 Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points.
58 Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points.
59 */
59 */
60 void QSplineSeries::calculateControlPoints()
60 void QSplineSeries::calculateControlPoints()
61 {
61 {
62
62
63 // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit
63 // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit
64 // CPOL License
64 // CPOL License
65
65
66 int n = count() - 1;
66 int n = count() - 1;
67 if (n == 1)
67 if (n == 1)
68 { // Special case: Bezier curve should be a straight line.
68 { // Special case: Bezier curve should be a straight line.
69 // firstControlPoints = new Point[1];
69 // firstControlPoints = new Point[1];
70 // 3P1 = 2P0 + P3
70 // 3P1 = 2P0 + P3
71 m_controlPoints.append(QPointF((2 * x(0) + x(1)) / 3, (2 * y(0) + y(1)) / 3));
71 m_controlPoints.append(QPointF((2 * x(0) + x(1)) / 3, (2 * y(0) + y(1)) / 3));
72
72
73 // P2 = 2P1 P0
73 // P2 = 2P1 P0
74 m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - x(0), 2 * m_controlPoints[0].y() - y(0)));
74 m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - x(0), 2 * m_controlPoints[0].y() - y(0)));
75 return;
75 return;
76 }
76 }
77
77
78 // Calculate first Bezier control points
78 // Calculate first Bezier control points
79 // Right hand side vector
79 // Right hand side vector
80 // Set of equations for P0 to Pn points.
80 // Set of equations for P0 to Pn points.
81 //
81 //
82 // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 |
82 // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 |
83 // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 |
83 // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 |
84 // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 |
84 // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 |
85 // | . . . . . . . . . . . . | | ... | | ... |
85 // | . . . . . . . . . . . . | | ... | | ... |
86 // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi |
86 // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi |
87 // | . . . . . . . . . . . . | | ... | | ... |
87 // | . . . . . . . . . . . . | | ... | | ... |
88 // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) |
88 // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) |
89 // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn |
89 // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn |
90 //
90 //
91 QList<qreal> rhs;
91 QList<qreal> rhs;
92 rhs.append(x(0) + 2 * x(1));
92 rhs.append(x(0) + 2 * x(1));
93
93
94 // Set right hand side X values
94 // Set right hand side X values
95 for (int i = 1; i < n - 1; ++i)
95 for (int i = 1; i < n - 1; ++i)
96 rhs.append(4 * x(i) + 2 * x(i + 1));
96 rhs.append(4 * x(i) + 2 * x(i + 1));
97
97
98 rhs.append((8 * x(n - 1) + x(n)) / 2.0);
98 rhs.append((8 * x(n - 1) + x(n)) / 2.0);
99 // Get first control points X-values
99 // Get first control points X-values
100 QList<qreal> xControl = getFirstControlPoints(rhs);
100 QList<qreal> xControl = getFirstControlPoints(rhs);
101 rhs[0] = y(0) + 2 * y(1);
101 rhs[0] = y(0) + 2 * y(1);
102
102
103 // Set right hand side Y values
103 // Set right hand side Y values
104 for (int i = 1; i < n - 1; ++i)
104 for (int i = 1; i < n - 1; ++i)
105 rhs[i] = 4 * y(i) + 2 * y(i + 1);
105 rhs[i] = 4 * y(i) + 2 * y(i + 1);
106
106
107 rhs[n - 1] = (8 * y(n - 1) + y(n)) / 2.0;
107 rhs[n - 1] = (8 * y(n - 1) + y(n)) / 2.0;
108 // Get first control points Y-values
108 // Get first control points Y-values
109 QList<qreal> yControl = getFirstControlPoints(rhs);
109 QList<qreal> yControl = getFirstControlPoints(rhs);
110
110
111 // Fill output arrays.
111 // Fill output arrays.
112 for (int i = 0; i < n; ++i) {
112 for (int i = 0; i < n; ++i) {
113 // First control point
113 // First control point
114 m_controlPoints.append(QPointF(xControl[i], yControl[i]));
114 m_controlPoints.append(QPointF(xControl[i], yControl[i]));
115 // Second control point
115 // Second control point
116 if (i < n - 1)
116 if (i < n - 1)
117 m_controlPoints.append(QPointF(2 * x(i + 1) - xControl[i + 1], 2 * y(i + 1) - yControl[i + 1]));
117 m_controlPoints.append(QPointF(2 * x(i + 1) - xControl[i + 1], 2 * y(i + 1) - yControl[i + 1]));
118 else
118 else
119 m_controlPoints.append(QPointF((x(n) + xControl[n - 1]) / 2, (y(n) + yControl[n - 1]) / 2));
119 m_controlPoints.append(QPointF((x(n) + xControl[n - 1]) / 2, (y(n) + yControl[n - 1]) / 2));
120 }
120 }
121 }
121 }
122
122
123 /*!
123 /*!
124 \internal
124 \internal
125 */
125 */
126 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs)
126 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs)
127 {
127 {
128 QList<qreal> x; // Solution vector.
128 QList<qreal> x; // Solution vector.
129 QList<qreal> tmp; // Temp workspace.
129 QList<qreal> tmp; // Temp workspace.
130
130
131 qreal b = 2.0;
131 qreal b = 2.0;
132 x.append(rhs[0] / b);
132 x.append(rhs[0] / b);
133 tmp.append(0);
133 tmp.append(0);
134 for (int i = 1; i < rhs.size(); i++) {
134 for (int i = 1; i < rhs.size(); i++) {
135 // Decomposition and forward substitution.
135 // Decomposition and forward substitution.
136 tmp.append(1 / b);
136 tmp.append(1 / b);
137 b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i];
137 b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i];
138 x.append((rhs[i] - x[i - 1]) / b);
138 x.append((rhs[i] - x[i - 1]) / b);
139 }
139 }
140 for (int i = 1; i < rhs.size(); i++)
140 for (int i = 1; i < rhs.size(); i++)
141 x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution.
141 x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution.
142
142
143 return x;
143 return x;
144 }
144 }
145
145
146 /*!
146 /*!
147 \internal
147 \internal
148 Updates the control points, besed on currently avaiable knots.
148 Updates the control points, besed on currently avaiable knots.
149 */
149 */
150 void QSplineSeries::updateControlPoints()
150 void QSplineSeries::updateControlPoints()
151 {
151 {
152 if (count() > 1) {
152 if (count() > 1) {
153 m_controlPoints.clear();
153 m_controlPoints.clear();
154 calculateControlPoints();
154 calculateControlPoints();
155 }
155 }
156 }
156 }
157
157
158 /*!
158 /*//!
159 \fn bool QSplineSeries::setModel(QAbstractItemModel *model)
159 \fn bool QSplineSeries::setModel(QAbstractItemModel *model)
160 Sets the \a model to be used as a data source
160 Sets the \a model to be used as a data source
161 \sa setModelMapping(), setModelMappingRange()
161 \sa setModelMapping(), setModelMappingRange()
162 */
162 */
163 //bool QSplineSeries::setModel(QAbstractItemModel* model)
163 //bool QSplineSeries::setModel(QAbstractItemModel* model)
164 //{
164 //{
165 // QXYSeries::setModel(model);
165 // QXYSeries::setModel(model);
166 //// calculateControlPoints();
166 //// calculateControlPoints();
167 // return true;
167 // return true;
168 //}
168 //}
169
169
170 /*!
170 /*//!
171 \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
171 \fn bool QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
172 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
172 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
173 as a data source for y coordinate. The \a orientation paramater specifies whether the data
173 as a data source for y coordinate. The \a orientation paramater specifies whether the data
174 is in columns or in rows.
174 is in columns or in rows.
175 */
175 */
176 //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
176 //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
177 //{
177 //{
178 // QLineSeries::setModelMapping(modelX, modelY, orientation);
178 // QLineSeries::setModelMapping(modelX, modelY, orientation);
179 //// calculateControlPoints();
179 //// calculateControlPoints();
180 //}
180 //}
181
181
182 /*!
182 /*!
183 \fn bool QSplineSeries::setModelMappingRange(int first, int count)
183 \fn bool QSplineSeries::setModelMappingRange(int first, int count)
184 Allows limiting the model mapping.
184 Allows limiting the model mapping.
185 Parameter \a first specifies which element of the model should be used as a first one of the series.
185 Parameter \a first specifies which element of the model should be used as a first one of the series.
186 Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1)
186 Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1)
187 then all the items following \a first item in a model are used.
187 then all the items following \a first item in a model are used.
188 \sa setModel(), setModelMapping()
188 \sa setModel(), setModelMapping()
189 */
189 */
190 void QSplineSeries::setModelMappingRange(int first, int count)
190 void QSplineSeries::setModelMappingRange(int first, int count)
191 {
191 {
192 QLineSeries::setModelMappingRange(first, count);
192 QLineSeries::setModelMappingRange(first, count);
193 calculateControlPoints();
193 calculateControlPoints();
194 }
194 }
195
195
196 #include "moc_qsplineseries.cpp"
196 #include "moc_qsplineseries.cpp"
197
197
198 QTCOMMERCIALCHART_END_NAMESPACE
198 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,564 +1,559
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qxyseries.h"
21 #include "qxyseries.h"
22 #include <QAbstractItemModel>
22 #include <QAbstractItemModel>
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QXYSeries
27 \class QXYSeries
28 \brief The QXYSeries class is a base class for line, spline and scatter series.
28 \brief The QXYSeries class is a base class for line, spline and scatter series.
29 */
29 */
30
30
31 /*!
31 /*!
32 \fn QPen QXYSeries::pen() const
32 \fn QPen QXYSeries::pen() const
33 \brief Returns pen used to draw points for series.
33 \brief Returns pen used to draw points for series.
34 \sa setPen()
34 \sa setPen()
35 */
35 */
36
36
37 /*!
37 /*!
38 \fn QBrush QXYSeries::brush() const
38 \fn QBrush QXYSeries::brush() const
39 \brief Returns brush used to draw points for series.
39 \brief Returns brush used to draw points for series.
40 \sa setBrush()
40 \sa setBrush()
41 */
41 */
42
42
43 /*!
43 /*!
44 \fn void QXYSeries::clicked(const QPointF& point)
44 \fn void QXYSeries::clicked(const QPointF& point)
45 \brief Signal is emitted when user clicks the \a point on chart.
45 \brief Signal is emitted when user clicks the \a point on chart.
46 */
46 */
47
47
48 /*!
48 /*!
49 \fn void QXYSeries::pointReplaced(int index)
49 \fn void QXYSeries::pointReplaced(int index)
50 \brief \internal \a index
50 \brief \internal \a index
51 */
51 */
52
52
53 /*!
53 /*!
54 \fn void QXYSeries::pointAdded(int index)
54 \fn void QXYSeries::pointAdded(int index)
55 \brief \internal \a index
55 \brief \internal \a index
56 */
56 */
57
57
58 /*!
58 /*!
59 \fn void QXYSeries::pointRemoved(int index)
59 \fn void QXYSeries::pointRemoved(int index)
60 \brief \internal \a index
60 \brief \internal \a index
61 */
61 */
62
62
63 /*!
63 /*!
64 \fn void QXYSeries::updated()
64 \fn void QXYSeries::updated()
65 \brief \internal
65 \brief \internal
66 */
66 */
67
67
68 /*!
68 /*!
69 \fn int QXYSeries::mapFirst() const
69 \fn int QXYSeries::mapFirst() const
70 Returns the index of the model's item that is used as a first one for the series.
70 Returns the index of the model's item that is used as a first one for the series.
71 \sa mapCount()
71 \sa mapCount()
72 */
72 */
73
73
74 /*!
74 /*!
75 \fn int QXYSeries::mapCount() const
75 \fn int QXYSeries::mapCount() const
76 Returns the number of the items that are taken from the model.
76 Returns the number of the items that are taken from the model.
77 If -1 it means all the items of the model following the first one are used.
77 If -1 it means all the items of the model following the first one are used.
78 \sa mapFirst()
78 \sa mapFirst()
79 */
79 */
80
80
81 /*!
81 /*!
82 Constructs empty series object which is a child of \a parent.
82 Constructs empty series object which is a child of \a parent.
83 When series object is added to QChartView or QChart instance ownerships is transfered.
83 When series object is added to QChartView or QChart instance ownerships is transfered.
84 */
84 */
85 QXYSeries::QXYSeries(QObject *parent):QSeries(parent)
85 QXYSeries::QXYSeries(QObject *parent):QSeries(parent)
86 {
86 {
87 m_mapX = -1;
87 m_mapX = -1;
88 m_mapY = -1;
88 m_mapY = -1;
89 m_mapFirst = 0;
89 m_mapFirst = 0;
90 m_mapCount = 0;
90 m_mapCount = 0;
91 m_mapLimited = false;
91 m_mapLimited = false;
92 m_mapOrientation = Qt::Vertical;
92 m_mapOrientation = Qt::Vertical;
93 // m_mapYOrientation = Qt::Vertical;
93 // m_mapYOrientation = Qt::Vertical;
94 }
94 }
95 /*!
95 /*!
96 Destroys the object. Series added to QChartView or QChart instances are owned by those,
96 Destroys the object. Series added to QChartView or QChart instances are owned by those,
97 and are deleted when mentioned object are destroyed.
97 and are deleted when mentioned object are destroyed.
98 */
98 */
99 QXYSeries::~QXYSeries()
99 QXYSeries::~QXYSeries()
100 {
100 {
101 }
101 }
102
102
103 /*!
103 /*!
104 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
104 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
105 */
105 */
106 void QXYSeries::append(qreal x,qreal y)
106 void QXYSeries::append(qreal x,qreal y)
107 {
107 {
108 Q_ASSERT(m_x.size() == m_y.size());
108 Q_ASSERT(m_x.size() == m_y.size());
109 m_x<<x;
109 m_x<<x;
110 m_y<<y;
110 m_y<<y;
111 emit pointAdded(m_x.size()-1);
111 emit pointAdded(m_x.size()-1);
112 }
112 }
113
113
114 /*!
114 /*!
115 This is an overloaded function.
115 This is an overloaded function.
116 Adds data \a point to the series. Points are connected with lines on the chart.
116 Adds data \a point to the series. Points are connected with lines on the chart.
117 */
117 */
118 void QXYSeries::append(const QPointF &point)
118 void QXYSeries::append(const QPointF &point)
119 {
119 {
120 append(point.x(),point.y());
120 append(point.x(),point.y());
121 }
121 }
122
122
123 /*!
123 /*!
124 This is an overloaded function.
124 This is an overloaded function.
125 Adds list of data \a points to the series. Points are connected with lines on the chart.
125 Adds list of data \a points to the series. Points are connected with lines on the chart.
126 */
126 */
127 void QXYSeries::append(const QList<QPointF> points)
127 void QXYSeries::append(const QList<QPointF> points)
128 {
128 {
129 foreach(const QPointF& point , points) {
129 foreach(const QPointF& point , points) {
130 append(point.x(),point.y());
130 append(point.x(),point.y());
131 }
131 }
132 }
132 }
133
133
134 /*!
134 /*!
135 Modifies \a y value for given \a x a value.
135 Modifies \a y value for given \a x a value.
136 */
136 */
137 void QXYSeries::replace(qreal x,qreal y)
137 void QXYSeries::replace(qreal x,qreal y)
138 {
138 {
139 int index = m_x.indexOf(x);
139 int index = m_x.indexOf(x);
140 m_x[index] = x;
140 m_x[index] = x;
141 m_y[index] = y;
141 m_y[index] = y;
142 emit pointReplaced(index);
142 emit pointReplaced(index);
143 }
143 }
144
144
145 /*!
145 /*!
146 This is an overloaded function.
146 This is an overloaded function.
147 Replaces current y value of for given \a point x value with \a point y value.
147 Replaces current y value of for given \a point x value with \a point y value.
148 */
148 */
149 void QXYSeries::replace(const QPointF &point)
149 void QXYSeries::replace(const QPointF &point)
150 {
150 {
151 replace(point.x(),point.y());
151 replace(point.x(),point.y());
152 }
152 }
153
153
154 /*!
154 /*!
155 Removes first \a x value and related y value.
155 Removes first \a x value and related y value.
156 */
156 */
157 void QXYSeries::remove(qreal x)
157 void QXYSeries::remove(qreal x)
158 {
158 {
159 int index = m_x.indexOf(x);
159 int index = m_x.indexOf(x);
160
160
161 if (index == -1) return;
161 if (index == -1) return;
162
162
163 m_x.remove(index);
163 m_x.remove(index);
164 m_y.remove(index);
164 m_y.remove(index);
165
165
166 emit pointRemoved(index);
166 emit pointRemoved(index);
167 }
167 }
168
168
169 /*!
169 /*!
170 Removes current \a x and \a y value.
170 Removes current \a x and \a y value.
171 */
171 */
172 void QXYSeries::remove(qreal x,qreal y)
172 void QXYSeries::remove(qreal x,qreal y)
173 {
173 {
174 int index =-1;
174 int index =-1;
175 do {
175 do {
176 index = m_x.indexOf(x,index+1);
176 index = m_x.indexOf(x,index+1);
177 } while (index !=-1 && m_y.at(index)!=y);
177 } while (index !=-1 && m_y.at(index)!=y);
178
178
179 if (index==-1) return;
179 if (index==-1) return;
180
180
181 m_x.remove(index);
181 m_x.remove(index);
182 m_y.remove(index);
182 m_y.remove(index);
183 emit pointRemoved(index);
183 emit pointRemoved(index);
184 }
184 }
185
185
186 /*!
186 /*!
187 Removes current \a point x value. Note \a point y value is ignored.
187 Removes current \a point x value. Note \a point y value is ignored.
188 */
188 */
189 void QXYSeries::remove(const QPointF &point)
189 void QXYSeries::remove(const QPointF &point)
190 {
190 {
191 remove(point.x(),point.y());
191 remove(point.x(),point.y());
192 }
192 }
193
193
194 /*!
194 /*!
195 Removes all data points from the series.
195 Removes all data points from the series.
196 */
196 */
197 void QXYSeries::removeAll()
197 void QXYSeries::removeAll()
198 {
198 {
199 m_x.clear();
199 m_x.clear();
200 m_y.clear();
200 m_y.clear();
201 }
201 }
202
202
203 /*!
203 /*!
204 \internal \a pos
204 \internal \a pos
205 */
205 */
206 qreal QXYSeries::x(int pos) const
206 qreal QXYSeries::x(int pos) const
207 {
207 {
208 if (m_model) {
208 if (m_model) {
209 if (m_mapOrientation == Qt::Vertical)
209 if (m_mapOrientation == Qt::Vertical)
210 // consecutive data is read from model's column
210 // consecutive data is read from model's column
211 return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble();
211 return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble();
212 else
212 else
213 // consecutive data is read from model's row
213 // consecutive data is read from model's row
214 return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble();
214 return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble();
215 } else {
215 } else {
216 // model is not specified, return the data from series' internal data store
216 // model is not specified, return the data from series' internal data store
217 return m_x.at(pos);
217 return m_x.at(pos);
218 }
218 }
219 }
219 }
220
220
221 /*!
221 /*!
222 \internal \a pos
222 \internal \a pos
223 */
223 */
224 qreal QXYSeries::y(int pos) const
224 qreal QXYSeries::y(int pos) const
225 {
225 {
226 if (m_model) {
226 if (m_model) {
227 if (m_mapOrientation == Qt::Vertical)
227 if (m_mapOrientation == Qt::Vertical)
228 // consecutive data is read from model's column
228 // consecutive data is read from model's column
229 return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble();
229 return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble();
230 else
230 else
231 // consecutive data is read from model's row
231 // consecutive data is read from model's row
232 return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble();
232 return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble();
233 } else {
233 } else {
234 // model is not specified, return the data from series' internal data store
234 // model is not specified, return the data from series' internal data store
235 return m_y.at(pos);
235 return m_y.at(pos);
236 }
236 }
237 }
237 }
238
238
239 /*!
239 /*!
240 Returns number of data points within series.
240 Returns number of data points within series.
241 */
241 */
242 int QXYSeries::count() const
242 int QXYSeries::count() const
243 {
243 {
244 Q_ASSERT(m_x.size() == m_y.size());
244 Q_ASSERT(m_x.size() == m_y.size());
245
245
246 if (m_model) {
246 if (m_model) {
247 if (m_mapOrientation == Qt::Vertical) {
247 if (m_mapOrientation == Qt::Vertical) {
248 // data is in a column. Return the number of mapped items if the model's column have enough items
248 // data is in a column. Return the number of mapped items if the model's column have enough items
249 // or the number of items that can be mapped
249 // or the number of items that can be mapped
250 if (m_mapLimited)
250 if (m_mapLimited)
251 return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0));
251 return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0));
252 else
252 else
253 return qMax(m_model->rowCount() - m_mapFirst, 0);
253 return qMax(m_model->rowCount() - m_mapFirst, 0);
254 } else {
254 } else {
255 // data is in a row. Return the number of mapped items if the model's row have enough items
255 // data is in a row. Return the number of mapped items if the model's row have enough items
256 // or the number of items that can be mapped
256 // or the number of items that can be mapped
257 if (m_mapLimited)
257 if (m_mapLimited)
258 return qMin(m_mapCount, qMax(m_model->columnCount() - m_mapFirst, 0));
258 return qMin(m_mapCount, qMax(m_model->columnCount() - m_mapFirst, 0));
259 else
259 else
260 return qMax(m_model->columnCount() - m_mapFirst, 0);
260 return qMax(m_model->columnCount() - m_mapFirst, 0);
261 }
261 }
262 }
262 }
263
263
264 // model is not specified, return the number of points in the series internal data store
264 // model is not specified, return the number of points in the series internal data store
265 return m_x.size();
265 return m_x.size();
266 }
266 }
267
267
268 /*!
268 /*!
269 Returns the data points of the series.
269 Returns the data points of the series.
270 */
270 */
271 QList<QPointF> QXYSeries::data()
271 QList<QPointF> QXYSeries::data()
272 {
272 {
273 QList<QPointF> data;
273 QList<QPointF> data;
274 for (int i(0); i < m_x.count() && i < m_y.count(); i++)
274 for (int i(0); i < m_x.count() && i < m_y.count(); i++)
275 data.append(QPointF(m_x.at(i), m_y.at(i)));
275 data.append(QPointF(m_x.at(i), m_y.at(i)));
276 return data;
276 return data;
277 }
277 }
278
278
279
279
280 /*!
280 /*!
281 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
281 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
282 pen from chart theme is used.
282 pen from chart theme is used.
283 \sa QChart::setChartTheme()
283 \sa QChart::setChartTheme()
284 */
284 */
285 void QXYSeries::setPen(const QPen &pen)
285 void QXYSeries::setPen(const QPen &pen)
286 {
286 {
287 if (pen != m_pen) {
287 if (pen != m_pen) {
288 m_pen = pen;
288 m_pen = pen;
289 emit updated();
289 emit updated();
290 }
290 }
291 }
291 }
292
292
293 /*!
293 /*!
294 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
294 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
295 from chart theme setting is used.
295 from chart theme setting is used.
296 \sa QChart::setChartTheme()
296 \sa QChart::setChartTheme()
297 */
297 */
298
298
299 void QXYSeries::setBrush(const QBrush &brush)
299 void QXYSeries::setBrush(const QBrush &brush)
300 {
300 {
301 if (brush != m_brush) {
301 if (brush != m_brush) {
302 m_brush = brush;
302 m_brush = brush;
303 emit updated();
303 emit updated();
304 }
304 }
305 }
305 }
306
306
307
307
308 /*!
308 /*!
309 Stream operator for adding a data \a point to the series.
309 Stream operator for adding a data \a point to the series.
310 \sa append()
310 \sa append()
311 */
311 */
312
312
313 QXYSeries& QXYSeries::operator<< (const QPointF &point)
313 QXYSeries& QXYSeries::operator<< (const QPointF &point)
314 {
314 {
315 append(point);
315 append(point);
316 return *this;
316 return *this;
317 }
317 }
318
318
319
319
320 /*!
320 /*!
321 Stream operator for adding a list of \a points to the series.
321 Stream operator for adding a list of \a points to the series.
322 \sa append()
322 \sa append()
323 */
323 */
324
324
325 QXYSeries& QXYSeries::operator<< (const QList<QPointF> points)
325 QXYSeries& QXYSeries::operator<< (const QList<QPointF> points)
326 {
326 {
327 append(points);
327 append(points);
328 return *this;
328 return *this;
329 }
329 }
330
330
331 /*!
331 /*!
332 \internal
332 \internal
333 */
333 */
334 void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
334 void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
335 {
335 {
336 Q_UNUSED(bottomRight)
336 Q_UNUSED(bottomRight)
337
337
338 if (m_mapOrientation == Qt::Vertical) {
338 if (m_mapOrientation == Qt::Vertical) {
339 if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount))
339 if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount))
340 emit pointReplaced(topLeft.row() - m_mapFirst);
340 emit pointReplaced(topLeft.row() - m_mapFirst);
341 } else {
341 } else {
342 if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount))
342 if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount))
343 emit pointReplaced(topLeft.column() - m_mapFirst);
343 emit pointReplaced(topLeft.column() - m_mapFirst);
344 }
344 }
345 }
345 }
346
346
347 /*!
347 /*!
348 \internal
348 \internal
349 */
349 */
350 void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end)
350 void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end)
351 {
351 {
352 Q_UNUSED(parent)
352 Q_UNUSED(parent)
353 // Q_UNUSED(end)
353 // Q_UNUSED(end)
354
354
355 if (m_mapLimited) {
355 if (m_mapLimited) {
356 if (start >= m_mapFirst + m_mapCount) {
356 if (start >= m_mapFirst + m_mapCount) {
357 // the added data is below mapped area
357 // the added data is below mapped area
358 // therefore it has no relevance
358 // therefore it has no relevance
359 return;
359 return;
360 } else {
360 } else {
361 // the added data is in the mapped area or before it and update is needed
361 // the added data is in the mapped area or before it and update is needed
362
362
363 // check how many mapped items there is currently (before new items are added)
363 // check how many mapped items there is currently (before new items are added)
364 // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem
364 // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem
365 // internal storage before new ones can be added
365 // internal storage before new ones can be added
366
366
367 int itemsToRemove = qMin(count() - qMax(start - m_mapFirst, 0), end - start + 1);
367 int itemsToRemove = qMin(count() - qMax(start - m_mapFirst, 0), end - start + 1);
368 if (m_mapCount == count()) {
368 if (m_mapCount == count()) {
369 for (int i = 0; i < itemsToRemove; i++)
369 for (int i = 0; i < itemsToRemove; i++)
370 emit pointRemoved(qMin(end, count()) - i);
370 emit pointRemoved(qMin(end, count()) - i);
371 }
371 }
372 }
372 }
373 } else {
373 } else {
374 // map is not limited (it includes all the items starting from m_mapFirst till the end of model)
374 // map is not limited (it includes all the items starting from m_mapFirst till the end of model)
375 // nothing to do
375 // nothing to do
376 // emit pointAdded(qMax(start - m_mapFirst, 0));
376 // emit pointAdded(qMax(start - m_mapFirst, 0));
377 }
377 }
378 }
378 }
379
379
380 /*!
380 /*!
381 \internal
381 \internal
382 */
382 */
383 void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end)
383 void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end)
384 {
384 {
385 Q_UNUSED(parent)
385 Q_UNUSED(parent)
386 // Q_UNUSED(end)
386 // Q_UNUSED(end)
387
387
388 if (m_mapLimited) {
388 if (m_mapLimited) {
389 if (start >= m_mapFirst + m_mapCount) {
389 if (start >= m_mapFirst + m_mapCount) {
390 // the added data is below mapped area
390 // the added data is below mapped area
391 // therefore it has no relevance
391 // therefore it has no relevance
392 return;
392 return;
393 } else {
393 } else {
394 // the added data is in the mapped area or before it
394 // the added data is in the mapped area or before it
395 // update needed
395 // update needed
396 if (count() > 0) {
396 if (count() > 0) {
397 int toBeAdded = qMin(m_mapCount - (start - m_mapFirst), end - start + 1);
397 int toBeAdded = qMin(m_mapCount - (start - m_mapFirst), end - start + 1);
398 for (int i = 0; i < toBeAdded; i++)
398 for (int i = 0; i < toBeAdded; i++)
399 if (start + i >= m_mapFirst)
399 if (start + i >= m_mapFirst)
400 emit pointAdded(start + i);
400 emit pointAdded(start + i);
401 }
401 }
402 }
402 }
403 } else {
403 } else {
404 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
404 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
405 for (int i = 0; i < end - start + 1; i++)
405 for (int i = 0; i < end - start + 1; i++)
406 emit pointAdded(start + i);
406 emit pointAdded(start + i);
407 }
407 }
408 }
408 }
409
409
410 /*!
410 /*!
411 \internal
411 \internal
412 */
412 */
413 void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end)
413 void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end)
414 {
414 {
415 Q_UNUSED(parent)
415 Q_UNUSED(parent)
416 // Q_UNUSED(end)
416 // Q_UNUSED(end)
417
417
418 if (m_mapLimited) {
418 if (m_mapLimited) {
419 if (start >= m_mapFirst + m_mapCount) {
419 if (start >= m_mapFirst + m_mapCount) {
420 // the removed data is below mapped area
420 // the removed data is below mapped area
421 // therefore it has no relevance
421 // therefore it has no relevance
422 return;
422 return;
423 } else {
423 } else {
424 // the removed data is in the mapped area or before it
424 // the removed data is in the mapped area or before it
425 // update needed
425 // update needed
426
426
427 // check how many items need to be removed from the xychartitem storage
427 // check how many items need to be removed from the xychartitem storage
428 // the number equals the number of items that are removed and that lay before
428 // the number equals the number of items that are removed and that lay before
429 // or in the mapped area. Items that lay beyond the map do not count
429 // or in the mapped area. Items that lay beyond the map do not count
430 // the max is the current number of items in storage (count())
430 // the max is the current number of items in storage (count())
431 int itemsToRemove = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1);
431 int itemsToRemove = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1);
432 for (int i = 0; i < itemsToRemove; i++)
432 for (int i = 0; i < itemsToRemove; i++)
433 emit pointRemoved(start);
433 emit pointRemoved(start);
434 }
434 }
435 } else {
435 } else {
436 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
436 // map is not limited (it included all the items starting from m_mapFirst till the end of model)
437 for (int i = 0; i < end - start + 1; i++)
437 for (int i = 0; i < end - start + 1; i++)
438 emit pointRemoved(start);
438 emit pointRemoved(start);
439 }
439 }
440 }
440 }
441
441
442 /*!
442 /*!
443 \internal
443 \internal
444 */
444 */
445 void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end)
445 void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end)
446 {
446 {
447 Q_UNUSED(parent)
447 Q_UNUSED(parent)
448 Q_UNUSED(end)
448 Q_UNUSED(end)
449
449
450 // how many items there were before data was removed
450 // how many items there were before data was removed
451 // int oldCount = count() - 1;
451 // int oldCount = count() - 1;
452
452
453 if (m_mapLimited) {
453 if (m_mapLimited) {
454 if (start >= m_mapFirst + m_mapCount) {
454 if (start >= m_mapFirst + m_mapCount) {
455 // the removed data is below mapped area
455 // the removed data is below mapped area
456 // therefore it has no relevance
456 // therefore it has no relevance
457 return;
457 return;
458 } else {
458 } else {
459 // if the current items count in the whole model is bigger than the index of the last item
459 // if the current items count in the whole model is bigger than the index of the last item
460 // that was removed than it means there are some extra items available
460 // that was removed than it means there are some extra items available
461
461
462 int removedItemsCount = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1);
462 int removedItemsCount = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1);
463 int extraItemsAvailable = 0;
463 int extraItemsAvailable = 0;
464 if (m_mapOrientation == Qt::Vertical) {
464 if (m_mapOrientation == Qt::Vertical) {
465 extraItemsAvailable = qMax(m_model->rowCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0);
465 extraItemsAvailable = qMax(m_model->rowCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0);
466 } else {
466 } else {
467 extraItemsAvailable = qMax(m_model->columnCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0);
467 extraItemsAvailable = qMax(m_model->columnCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0);
468 }
468 }
469
469
470 // if there are excess items available (below the mapped area) use them to repopulate mapped area
470 // if there are excess items available (below the mapped area) use them to repopulate mapped area
471 int toBeAdded = qMin(extraItemsAvailable, removedItemsCount);
471 int toBeAdded = qMin(extraItemsAvailable, removedItemsCount);
472 for (int k = 0; k < toBeAdded; k++)
472 for (int k = 0; k < toBeAdded; k++)
473 emit pointAdded(m_mapFirst + m_mapCount - removedItemsCount + k);
473 emit pointAdded(m_mapFirst + m_mapCount - removedItemsCount + k);
474 }
474 }
475 } else {
475 } else {
476 // data was removed from XYSeries interal storage. Nothing more to do
476 // data was removed from XYSeries interal storage. Nothing more to do
477 }
477 }
478 }
478 }
479
479
480 /*!
480 /*!
481 \fn QAbstractItemModel* QXYSeries::model()
482 Returns the model from which the series takes its data.
483 */
484
485 /*!
486 \fn bool QXYSeries::setModel(QAbstractItemModel *model)
481 \fn bool QXYSeries::setModel(QAbstractItemModel *model)
487 Sets the \a model to be used as a data source
482 Sets the \a model to be used as a data source
488 \sa setModelMapping(), setModelMappingRange()
483 \sa setModelMapping(), setModelMappingRange()
489 */
484 */
490 bool QXYSeries::setModel(QAbstractItemModel *model) {
485 bool QXYSeries::setModel(QAbstractItemModel *model) {
491
486
492 // disconnect signals from old model
487 // disconnect signals from old model
493 if (m_model) {
488 if (m_model) {
494 disconnect(m_model, 0, this, 0);
489 disconnect(m_model, 0, this, 0);
495 m_mapX = -1;
490 m_mapX = -1;
496 m_mapY = -1;
491 m_mapY = -1;
497 m_mapFirst = 0;
492 m_mapFirst = 0;
498 m_mapCount = 0;
493 m_mapCount = 0;
499 m_mapLimited = false;
494 m_mapLimited = false;
500 m_mapOrientation = Qt::Vertical;
495 m_mapOrientation = Qt::Vertical;
501 }
496 }
502
497
503 // set new model
498 // set new model
504 if (model) {
499 if (model) {
505 m_model = model;
500 m_model = model;
506 return true;
501 return true;
507 } else {
502 } else {
508 m_model = 0;
503 m_model = 0;
509 return false;
504 return false;
510 }
505 }
511 }
506 }
512
507
513 /*!
508 /*!
514 \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
509 \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
515 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
510 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
516 as a data source for y coordinate. The \a orientation paramater specifies whether the data
511 as a data source for y coordinate. The \a orientation paramater specifies whether the data
517 is in columns or in rows.
512 is in columns or in rows.
518 \sa setModel(), setModelMappingRange()
513 \sa setModel(), setModelMappingRange()
519 */
514 */
520 void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
515 void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
521 {
516 {
522 if (m_model == 0)
517 if (m_model == 0)
523 return;
518 return;
524 m_mapX = modelX;
519 m_mapX = modelX;
525 m_mapY = modelY;
520 m_mapY = modelY;
526 m_mapFirst = 0;
521 m_mapFirst = 0;
527 m_mapOrientation = orientation;
522 m_mapOrientation = orientation;
528 if (m_mapOrientation == Qt::Vertical) {
523 if (m_mapOrientation == Qt::Vertical) {
529 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
524 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
530 connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
525 connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
531 connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
526 connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
532 connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
527 connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
533 connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
528 connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
534 } else {
529 } else {
535 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
530 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
536 connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
531 connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int)));
537 connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
532 connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
538 connect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
533 connect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int)));
539 connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
534 connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
540 }
535 }
541 }
536 }
542
537
543 /*!
538 /*!
544 \fn bool QXYSeries::setModelMappingRange(int first, int count)
539 \fn bool QXYSeries::setModelMappingRange(int first, int count)
545 Allows limiting the model mapping.
540 Allows limiting the model mapping.
546 Parameter \a first specifies which element of the model should be used as a first one of the series.
541 Parameter \a first specifies which element of the model should be used as a first one of the series.
547 Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1)
542 Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1)
548 then all the items following \a first item in a model are used.
543 then all the items following \a first item in a model are used.
549 \sa setModel(), setModelMapping()
544 \sa setModel(), setModelMapping()
550 */
545 */
551 void QXYSeries::setModelMappingRange(int first, int count)
546 void QXYSeries::setModelMappingRange(int first, int count)
552 {
547 {
553 m_mapFirst = first;
548 m_mapFirst = first;
554 if (count == 0) {
549 if (count == 0) {
555 m_mapLimited = false;
550 m_mapLimited = false;
556 } else {
551 } else {
557 m_mapCount = count;
552 m_mapCount = count;
558 m_mapLimited = true;
553 m_mapLimited = true;
559 }
554 }
560 }
555 }
561
556
562 #include "moc_qxyseries.cpp"
557 #include "moc_qxyseries.cpp"
563
558
564 QTCOMMERCIALCHART_END_NAMESPACE
559 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now