##// END OF EJS Templates
Krazy reported errors...
Michal Klocek -
r974:de7be57d3935
parent child
Show More
@@ -16,7 +16,7
16
16
17 \snippet ../examples/stackedbarchartdrilldown/main.cpp 1
17 \snippet ../examples/stackedbarchartdrilldown/main.cpp 1
18
18
19 To enable drilldown we create own view, which implements handler for right click. All QBarSeries derived classes send out rightClicked(QBarSet*, QString) signal when series is clicked with right mouse button. The parameters QBarSet and QString contain the pointer to clicked bar set and name of category, where click occured.
19 To enable drilldown we create own view, which implements handler for right click. All QBarSeries derived classes send out rightClicked(QBarSet*, QString) signal when series is clicked with right mouse button. The parameters QBarSet and QString contain the pointer to clicked bar set and name of category, where click occurred.
20
20
21 In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
21 In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
22
22
@@ -143,7 +143,7 void ChartAnimator::updateLayout(Axis *item , QVector<qreal> &newLayout)
143 QRectF rect = item->geometry();
143 QRectF rect = item->geometry();
144 oldLayout.resize(newLayout.count());
144 oldLayout.resize(newLayout.count());
145
145
146 for(int i = 0, j = oldLayout.count() - 1; i < (oldLayout.count() + 1) / 2; i++, j--) {
146 for(int i = 0, j = oldLayout.count() - 1; i < (oldLayout.count() + 1) / 2; ++i, --j) {
147 oldLayout[i] = item->axisType() == Axis::X_AXIS ? rect.left() : rect.bottom();
147 oldLayout[i] = item->axisType() == Axis::X_AXIS ? rect.left() : rect.bottom();
148 oldLayout[j] = item->axisType() == Axis::X_AXIS ? rect.right() : rect.top();
148 oldLayout[j] = item->axisType() == Axis::X_AXIS ? rect.right() : rect.top();
149 }
149 }
@@ -161,7 +161,7 void ChartAnimator::updateLayout(Axis *item , QVector<qreal> &newLayout)
161 case ScrollRightState: {
161 case ScrollRightState: {
162 oldLayout.resize(newLayout.count());
162 oldLayout.resize(newLayout.count());
163
163
164 for(int i = 0, j = i + 1; i < oldLayout.count() - 1; i++, j++)
164 for(int i = 0, j = i + 1; i < oldLayout.count() - 1; ++i, ++j)
165 oldLayout[i]= oldLayout[j];
165 oldLayout[i]= oldLayout[j];
166 }
166 }
167 break;
167 break;
@@ -169,14 +169,14 void ChartAnimator::updateLayout(Axis *item , QVector<qreal> &newLayout)
169 case ScrollLeftState: {
169 case ScrollLeftState: {
170 oldLayout.resize(newLayout.count());
170 oldLayout.resize(newLayout.count());
171
171
172 for(int i = oldLayout.count() - 1, j = i - 1; i > 0; i--, j--)
172 for(int i = oldLayout.count() - 1, j = i - 1; i > 0; --i, --j)
173 oldLayout[i]= oldLayout[j];
173 oldLayout[i]= oldLayout[j];
174 }
174 }
175 break;
175 break;
176 default: {
176 default: {
177 oldLayout.resize(newLayout.count());
177 oldLayout.resize(newLayout.count());
178 QRectF rect = item->geometry();
178 QRectF rect = item->geometry();
179 for(int i = 0, j = oldLayout.count() - 1; i < oldLayout.count(); i++, j--)
179 for(int i = 0, j = oldLayout.count() - 1; i < oldLayout.count(); ++i, --j)
180 oldLayout[i] = item->axisType() == Axis::X_AXIS ? rect.left() : rect.top();
180 oldLayout[i] = item->axisType() == Axis::X_AXIS ? rect.left() : rect.top();
181 }
181 }
182 break;
182 break;
@@ -296,4 +296,6 void ChartAnimator::setState(State state, const QPointF &point)
296 m_point = point;
296 m_point = point;
297 }
297 }
298
298
299 #include "moc_chartanimator_p.cpp"
300
299 QTCOMMERCIALCHART_END_NAMESPACE
301 QTCOMMERCIALCHART_END_NAMESPACE
@@ -37,8 +37,9 class ScatterChartItem;
37 class LineChartItem;
37 class LineChartItem;
38 class XYChartItem;
38 class XYChartItem;
39
39
40 class ChartAnimator : public QObject {
40 class ChartAnimator : public QObject
41
41 {
42 Q_OBJECT
42 public:
43 public:
43 enum State{ShowState, ScrollUpState, ScrollDownState, ScrollLeftState, ScrollRightState, ZoomInState, ZoomOutState};
44 enum State{ShowState, ScrollUpState, ScrollDownState, ScrollLeftState, ScrollRightState, ZoomInState, ZoomOutState};
44
45
@@ -118,7 +118,7 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &en
118 break;
118 break;
119 case LineDrawAnimation:{
119 case LineDrawAnimation:{
120 Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count());
120 Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count());
121 int count = endPair.first.count()* qBound(0.0, progress, 1.0);
121 int count = endPair.first.count()* qBound(qreal(0), progress, qreal(1));
122 for(int i = 0; i < count; i++) {
122 for(int i = 0; i < count; i++) {
123 result.first << endPair.first[i];
123 result.first << endPair.first[i];
124 if(i + 1 == count)
124 if(i + 1 == count)
@@ -85,7 +85,7 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant &end, q
85 }
85 }
86 break;
86 break;
87 case LineDrawAnimation: {
87 case LineDrawAnimation: {
88 for(int i = 0; i < endVector.count() * qBound(0.0, progress, 1.0); i++)
88 for(int i = 0; i < endVector.count() * qBound(qreal(0), progress, qreal(1)); i++)
89 result << endVector[i];
89 result << endVector[i];
90 }
90 }
91 break;
91 break;
@@ -110,7 +110,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
110 /*!
110 /*!
111 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
111 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
112 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
112 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
113 When series object is added to QChartView or QChart instance ownerships is transfered.
113 When series object is added to QChartView or QChart instance ownerships is transferred.
114 */
114 */
115 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
115 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
116 : QSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
116 : QSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
@@ -37,7 +37,7 QChartAxisCategories::~QChartAxisCategories()
37 void QChartAxisCategories::insert(const QBarCategories &categories)
37 void QChartAxisCategories::insert(const QBarCategories &categories)
38 {
38 {
39 int i=1;
39 int i=1;
40 foreach (QString string , categories) {
40 foreach (const QString& string , categories) {
41 d_ptr->m_map.insert(i,string);
41 d_ptr->m_map.insert(i,string);
42 i++;
42 i++;
43 }
43 }
@@ -195,4 +195,4 QString BarChartModel::categoryName(int category)
195
195
196 #include "moc_barchartmodel_p.cpp"
196 #include "moc_barchartmodel_p.cpp"
197
197
198 QTCOMMERCIALCHART_END_NAMESPACE No newline at end of file
198 QTCOMMERCIALCHART_END_NAMESPACE
@@ -38,7 +38,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 \class QBarSeries
38 \class QBarSeries
39 \brief part of QtCommercial chart API.
39 \brief part of QtCommercial chart API.
40
40
41 QBarSeries represents a series of data shown as bars. One QBarSeries can contain multible
41 QBarSeries represents a series of data shown as bars. One QBarSeries can contain multiple
42 QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined
42 QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined
43 by QStringList.
43 by QStringList.
44
44
@@ -103,7 +103,7 void QBarSeries::appendBarSet(QBarSet *set)
103 }
103 }
104
104
105 /*!
105 /*!
106 Removes a set of bars from series. Releases ownership of \a set. Doesnt delete \a set.
106 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
107 Disconnects the clicked(QString, Qt::MouseButtons) signal
107 Disconnects the clicked(QString, Qt::MouseButtons) signal
108 of \a set from this series
108 of \a set from this series
109 */
109 */
@@ -131,7 +131,7 void QBarSeries::appendBarSets(QList<QBarSet* > sets)
131 }
131 }
132
132
133 /*!
133 /*!
134 Removes a list of barsets from series. Releases ownership of \a sets. Doesnt delete \a sets.
134 Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets.
135 Disconnects the clicked(QString, Qt::MouseButtons) signal
135 Disconnects the clicked(QString, Qt::MouseButtons) signal
136 of \a sets from this series
136 of \a sets from this series
137 */
137 */
@@ -231,7 +231,7 bool QBarSeries::setModel(QAbstractItemModel *model)
231 Parameter \a bottomBoundry indicates the column/row where the first bar set is located in the model.
231 Parameter \a bottomBoundry indicates the column/row where the first bar set is located in the model.
232 Parameter \a topBoundry indicates the column/row where the last bar set is located in the model.
232 Parameter \a topBoundry indicates the column/row where the last bar set is located in the model.
233 All the columns/rows inbetween those two values are also used as data for bar sets.
233 All the columns/rows inbetween those two values are also used as data for bar sets.
234 The \a orientation paramater specifies whether the data is in columns or in rows.
234 The \a orientation parameter specifies whether the data is in columns or in rows.
235 */
235 */
236 void QBarSeries::setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation)
236 void QBarSeries::setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation)
237 {
237 {
@@ -33,7 +33,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 \brief part of QtCommercial chart API.
33 \brief part of QtCommercial chart API.
34
34
35 QPercentBarSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage
35 QPercentBarSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage
36 of all bars in category. One QPercentBarSeries can contain multible QBarSet data sets.
36 of all bars in category. One QPercentBarSeries can contain multiple QBarSet data sets.
37 QBarSeries groups the data from sets to categories, which are defined by QStringList.
37 QBarSeries groups the data from sets to categories, which are defined by QStringList.
38
38
39 \mainclass
39 \mainclass
@@ -33,7 +33,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 \brief part of QtCommercial chart API.
33 \brief part of QtCommercial chart API.
34
34
35 QStackedBarSeries represents a series of data shown as bars. All bars in same category are
35 QStackedBarSeries represents a series of data shown as bars. All bars in same category are
36 stacked on top of each other. One QStackedBarSeries can contain multible QBarSet data sets.
36 stacked on top of each other. One QStackedBarSeries can contain multiple QBarSet data sets.
37 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
37 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
38
38
39 \mainclass
39 \mainclass
@@ -52,13 +52,8 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
52 return;
52 return;
53 }
53 }
54
54
55 if(!series->parent()){
55 series->setParent(this); // take ownership
56 series->setParent(this); // take ownership
56 axisY->setParent(this); // take ownership
57 };
58
59 if(!axisY->parent()){
60 axisY->setParent(this); // take ownership
61 }
62
57
63 Domain* domain = m_axisDomainMap.value(axisY);
58 Domain* domain = m_axisDomainMap.value(axisY);
64
59
@@ -111,26 +106,23 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
111
106
112 }
107 }
113
108
114 void ChartDataSet::removeSeries(QSeries* series)
109 QChartAxis* ChartDataSet::removeSeries(QSeries* series)
115 {
110 {
116
117 QChartAxis* axis = m_seriesAxisMap.value(series);
111 QChartAxis* axis = m_seriesAxisMap.value(series);
118
112
119 if(!axis){
113 if(!axis){
120 qWarning()<<"Can not remove series. Series not found on the chart.";
114 qWarning()<<"Can not remove series. Series not found on the chart.";
121 return;
115 return 0;
122 }
116 }
117
123 emit seriesRemoved(series);
118 emit seriesRemoved(series);
119
124 m_seriesAxisMap.remove(series);
120 m_seriesAxisMap.remove(series);
125 int key = seriesIndex(series);
121 int key = seriesIndex(series);
126 Q_ASSERT(key!=-1);
122 Q_ASSERT(key!=-1);
127
123
128 m_indexSeriesMap.remove(key);
124 m_indexSeriesMap.remove(key);
129
125 series->setParent(0);
130 if(series->parent()==this){
131 delete series;
132 series=0;
133 }
134
126
135 QList<QChartAxis*> axes = m_seriesAxisMap.values();
127 QList<QChartAxis*> axes = m_seriesAxisMap.values();
136
128
@@ -140,10 +132,7 void ChartDataSet::removeSeries(QSeries* series)
140 Domain* domain = m_axisDomainMap.take(axis);
132 Domain* domain = m_axisDomainMap.take(axis);
141 emit axisRemoved(axis);
133 emit axisRemoved(axis);
142 if(axis!=axisY()){
134 if(axis!=axisY()){
143 if(axis->parent()==this){
135 axis->setParent(0);
144 delete axis;
145 axis=0;
146 }
147 }
136 }
148 delete domain;
137 delete domain;
149 }
138 }
@@ -153,20 +142,28 void ChartDataSet::removeSeries(QSeries* series)
153 m_axisXInitialized=false;
142 m_axisXInitialized=false;
154 emit axisRemoved(axisX());
143 emit axisRemoved(axisX());
155 }
144 }
145
146 return axis;
156 }
147 }
157
148
158 void ChartDataSet::removeAllSeries()
149 void ChartDataSet::removeAllSeries()
159 {
150 {
160
161 QList<QSeries*> series = m_seriesAxisMap.keys();
151 QList<QSeries*> series = m_seriesAxisMap.keys();
162
152 QList<QChartAxis*> axes;
163 foreach(QSeries* s , series) {
153 foreach(QSeries* s , series) {
164 removeSeries(s);
154 QChartAxis* axis = removeSeries(s);
155 if(axis==axisY()) continue;
156 int i = axes.indexOf(axis);
157 if(i==-1){
158 axes<<axis;
159 }
165 }
160 }
166
161
167 Q_ASSERT(m_seriesAxisMap.count()==0);
162 Q_ASSERT(m_seriesAxisMap.count()==0);
168 Q_ASSERT(m_axisDomainMap.count()==0);
163 Q_ASSERT(m_axisDomainMap.count()==0);
169
164
165 qDeleteAll(series);
166 qDeleteAll(axes);
170 }
167 }
171
168
172 void ChartDataSet::setupCategories(QBarSeries* series)
169 void ChartDataSet::setupCategories(QBarSeries* series)
@@ -47,7 +47,7 public:
47 virtual ~ChartDataSet();
47 virtual ~ChartDataSet();
48
48
49 void addSeries(QSeries* series,QChartAxis *axisY = 0);
49 void addSeries(QSeries* series,QChartAxis *axisY = 0);
50 void removeSeries(QSeries* series);
50 QChartAxis* removeSeries(QSeries* series);
51 void removeAllSeries();
51 void removeAllSeries();
52
52
53 void zoomInDomain(const QRectF& rect, const QSizeF& size);
53 void zoomInDomain(const QRectF& rect, const QSizeF& size);
@@ -313,7 +313,7 void ChartTheme::decorate(QChartAxis *axis,bool axisX)
313 void ChartTheme::generateSeriesGradients()
313 void ChartTheme::generateSeriesGradients()
314 {
314 {
315 // Generate gradients in HSV color space
315 // Generate gradients in HSV color space
316 foreach (QColor color, m_seriesColors) {
316 foreach (const QColor& color, m_seriesColors) {
317 QLinearGradient g;
317 QLinearGradient g;
318 qreal h = color.hsvHueF();
318 qreal h = color.hsvHueF();
319 qreal s = color.hsvSaturationF();
319 qreal s = color.hsvSaturationF();
@@ -315,7 +315,7 void QLegendPrivate::setOffset(qreal x, qreal y)
315 if(m_width<=m_rect.width()) return;
315 if(m_width<=m_rect.width()) return;
316
316
317 if (x != m_offsetX) {
317 if (x != m_offsetX) {
318 m_offsetX = qBound(0.0, x, m_width - m_rect.width());
318 m_offsetX = qBound(qreal(0), x, m_width - m_rect.width());
319 m_markers->setPos(-m_offsetX,m_rect.top());
319 m_markers->setPos(-m_offsetX,m_rect.top());
320 }
320 }
321 break;
321 break;
@@ -326,7 +326,7 void QLegendPrivate::setOffset(qreal x, qreal y)
326 if(m_height<=m_rect.height()) return;
326 if(m_height<=m_rect.height()) return;
327
327
328 if (y != m_offsetY) {
328 if (y != m_offsetY) {
329 m_offsetY = qBound(0.0, y, m_height - m_rect.height());
329 m_offsetY = qBound(qreal(0), y, m_height - m_rect.height());
330 m_markers->setPos(m_rect.left(),-m_offsetY);
330 m_markers->setPos(m_rect.left(),-m_offsetY);
331 }
331 }
332 break;
332 break;
@@ -56,7 +56,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
56
56
57 /*!
57 /*!
58 Constructs empty series object which is a child of \a parent.
58 Constructs empty series object which is a child of \a parent.
59 When series object is added to QChartView or QChart instance ownerships is transfered.
59 When series object is added to QChartView or QChart instance ownerships is transferred.
60 */
60 */
61 QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent)
61 QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent)
62 {
62 {
@@ -32,7 +32,7 class QLineSeriesPrivate;
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
33 {
33 {
34 public:
34 public:
35 explicit QLineSeries(QObject *parent=0);
35 explicit QLineSeries(QObject *parent = 0);
36 ~QLineSeries();
36 ~QLineSeries();
37
37
38 QSeries::QSeriesType type() const;
38 QSeries::QSeriesType type() const;
@@ -82,7 +82,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
82 The value is a relative value to the chart rectangle where:
82 The value is a relative value to the chart rectangle where:
83
83
84 \list
84 \list
85 \o 0.0 is the minumum size (pie not drawn).
85 \o 0.0 is the minimum size (pie not drawn).
86 \o 1.0 is the maximum size that can fit the chart.
86 \o 1.0 is the maximum size that can fit the chart.
87 \endlist
87 \endlist
88
88
@@ -484,7 +484,7 bool QPieSeries::setModel(QAbstractItemModel* model)
484 Sets column/row specified by \a modelValuesLine to be used as a list of pie slice values for the pie.
484 Sets column/row specified by \a modelValuesLine to be used as a list of pie slice values for the pie.
485 Parameter \a modelValuesLine indicates the column/row where the values for the pie slices are located in the model.
485 Parameter \a modelValuesLine indicates the column/row where the values for the pie slices are located in the model.
486 Parameter \a modelLabelsLine indicates the column/row where the labels for the pie slices are located in the model.
486 Parameter \a modelLabelsLine indicates the column/row where the labels for the pie slices are located in the model.
487 The \a orientation paramater specifies whether the data is in columns or in rows.
487 The \a orientation parameter specifies whether the data is in columns or in rows.
488 */
488 */
489 void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation)
489 void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation)
490 {
490 {
@@ -126,6 +126,7 QSeriesPrivate::~QSeriesPrivate()
126 }
126 }
127
127
128 #include "moc_qseries.cpp"
128 #include "moc_qseries.cpp"
129 #include "moc_qseries_p.cpp"
129
130
130 QTCOMMERCIALCHART_END_NAMESPACE
131 QTCOMMERCIALCHART_END_NAMESPACE
131
132
@@ -44,6 +44,7 class QLegend;
44
44
45 class QSeriesPrivate : public QObject
45 class QSeriesPrivate : public QObject
46 {
46 {
47 Q_OBJECT
47 public:
48 public:
48 QSeriesPrivate(QSeries *q);
49 QSeriesPrivate(QSeries *q);
49 ~QSeriesPrivate();
50 ~QSeriesPrivate();
@@ -245,4 +245,6 void ScrollTicker::timerEvent(QTimerEvent *event)
245 m_scroller->scrollTick();
245 m_scroller->scrollTick();
246 }
246 }
247
247
248 #include "moc_scroller_p.cpp"
249
248 QTCOMMERCIALCHART_END_NAMESPACE
250 QTCOMMERCIALCHART_END_NAMESPACE
@@ -44,6 +44,7 class QLegend;
44
44
45 class ScrollTicker : public QObject
45 class ScrollTicker : public QObject
46 {
46 {
47 Q_OBJECT
47 public:
48 public:
48 explicit ScrollTicker(Scroller *scroller,QObject *parent = 0);
49 explicit ScrollTicker(Scroller *scroller,QObject *parent = 0);
49 void start(int interval);
50 void start(int interval);
@@ -47,7 +47,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
47
47
48 /*!
48 /*!
49 Constructs empty series object which is a child of \a parent.
49 Constructs empty series object which is a child of \a parent.
50 When series object is added to QChartView or QChart instance then the ownerships is transfered.
50 When series object is added to QChartView or QChart instance then the ownerships is transferred.
51 */
51 */
52
52
53 QSplineSeries::QSplineSeries(QObject *parent) :
53 QSplineSeries::QSplineSeries(QObject *parent) :
@@ -201,7 +201,7 void QSplineSeriesPrivate::updateControlPoints()
201 /*//!
201 /*//!
202 \fn bool QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
202 \fn bool QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
203 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
203 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
204 as a data source for y coordinate. The \a orientation paramater specifies whether the data
204 as a data source for y coordinate. The \a orientation parameter specifies whether the data
205 is in columns or in rows.
205 is in columns or in rows.
206 */
206 */
207 //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
207 //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
@@ -92,7 +92,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
92 \internal
92 \internal
93
93
94 Constructs empty series object which is a child of \a parent.
94 Constructs empty series object which is a child of \a parent.
95 When series object is added to QChartView or QChart instance ownerships is transfered.
95 When series object is added to QChartView or QChart instance ownerships is transferred.
96 */
96 */
97 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent):QSeries(d,parent)
97 QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent):QSeries(d,parent)
98 {
98 {
@@ -560,7 +560,7 bool QXYSeries::setModel(QAbstractItemModel *model)
560 /*!
560 /*!
561 \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
561 \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation)
562 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
562 Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used
563 as a data source for y coordinate. The \a orientation paramater specifies whether the data
563 as a data source for y coordinate. The \a orientation parameter specifies whether the data
564 is in columns or in rows.
564 is in columns or in rows.
565 \sa setModel(), setModelMappingRange()
565 \sa setModel(), setModelMappingRange()
566 */
566 */
@@ -150,6 +150,13 void tst_ChartDataSet::addSeries()
150 QCOMPARE(spy2.count(), 3);
150 QCOMPARE(spy2.count(), 3);
151 QCOMPARE(spy3.count(), 0);
151 QCOMPARE(spy3.count(), 0);
152
152
153 if(axis0==0) axis0 = dataSet.axisY();
154 if(axis1==0) axis1 = dataSet.axisY();
155 if(axis2==0) axis2 = dataSet.axisY();
156
157 QVERIFY(axis0 == dataSet.removeSeries(series0));
158 QVERIFY(axis1 == dataSet.removeSeries(series1));
159 QVERIFY(axis2 == dataSet.removeSeries(series2));
153 }
160 }
154
161
155 void tst_ChartDataSet::removeSeries_data()
162 void tst_ChartDataSet::removeSeries_data()
@@ -190,36 +197,37 void tst_ChartDataSet::removeSeries()
190
197
191 void tst_ChartDataSet::removeAllSeries_data()
198 void tst_ChartDataSet::removeAllSeries_data()
192 {
199 {
193 addSeries_data();
200
194 }
201 }
195
202
196 void tst_ChartDataSet::removeAllSeries()
203 void tst_ChartDataSet::removeAllSeries()
197 {
204 {
198 QFETCH(QLineSeries*, series0);
205 QLineSeries* series0 = new QLineSeries(this);
199 QFETCH(QChartAxis*, axis0);
206 QLineSeries* series1 = new QLineSeries(this);
200 QFETCH(QLineSeries*, series1);
207 QLineSeries* series2 = new QLineSeries(this);
201 QFETCH(QChartAxis*, axis1);
208
202 QFETCH(QLineSeries*, series2);
209 QChartAxis* axis0 = new QChartAxis(this);
203 QFETCH(QChartAxis*, axis2);
210 QChartAxis* axis1 = new QChartAxis(this);
204 QFETCH(int, axisCount);
211 QChartAxis* axis2 = new QChartAxis(this);
205
212
206 ChartDataSet dataSet;
213
207
214 ChartDataSet dataSet;
208 dataSet.addSeries(series0,axis0);
215
209 dataSet.addSeries(series1,axis1);
216 dataSet.addSeries(series0, axis0);
210 dataSet.addSeries(series2,axis2);
217 dataSet.addSeries(series1, axis1);
211
218 dataSet.addSeries(series2, axis2);
212 QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*)));
219
213 QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*)));
220 QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*)));
214 QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*)));
221 QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*)));
215 QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*)));
222 QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*)));
216
223 QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*)));
217 dataSet.removeAllSeries();
224
218
225 dataSet.removeAllSeries();
219 QCOMPARE(spy0.count(), 0);
226
220 QCOMPARE(spy1.count(), axisCount);
227 QCOMPARE(spy0.count(), 0);
221 QCOMPARE(spy2.count(), 0);
228 QCOMPARE(spy1.count(), 4);
222 QCOMPARE(spy3.count(), 3);
229 QCOMPARE(spy2.count(), 0);
230 QCOMPARE(spy3.count(), 3);
223 }
231 }
224
232
225
233
@@ -295,6 +303,10 void tst_ChartDataSet::seriesCount()
295 QCOMPARE(spy1.count(), 0);
303 QCOMPARE(spy1.count(), 0);
296 QCOMPARE(spy2.count(), 0);
304 QCOMPARE(spy2.count(), 0);
297 QCOMPARE(spy3.count(), 0);
305 QCOMPARE(spy3.count(), 0);
306
307 dataSet.removeSeries(series0);
308 dataSet.removeSeries(series1);
309 dataSet.removeSeries(series2);
298 }
310 }
299
311
300 void tst_ChartDataSet::seriesIndex_data()
312 void tst_ChartDataSet::seriesIndex_data()
@@ -382,6 +394,10 void tst_ChartDataSet::seriesIndex()
382 QCOMPARE(dataSet.seriesIndex(series1),1);
394 QCOMPARE(dataSet.seriesIndex(series1),1);
383 QCOMPARE(dataSet.seriesIndex(series2),0);
395 QCOMPARE(dataSet.seriesIndex(series2),0);
384
396
397 dataSet.removeSeries(series0);
398 dataSet.removeSeries(series1);
399 dataSet.removeSeries(series2);
400
385 }
401 }
386
402
387 void tst_ChartDataSet::domain_data()
403 void tst_ChartDataSet::domain_data()
@@ -418,6 +434,10 void tst_ChartDataSet::domain()
418 QCOMPARE(spy1.count(), 0);
434 QCOMPARE(spy1.count(), 0);
419 QCOMPARE(spy2.count(), 0);
435 QCOMPARE(spy2.count(), 0);
420 QCOMPARE(spy3.count(), 0);
436 QCOMPARE(spy3.count(), 0);
437
438 dataSet.removeSeries(series0);
439 dataSet.removeSeries(series1);
440 dataSet.removeSeries(series2);
421 }
441 }
422
442
423 void tst_ChartDataSet::zoomInDomain_data()
443 void tst_ChartDataSet::zoomInDomain_data()
@@ -455,6 +475,10 void tst_ChartDataSet::zoomInDomain()
455 QCOMPARE(spy0.count(), 1);
475 QCOMPARE(spy0.count(), 1);
456 QCOMPARE(spy1.count(), 1);
476 QCOMPARE(spy1.count(), 1);
457 QCOMPARE(spy2.count(), 1);
477 QCOMPARE(spy2.count(), 1);
478
479 dataSet.removeSeries(series0);
480 dataSet.removeSeries(series1);
481 dataSet.removeSeries(series2);
458 }
482 }
459
483
460 void tst_ChartDataSet::zoomOutDomain_data()
484 void tst_ChartDataSet::zoomOutDomain_data()
@@ -493,6 +517,10 void tst_ChartDataSet::zoomOutDomain()
493 QCOMPARE(spy0.count(), 1);
517 QCOMPARE(spy0.count(), 1);
494 QCOMPARE(spy1.count(), 1);
518 QCOMPARE(spy1.count(), 1);
495 QCOMPARE(spy2.count(), 1);
519 QCOMPARE(spy2.count(), 1);
520
521 dataSet.removeSeries(series0);
522 dataSet.removeSeries(series1);
523 dataSet.removeSeries(series2);
496 }
524 }
497
525
498 void tst_ChartDataSet::scrollDomain_data()
526 void tst_ChartDataSet::scrollDomain_data()
@@ -531,6 +559,10 void tst_ChartDataSet::scrollDomain()
531 QCOMPARE(spy0.count(), 1);
559 QCOMPARE(spy0.count(), 1);
532 QCOMPARE(spy1.count(), 1);
560 QCOMPARE(spy1.count(), 1);
533 QCOMPARE(spy2.count(), 1);
561 QCOMPARE(spy2.count(), 1);
562
563 dataSet.removeSeries(series0);
564 dataSet.removeSeries(series1);
565 dataSet.removeSeries(series2);
534 }
566 }
535
567
536 QTEST_MAIN(tst_ChartDataSet)
568 QTEST_MAIN(tst_ChartDataSet)
@@ -198,6 +198,8 void tst_QChart::addSeries()
198 if(!axis) axis = m_chart->axisY();
198 if(!axis) axis = m_chart->axisY();
199 m_chart->addSeries(series,axis);
199 m_chart->addSeries(series,axis);
200 QCOMPARE(m_chart->axisY(series),axis);
200 QCOMPARE(m_chart->axisY(series),axis);
201 m_chart->removeSeries(series);
202
201 }
203 }
202
204
203 void tst_QChart::animationOptions_data()
205 void tst_QChart::animationOptions_data()
General Comments 0
You need to be logged in to leave comments. Login now