##// END OF EJS Templates
Adds domains swap logic
Michal Klocek -
r2284:5ea9e4fa75c8
parent child
Show More
@@ -862,6 +862,7 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options
862 862 }
863 863
864 864
865
865 866 #include "moc_qabstractaxis.cpp"
866 867 #include "moc_qabstractaxis_p.cpp"
867 868
@@ -189,6 +189,7 protected:
189 189 friend class ChartAxis;
190 190 friend class ChartPresenter;
191 191 friend class ChartThemeManager;
192 friend class AbstractDomain;
192 193 };
193 194
194 195 QTCOMMERCIALCHART_END_NAMESPACE
@@ -52,8 +52,8 ChartDataSet::ChartDataSet(QChart *chart)
52 52
53 53 ChartDataSet::~ChartDataSet()
54 54 {
55 removeAllSeries();
56 removeAllAxes();
55 deleteAllSeries();
56 deleteAllAxes();
57 57 }
58 58
59 59 /*
@@ -126,6 +126,7 void ChartDataSet::removeSeries(QAbstractSeries *series)
126 126 axis->d_ptr->m_series.removeAll(series);
127 127 series->d_ptr->m_axes.removeAll(axis);
128 128 }
129
129 130 }
130 131
131 132 /*
@@ -153,7 +154,7 void ChartDataSet::removeAxis(QAbstractAxis *axis)
153 154 }
154 155
155 156 /*
156 * This method attach axis to series, return true if success.
157 * This method attaches axis to series, return true if success.
157 158 */
158 159 bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis)
159 160 {
@@ -162,7 +163,6 bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis)
162 163
163 164 QList<QAbstractSeries* > attachedSeriesList = axis->d_ptr->m_series;
164 165 QList<QAbstractAxis* > attachedAxisList = series->d_ptr->m_axes;
165 QSharedPointer<AbstractDomain> domain = series->d_ptr->m_domain;
166 166
167 167 if (!m_seriesList.contains(series)) {
168 168 qWarning() << QObject::tr("Can not find series on the chart.");
@@ -179,38 +179,42 bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis)
179 179 return false;
180 180 }
181 181
182 Q_ASSERT(!attachedSeriesList.contains(series));
183 Q_ASSERT(!domain.isNull());
182 if (attachedSeriesList.contains(series)) {
183 qWarning() << QObject::tr("Axis already attached to series.");
184 return false;
185 }
184 186
185 if(attachedSeriesList.isEmpty()){
187 QSharedPointer<AbstractDomain> domain = series->d_ptr->domain();
188 AbstractDomain::DomainType type = selectDomain(attachedAxisList<<axis);
186 189
187 }else{
188 domain = attachedSeriesList.first()->d_ptr->domain();
189 Q_ASSERT(!domain.isNull());
190 series->d_ptr->setDomain(domain);
190 if(type == AbstractDomain::UndefinedDomain) return false;
191
192
193 if(domain->type()!=type){
194 domain = QSharedPointer<AbstractDomain>(createDomain(type));
191 195 }
192 196
197 if(domain.isNull()) return false;
198
199 if(!domain->attachAxis(axis)) return false;
200
193 201 series->d_ptr->m_axes<<axis;
194 202 axis->d_ptr->m_series<<series;
195 203
204 series->d_ptr->setDomain(domain);
205 series->d_ptr->initializeDomain();
196 206 series->d_ptr->initializeAxes();
197 207 axis->d_ptr->initializeDomain(domain.data());
198 208
199 if(axis->orientation()==Qt::Vertical){
200 QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleVerticalAxisRangeChanged(qreal,qreal)));
201 QObject::connect(domain.data(), SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
202 }
203
204 if(axis->orientation()==Qt::Horizontal){
205 QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleHorizontalAxisRangeChanged(qreal,qreal)));
206 QObject::connect(domain.data(), SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
209 if(attachedSeriesList.count()>0 && attachedAxisList.count()>0){
210 //TODO optimatization: joinDomain(attachedAxisList, attachedSeriesList);
207 211 }
208 212
209 213 return true;
210 214 }
211 215
212 216 /*
213 * This method detach axis to series, return true if success.
217 * This method detaches axis to series, return true if success.
214 218 */
215 219 bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis)
216 220 {
@@ -238,19 +242,10 bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis)
238 242
239 243 Q_ASSERT(axis->d_ptr->m_series.contains(series));
240 244
245 domain->detachAxis(axis);
241 246 series->d_ptr->m_axes.removeAll(axis);
242 247 axis->d_ptr->m_series.removeAll(series);
243 248
244 if(axis->orientation()==Qt::Vertical){
245 QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleVerticalAxisRangeChanged(qreal,qreal)));
246 QObject::disconnect(domain.data(), SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
247 }
248
249 if(axis->orientation()==Qt::Horizontal){
250 QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleHorizontalAxisRangeChanged(qreal,qreal)));
251 QObject::disconnect(domain.data(), SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
252 }
253
254 249 return true;
255 250 }
256 251
@@ -263,7 +258,7 void ChartDataSet::createDefaultAxes()
263 258 QAbstractAxis::AxisTypes typeY(0);
264 259
265 260 // Remove possibly existing axes
266 removeAllAxes();
261 deleteAllAxes();
267 262
268 263 Q_ASSERT(m_axisList.isEmpty());
269 264
@@ -326,22 +321,22 void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation ori
326 321 }
327 322 }
328 323
329 void ChartDataSet::removeAllSeries()
324 void ChartDataSet::deleteAllSeries()
330 325 {
331 foreach (QAbstractSeries *s , m_seriesList)
326 foreach (QAbstractSeries *s , m_seriesList){
332 327 removeSeries(s);
333
328 delete s;
329 }
334 330 Q_ASSERT(m_seriesList.count() == 0);
335 qDeleteAll(m_seriesList);
336 331 }
337 332
338 void ChartDataSet::removeAllAxes()
333 void ChartDataSet::deleteAllAxes()
339 334 {
340 foreach (QAbstractAxis *a , m_axisList)
335 foreach (QAbstractAxis *a , m_axisList){
341 336 removeAxis(a);
342
337 delete a;
338 }
343 339 Q_ASSERT(m_axisList.count() == 0);
344 qDeleteAll(m_axisList);
345 340 }
346 341
347 342 void ChartDataSet::zoomInDomain(const QRectF &rect)
@@ -405,6 +400,72 QList<QAbstractSeries *> ChartDataSet::series() const
405 400 return m_seriesList;
406 401 }
407 402
403 AbstractDomain::DomainType ChartDataSet::selectDomain(QList<QAbstractAxis*> axes)
404 {
405 enum Type {
406 LogType = 0x1,
407 ValueType = 0x2
408 };
409
410 int horizontal(ValueType);
411 int vertical(ValueType);
412
413 foreach(QAbstractAxis* axis, axes)
414 {
415 switch(axis->type()) {
416 case QAbstractAxis::AxisTypeLogValue:
417 axis->orientation()==Qt::Horizontal?horizontal:vertical|=LogType;
418 break;
419 case QAbstractAxis::AxisTypeValue:
420 case QAbstractAxis::AxisTypeBarCategory:
421 case QAbstractAxis::AxisTypeCategory:
422 case QAbstractAxis::AxisTypeDateTime:
423 axis->orientation()==Qt::Horizontal?horizontal:vertical|=ValueType;
424 break;
425 default:
426 qWarning()<<"Undefined type";
427 break;
428 }
429 }
430
431 if(vertical==ValueType && horizontal== ValueType) {
432 return AbstractDomain::XYDomain;
433 }
434
435 if(vertical==LogType && horizontal== ValueType) {
436 return AbstractDomain::XLogYDomain;
437 }
438
439 if(vertical==ValueType && horizontal== LogType) {
440 return AbstractDomain::LogXYDomain;
441 }
442
443 if(vertical==LogType && horizontal== LogType) {
444 return AbstractDomain::XLogYLogDomain;
445 }
446
447 return AbstractDomain::UndefinedDomain;
448 }
449
450
451 //refactor create factory
452 AbstractDomain* ChartDataSet::createDomain(AbstractDomain::DomainType type)
453 {
454 switch(type)
455 {
456 case AbstractDomain::XLogYLogDomain:
457 return 0;
458 case AbstractDomain::XYDomain:
459 return new XYDomain();
460 case AbstractDomain::XLogYDomain:
461 return 0;
462 case AbstractDomain::LogXYDomain:
463 return 0;
464 default:
465 return 0;
466 }
467 }
468
408 469 #include "moc_chartdataset_p.cpp"
409 470
410 471 QTCOMMERCIALCHART_END_NAMESPACE
@@ -50,12 +50,10 public:
50 50 void addSeries(QAbstractSeries *series);
51 51 void removeSeries(QAbstractSeries *series);
52 52 QList<QAbstractSeries *> series() const;
53 void removeAllSeries();
54 53
55 54 void addAxis(QAbstractAxis *axis,Qt::Alignment aligment);
56 55 void removeAxis(QAbstractAxis *axis);
57 56 QList<QAbstractAxis*> axes() const;
58 void removeAllAxes();
59 57
60 58 bool attachAxis(QAbstractSeries* series,QAbstractAxis *axis);
61 59 bool detachAxis(QAbstractSeries* series,QAbstractAxis *axis);
@@ -75,7 +73,10 Q_SIGNALS:
75 73 private:
76 74 void createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation);
77 75 QAbstractAxis *createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation);
78
76 AbstractDomain::DomainType selectDomain(QList<QAbstractAxis* > axes);
77 AbstractDomain* createDomain(AbstractDomain::DomainType type);
78 void deleteAllAxes();
79 void deleteAllSeries();
79 80 private:
80 81 QList<QAbstractSeries *> m_seriesList;
81 82 QList<QAbstractAxis *> m_axisList;
@@ -161,6 +161,35 qreal AbstractDomain::niceNumber(qreal x, bool ceiling)
161 161 return q * z;
162 162 }
163 163
164 bool AbstractDomain::attachAxis(QAbstractAxis* axis)
165 {
166 if(axis->orientation()==Qt::Vertical) {
167 QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleVerticalAxisRangeChanged(qreal,qreal)));
168 QObject::connect(this, SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
169 }
170
171 if(axis->orientation()==Qt::Horizontal) {
172 QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleHorizontalAxisRangeChanged(qreal,qreal)));
173 QObject::connect(this, SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
174 }
175
176 return true;
177 }
178
179 bool AbstractDomain::detachAxis(QAbstractAxis* axis)
180 {
181 if(axis->orientation()==Qt::Vertical) {
182 QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleVerticalAxisRangeChanged(qreal,qreal)));
183 QObject::disconnect(this, SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
184 }
185
186 if(axis->orientation()==Qt::Horizontal) {
187 QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleHorizontalAxisRangeChanged(qreal,qreal)));
188 QObject::disconnect(this, SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal)));
189 }
190
191 return true;
192 }
164 193
165 194 // operators
166 195
@@ -36,16 +36,22
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 class QAbstractAxis;
40
39 41 class QTCOMMERCIALCHART_AUTOTEST_EXPORT AbstractDomain: public QObject
40 42 {
41 43 Q_OBJECT
42 44 public:
45 enum DomainType { UndefinedDomain, XYDomain, XLogYDomain, LogXYDomain, XLogYLogDomain };
46 public:
43 47 explicit AbstractDomain(QObject *object = 0);
44 48 virtual ~AbstractDomain();
45 49
46 50 void setSize(const QSizeF& size);
47 51 QSizeF size() const;
48 52
53 virtual DomainType type() = 0;
54
49 55 virtual void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) = 0;
50 56 void setRangeX(qreal min, qreal max);
51 57 void setRangeY(qreal min, qreal max);
@@ -63,11 +69,9 public:
63 69 qreal spanY() const;
64 70 bool isEmpty() const;
65 71
66
67 72 void blockAxisSignals(bool block);
68 73 bool axisSignalsBlocked() const { return m_axisSignalsBlocked; }
69 74
70
71 75 friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const AbstractDomain &domain1, const AbstractDomain &domain2);
72 76 friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2);
73 77 friend QDebug QTCOMMERCIALCHART_AUTOTEST_EXPORT operator<<(QDebug dbg, const AbstractDomain &domain);
@@ -80,6 +84,9 public:
80 84 virtual QPointF calculateDomainPoint(const QPointF &point) const = 0;
81 85 virtual QVector<QPointF> calculateGeometryPoints(const QList<QPointF>& vector) const = 0;
82 86
87 virtual bool attachAxis(QAbstractAxis* axis);
88 virtual bool detachAxis(QAbstractAxis* axis);
89
83 90 static void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount);
84 91 static qreal niceNumber(qreal x, bool ceiling);
85 92
@@ -42,6 +42,8 public:
42 42 explicit XYDomain(QObject *object = 0);
43 43 virtual ~XYDomain();
44 44
45 DomainType type(){ return AbstractDomain::XYDomain;}
46
45 47 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY);
46 48
47 49 friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const XYDomain &Domain1, const XYDomain &Domain2);
@@ -38,7 +38,6 class QChart;
38 38 class ChartPresenter;
39 39 class QAbstractSeries;
40 40 class LegendLayout;
41 class Domain;
42 41 class QLegendMarker;
43 42
44 43 class QLegendPrivate : public QObject
@@ -160,7 +160,10 void QChart::removeSeries(QAbstractSeries *series)
160 160 */
161 161 void QChart::removeAllSeries()
162 162 {
163 d_ptr->m_dataset->removeAllSeries();
163 foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){
164 removeSeries(s);
165 delete s;
166 }
164 167 }
165 168
166 169 /*!
@@ -71,6 +71,8 Q_DECLARE_METATYPE(QLineSeries *)
71 71 class tst_ChartDataSet: public QObject {
72 72
73 73 Q_OBJECT
74 public:
75 tst_ChartDataSet():m_dataset(0){};
74 76
75 77 public Q_SLOTS:
76 78 void initTestCase();
@@ -85,14 +87,10 private Q_SLOTS:
85 87 void addSeries();
86 88 void removeSeries_data();
87 89 void removeSeries();
88 void removeAllSeries_data();
89 void removeAllSeries();
90 90 void addAxis_data();
91 91 void addAxis();
92 92 void removeAxis_data();
93 93 void removeAxis();
94 void removeAllAxes_data();
95 void removeAllAxes();
96 94 void attachAxis_data();
97 95 void attachAxis();
98 96 void detachAxis_data();
@@ -115,17 +113,15 void tst_ChartDataSet::cleanupTestCase()
115 113
116 114 void tst_ChartDataSet::init()
117 115 {
116 Q_ASSERT(!m_dataset);
118 117 m_dataset = new ChartDataSet(0);
119 118 }
120 119
121 120
122 121 void tst_ChartDataSet::cleanup()
123 122 {
124 QList<QAbstractSeries*> series = m_dataset->series();
125 foreach (QAbstractSeries* serie, series)
126 {
127 m_dataset->removeSeries(serie);
128 }
123 delete m_dataset;
124 m_dataset=0;
129 125 }
130 126
131 127 void tst_ChartDataSet::chartdataset_data()
@@ -145,21 +141,27 void tst_ChartDataSet::addSeries_data()
145 141 QTest::addColumn<QAbstractSeries*>("series");
146 142
147 143 QAbstractSeries* line = new QLineSeries(this);
148 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
149 QAbstractSeries* scatter = new QScatterSeries(this);
150 QAbstractSeries* spline = new QSplineSeries(this);
151 QAbstractSeries* pie = new QPieSeries(this);
152 QAbstractSeries* bar = new QBarSeries(this);
153 QAbstractSeries* percent = new QPercentBarSeries(this);
154 QAbstractSeries* stacked = new QStackedBarSeries(this);
155
156 144 QTest::newRow("line") << line;
145
146 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(new QLineSeries(this)));
157 147 QTest::newRow("area") << area;
148
149 QAbstractSeries* scatter = new QScatterSeries(this);
158 150 QTest::newRow("scatter") << scatter;
151
152 QAbstractSeries* spline = new QSplineSeries(this);
159 153 QTest::newRow("spline") << spline;
154
155 QAbstractSeries* pie = new QPieSeries(this);
160 156 QTest::newRow("pie") << pie;
157
158 QAbstractSeries* bar = new QBarSeries(this);
161 159 QTest::newRow("bar") << bar;
160
161 QAbstractSeries* percent = new QPercentBarSeries(this);
162 162 QTest::newRow("percent") << percent;
163
164 QAbstractSeries* stacked = new QStackedBarSeries(this);
163 165 QTest::newRow("stacked") << stacked;
164 166 }
165 167
@@ -175,7 +177,6 void tst_ChartDataSet::addSeries()
175 177
176 178 m_dataset->addSeries(series);
177 179
178
179 180 QCOMPARE(m_dataset->series().count(),1);
180 181 TRY_COMPARE(spy0.count(), 0);
181 182 TRY_COMPARE(spy1.count(), 0);
@@ -208,56 +209,6 void tst_ChartDataSet::removeSeries()
208 209 TRY_COMPARE(spy3.count(), 1);
209 210 }
210 211
211 void tst_ChartDataSet::removeAllSeries_data()
212 {
213 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
214 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
215
216 QList<QAbstractSeries*> series;
217 QList<QAbstractAxis*> axis;
218
219 series << new QLineSeries(this) << new QSplineSeries(this) << new QScatterSeries(this);
220 axis << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this);
221
222 QTest::newRow("3 series , 3 axis") << series << axis;
223 }
224
225 void tst_ChartDataSet::removeAllSeries()
226 {
227 QFETCH(QList<QAbstractSeries*>, seriesList);
228 QFETCH(QList<QAbstractAxis*>, axisList);
229
230 QCOMPARE(m_dataset->series().count(),0);
231 QCOMPARE(m_dataset->axes().count(),0);
232
233 foreach (QAbstractSeries* series, seriesList) {
234 m_dataset->addSeries(series);
235 }
236
237 foreach (QAbstractAxis* axis, axisList) {
238 m_dataset->addAxis(axis,Qt::AlignBottom);
239 }
240
241 for (int i = 0; i < seriesList.count(); i++) {
242 m_dataset->attachAxis(seriesList.at(i),axisList.at(i));
243 }
244
245 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)));
246 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
247 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)));
248 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)));
249
250 m_dataset->removeAllSeries();
251
252 TRY_COMPARE(spy0.count(), 0);
253 TRY_COMPARE(spy1.count(), 0);
254 TRY_COMPARE(spy2.count(), 0);
255 TRY_COMPARE(spy3.count(), seriesList.count());
256
257 QCOMPARE(m_dataset->series().count(),0);
258 QCOMPARE(m_dataset->axes().count(),axisList.count());
259 }
260
261 212 void tst_ChartDataSet::addAxis_data()
262 213 {
263 214 QTest::addColumn<QAbstractAxis*>("axis");
@@ -316,58 +267,9 void tst_ChartDataSet::removeAxis()
316 267 TRY_COMPARE(spy3.count(), 0);
317 268 }
318 269
319 void tst_ChartDataSet::removeAllAxes_data()
320 {
321 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
322 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
323
324 QList<QAbstractSeries*> series;
325 QList<QAbstractAxis*> axis;
326
327 series << new QLineSeries(this) << new QSplineSeries(this) << new QScatterSeries(this);
328 axis << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this);
329
330 QTest::newRow("3 series , 3 axis") << series << axis;
331 }
332
333 void tst_ChartDataSet::removeAllAxes()
334 {
335 QFETCH(QList<QAbstractSeries*>, seriesList);
336 QFETCH(QList<QAbstractAxis*>, axisList);
337
338 QCOMPARE(m_dataset->series().count(),0);
339 QCOMPARE(m_dataset->axes().count(),0);
340
341 foreach (QAbstractSeries* series, seriesList) {
342 m_dataset->addSeries(series);
343 }
344
345 foreach (QAbstractAxis* axis, axisList) {
346 m_dataset->addAxis(axis,Qt::AlignBottom);
347 }
348
349 for (int i = 0; i < seriesList.count(); i++) {
350 m_dataset->attachAxis(seriesList.at(i),axisList.at(i));
351 }
352
353 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)));
354 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
355 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)));
356 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)));
357
358 m_dataset->removeAllAxes();
359
360 TRY_COMPARE(spy0.count(), 0);
361 TRY_COMPARE(spy1.count(), axisList.count());
362 TRY_COMPARE(spy2.count(), 0);
363 TRY_COMPARE(spy3.count(), 0);
364
365 QCOMPARE(m_dataset->series().count(),seriesList.count());
366 QCOMPARE(m_dataset->axes().count(),0);
367 }
368
369 270 void tst_ChartDataSet::attachAxis_data()
370 271 {
272
371 273 QTest::addColumn<QList<QAbstractSeries*> >("series");
372 274 QTest::addColumn<QList<QAbstractAxis*> >("axis");
373 275 QTest::addColumn<QList<Qt::Alignment> >("alignment");
@@ -375,12 +277,7 void tst_ChartDataSet::attachAxis_data()
375 277 QTest::addColumn<QAbstractAxis*>("attachAxis");
376 278 QTest::addColumn<bool>("success");
377 279
378 QList<QAbstractSeries*> series;
379 QList<QAbstractAxis*> axes;
380 QList<Qt::Alignment> alignment;
381
382 QAbstractSeries* line = new QLineSeries(this);
383 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
280 //QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
384 281 QAbstractSeries* scatter = new QScatterSeries(this);
385 282 QAbstractSeries* spline = new QSplineSeries(this);
386 283 QAbstractSeries* pie = new QPieSeries(this);
@@ -388,17 +285,35 void tst_ChartDataSet::attachAxis_data()
388 285 QAbstractSeries* percent = new QPercentBarSeries(this);
389 286 QAbstractSeries* stacked = new QStackedBarSeries(this);
390 287
391 QAbstractAxis* value1 = new QValueAxis(this);
392 QAbstractAxis* value2 = new QValueAxis(this);
393 288 QAbstractAxis* category = new QCategoryAxis(this);
394 289 QAbstractAxis* barcategory = new QBarCategoryAxis(this);
395 290 QAbstractAxis* datetime = new QDateTimeAxis(this);
396 291
397
292 {
293 QList<QAbstractSeries*> series;
294 QList<QAbstractAxis*> axes;
295 QList<Qt::Alignment> alignment;
296 QAbstractSeries* line = new QLineSeries(this);
297 QAbstractAxis* value1 = new QValueAxis(this);
298 QAbstractAxis* value2 = new QValueAxis(this);
398 299 series << line << 0;
399 300 axes << value1 << value2;
400 301 alignment << Qt::AlignBottom << Qt::AlignLeft;
401 QTest::newRow("line + two axes") << series << axes << alignment << line << value2 << true;
302 QTest::newRow("first") << series << axes << alignment << line << value2 << true ;
303 }
304
305 {
306 QList<QAbstractSeries*> series;
307 QList<QAbstractAxis*> axes;
308 QList<Qt::Alignment> alignment;
309 QAbstractSeries* line = new QLineSeries(this);
310 QAbstractAxis* value1 = new QValueAxis(this);
311 QAbstractAxis* value2 = new QValueAxis(this);
312 series << 0 << line;
313 axes << value1 << value2;
314 alignment << Qt::AlignBottom << Qt::AlignLeft;
315 QTest::newRow("second") << series << axes << alignment << line << value1 << true;
316 }
402 317
403 318 }
404 319
@@ -440,15 +355,15 void tst_ChartDataSet::detachAxis_data()
440 355 QTest::addColumn<QAbstractAxis*>("detachAxis");
441 356 QTest::addColumn<bool>("success");
442 357
358 {
443 359 QList<QAbstractSeries*> series;
444 360 QList<QAbstractAxis*> axes;
445
446 361 QAbstractSeries* line = new QLineSeries(this);
447 362 QAbstractAxis* value = new QValueAxis(this);
448
449 363 series << line;
450 364 axes << value;
451 QTest::newRow("line + axis") << series << axes << line << value << true;
365 QTest::newRow("first") << series << axes << line << value << true;
366 }
452 367 }
453 368
454 369 void tst_ChartDataSet::detachAxis()
General Comments 0
You need to be logged in to leave comments. Login now