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