##// END OF EJS Templates
barsetCount -> count in tests and examples too
sauimone -
r1463:e1e0c05a814c
parent child
Show More
@@ -178,8 +178,8 void MainWidget::attachLegend()
178
178
179 void MainWidget::addBarset()
179 void MainWidget::addBarset()
180 {
180 {
181 QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->barsetCount()));
181 QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count()));
182 qreal delta = m_series->barsetCount() * 0.1;
182 qreal delta = m_series->count() * 0.1;
183 *barSet << QPointF(0.0 + delta, 1 + delta) << QPointF(1.0 + delta, 2 + delta) << QPointF(2.0 + delta, 3 + delta) << QPointF(3.0 + delta, 4 + delta);
183 *barSet << QPointF(0.0 + delta, 1 + delta) << QPointF(1.0 + delta, 2 + delta) << QPointF(2.0 + delta, 3 + delta) << QPointF(3.0 + delta, 4 + delta);
184 m_series->append(barSet);
184 m_series->append(barSet);
185 }
185 }
@@ -181,7 +181,7 void tst_qbarmodelmapper::verticalMapper()
181
181
182 m_chart->addSeries(m_series);
182 m_chart->addSeries(m_series);
183
183
184 QCOMPARE(m_series->barsetCount(), expectedBarSetCount);
184 QCOMPARE(m_series->count(), expectedBarSetCount);
185 QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn));
185 QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn));
186 QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn));
186 QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn));
187
187
@@ -216,7 +216,7 void tst_qbarmodelmapper::verticalMapperCustomMapping()
216
216
217 m_series = new QGroupedBarSeries;
217 m_series = new QGroupedBarSeries;
218
218
219 QCOMPARE(m_series->barsetCount(), 0);
219 QCOMPARE(m_series->count(), 0);
220
220
221 QVBarModelMapper *mapper = new QVBarModelMapper;
221 QVBarModelMapper *mapper = new QVBarModelMapper;
222 mapper->setFirstBarSetColumn(0);
222 mapper->setFirstBarSetColumn(0);
@@ -227,7 +227,7 void tst_qbarmodelmapper::verticalMapperCustomMapping()
227 mapper->setCount(countLimit);
227 mapper->setCount(countLimit);
228 m_chart->addSeries(m_series);
228 m_chart->addSeries(m_series);
229
229
230 QCOMPARE(m_series->barsetCount(), expectedBarSetCount);
230 QCOMPARE(m_series->count(), expectedBarSetCount);
231
231
232 if (expectedBarSetCount > 0)
232 if (expectedBarSetCount > 0)
233 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
233 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
@@ -236,7 +236,7 void tst_qbarmodelmapper::verticalMapperCustomMapping()
236 mapper->setFirstBarSetColumn(-1);
236 mapper->setFirstBarSetColumn(-1);
237 mapper->setLastBarSetColumn(1);
237 mapper->setLastBarSetColumn(1);
238
238
239 QCOMPARE(m_series->barsetCount(), 0);
239 QCOMPARE(m_series->count(), 0);
240
240
241 delete mapper;
241 delete mapper;
242 mapper = 0;
242 mapper = 0;
@@ -271,7 +271,7 void tst_qbarmodelmapper::horizontalMapper()
271
271
272 m_chart->addSeries(m_series);
272 m_chart->addSeries(m_series);
273
273
274 QCOMPARE(m_series->barsetCount(), expectedBarSetCount);
274 QCOMPARE(m_series->count(), expectedBarSetCount);
275 QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow));
275 QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow));
276 QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow));
276 QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow));
277
277
@@ -306,7 +306,7 void tst_qbarmodelmapper::horizontalMapperCustomMapping()
306
306
307 m_series = new QGroupedBarSeries;
307 m_series = new QGroupedBarSeries;
308
308
309 QCOMPARE(m_series->barsetCount(), 0);
309 QCOMPARE(m_series->count(), 0);
310
310
311 QHBarModelMapper *mapper = new QHBarModelMapper;
311 QHBarModelMapper *mapper = new QHBarModelMapper;
312 mapper->setFirstBarSetRow(0);
312 mapper->setFirstBarSetRow(0);
@@ -317,7 +317,7 void tst_qbarmodelmapper::horizontalMapperCustomMapping()
317 mapper->setCount(countLimit);
317 mapper->setCount(countLimit);
318 m_chart->addSeries(m_series);
318 m_chart->addSeries(m_series);
319
319
320 QCOMPARE(m_series->barsetCount(), expectedBarSetCount);
320 QCOMPARE(m_series->count(), expectedBarSetCount);
321
321
322 if (expectedBarSetCount > 0)
322 if (expectedBarSetCount > 0)
323 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
323 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
@@ -326,7 +326,7 void tst_qbarmodelmapper::horizontalMapperCustomMapping()
326 mapper->setFirstBarSetRow(-1);
326 mapper->setFirstBarSetRow(-1);
327 mapper->setLastBarSetRow(1);
327 mapper->setLastBarSetRow(1);
328
328
329 QCOMPARE(m_series->barsetCount(), 0);
329 QCOMPARE(m_series->count(), 0);
330
330
331 delete mapper;
331 delete mapper;
332 mapper = 0;
332 mapper = 0;
@@ -379,39 +379,39 void tst_qbarmodelmapper::verticalModelInsertRows()
379 {
379 {
380 // setup the mapper
380 // setup the mapper
381 createVerticalMapper();
381 createVerticalMapper();
382 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
382 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
383 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
383 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
384 QVERIFY(m_vMapper->model() != 0);
384 QVERIFY(m_vMapper->model() != 0);
385
385
386 int insertCount = 4;
386 int insertCount = 4;
387 m_model->insertRows(3, insertCount);
387 m_model->insertRows(3, insertCount);
388 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
388 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
389 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount);
389 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount);
390
390
391 int first = 3;
391 int first = 3;
392 m_vMapper->setFirst(3);
392 m_vMapper->setFirst(3);
393 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
393 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
394 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount - first);
394 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount - first);
395
395
396 m_model->insertRows(3, insertCount);
396 m_model->insertRows(3, insertCount);
397 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
397 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
398 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 2 * insertCount - first);
398 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 2 * insertCount - first);
399
399
400 int countLimit = 6;
400 int countLimit = 6;
401 m_vMapper->setCount(countLimit);
401 m_vMapper->setCount(countLimit);
402 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
402 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
403 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
403 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
404
404
405 m_model->insertRows(3, insertCount);
405 m_model->insertRows(3, insertCount);
406 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
406 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
407 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
407 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
408
408
409 m_vMapper->setFirst(0);
409 m_vMapper->setFirst(0);
410 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
410 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
411 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
411 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
412
412
413 m_vMapper->setCount(-1);
413 m_vMapper->setCount(-1);
414 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
414 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
415 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 3 * insertCount);
415 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 3 * insertCount);
416 }
416 }
417
417
@@ -419,39 +419,39 void tst_qbarmodelmapper::verticalModelRemoveRows()
419 {
419 {
420 // setup the mapper
420 // setup the mapper
421 createVerticalMapper();
421 createVerticalMapper();
422 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
422 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
423 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
423 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
424 QVERIFY(m_vMapper->model() != 0);
424 QVERIFY(m_vMapper->model() != 0);
425
425
426 int removeCount = 2;
426 int removeCount = 2;
427 m_model->removeRows(1, removeCount);
427 m_model->removeRows(1, removeCount);
428 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
428 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
429 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount);
429 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount);
430
430
431 int first = 1;
431 int first = 1;
432 m_vMapper->setFirst(first);
432 m_vMapper->setFirst(first);
433 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
433 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
434 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount - first);
434 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount - first);
435
435
436 m_model->removeRows(1, removeCount);
436 m_model->removeRows(1, removeCount);
437 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
437 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
438 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 2 * removeCount - first);
438 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 2 * removeCount - first);
439
439
440 int countLimit = 3;
440 int countLimit = 3;
441 m_vMapper->setCount(countLimit);
441 m_vMapper->setCount(countLimit);
442 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
442 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
443 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
443 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
444
444
445 m_model->removeRows(1, removeCount);
445 m_model->removeRows(1, removeCount);
446 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
446 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
447 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
447 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
448
448
449 m_vMapper->setFirst(0);
449 m_vMapper->setFirst(0);
450 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
450 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
451 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
451 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
452
452
453 m_vMapper->setCount(-1);
453 m_vMapper->setCount(-1);
454 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
454 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
455 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 3 * removeCount);
455 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 3 * removeCount);
456 }
456 }
457
457
@@ -459,13 +459,13 void tst_qbarmodelmapper::verticalModelInsertColumns()
459 {
459 {
460 // setup the mapper
460 // setup the mapper
461 createVerticalMapper();
461 createVerticalMapper();
462 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
462 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
463 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
463 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
464 QVERIFY(m_vMapper->model() != 0);
464 QVERIFY(m_vMapper->model() != 0);
465
465
466 int insertCount = 4;
466 int insertCount = 4;
467 m_model->insertColumns(3, insertCount);
467 m_model->insertColumns(3, insertCount);
468 QCOMPARE(m_series->barsetCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
468 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
469 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
469 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
470 }
470 }
471
471
@@ -473,31 +473,31 void tst_qbarmodelmapper::verticalModelRemoveColumns()
473 {
473 {
474 // setup the mapper
474 // setup the mapper
475 createVerticalMapper();
475 createVerticalMapper();
476 QCOMPARE(m_series->barsetCount(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
476 QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
477 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
477 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
478 QVERIFY(m_vMapper->model() != 0);
478 QVERIFY(m_vMapper->model() != 0);
479
479
480 int removeCount = m_modelColumnCount - 2;
480 int removeCount = m_modelColumnCount - 2;
481 m_model->removeColumns(0, removeCount);
481 m_model->removeColumns(0, removeCount);
482 QCOMPARE(m_series->barsetCount(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
482 QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
483 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
483 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
484
484
485 // leave all the columns
485 // leave all the columns
486 m_model->removeColumns(0, m_modelColumnCount - removeCount);
486 m_model->removeColumns(0, m_modelColumnCount - removeCount);
487 QCOMPARE(m_series->barsetCount(), 0);
487 QCOMPARE(m_series->count(), 0);
488 }
488 }
489
489
490 void tst_qbarmodelmapper::horizontalModelInsertRows()
490 void tst_qbarmodelmapper::horizontalModelInsertRows()
491 {
491 {
492 // setup the mapper
492 // setup the mapper
493 createHorizontalMapper();
493 createHorizontalMapper();
494 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
494 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
495 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
495 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
496 QVERIFY(m_hMapper->model() != 0);
496 QVERIFY(m_hMapper->model() != 0);
497
497
498 int insertCount = 4;
498 int insertCount = 4;
499 m_model->insertRows(3, insertCount);
499 m_model->insertRows(3, insertCount);
500 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
500 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
501 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
501 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
502 }
502 }
503
503
@@ -505,57 +505,57 void tst_qbarmodelmapper::horizontalModelRemoveRows()
505 {
505 {
506 // setup the mapper
506 // setup the mapper
507 createHorizontalMapper();
507 createHorizontalMapper();
508 QCOMPARE(m_series->barsetCount(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
508 QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
509 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
509 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
510 QVERIFY(m_hMapper->model() != 0);
510 QVERIFY(m_hMapper->model() != 0);
511
511
512 int removeCount = m_modelRowCount - 2;
512 int removeCount = m_modelRowCount - 2;
513 m_model->removeRows(0, removeCount);
513 m_model->removeRows(0, removeCount);
514 QCOMPARE(m_series->barsetCount(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
514 QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
515 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
515 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
516
516
517 // leave all the columns
517 // leave all the columns
518 m_model->removeRows(0, m_modelRowCount - removeCount);
518 m_model->removeRows(0, m_modelRowCount - removeCount);
519 QCOMPARE(m_series->barsetCount(), 0);
519 QCOMPARE(m_series->count(), 0);
520 }
520 }
521
521
522 void tst_qbarmodelmapper::horizontalModelInsertColumns()
522 void tst_qbarmodelmapper::horizontalModelInsertColumns()
523 {
523 {
524 // setup the mapper
524 // setup the mapper
525 createHorizontalMapper();
525 createHorizontalMapper();
526 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
526 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
527 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
527 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
528 QVERIFY(m_hMapper->model() != 0);
528 QVERIFY(m_hMapper->model() != 0);
529
529
530 int insertCount = 4;
530 int insertCount = 4;
531 m_model->insertColumns(3, insertCount);
531 m_model->insertColumns(3, insertCount);
532 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
532 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
533 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount);
533 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount);
534
534
535 int first = 3;
535 int first = 3;
536 m_hMapper->setFirst(3);
536 m_hMapper->setFirst(3);
537 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
537 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
538 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount - first);
538 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount - first);
539
539
540 m_model->insertColumns(3, insertCount);
540 m_model->insertColumns(3, insertCount);
541 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
541 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
542 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 2 * insertCount - first);
542 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 2 * insertCount - first);
543
543
544 int countLimit = 6;
544 int countLimit = 6;
545 m_hMapper->setCount(countLimit);
545 m_hMapper->setCount(countLimit);
546 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
546 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
547 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
547 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
548
548
549 m_model->insertColumns(3, insertCount);
549 m_model->insertColumns(3, insertCount);
550 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
550 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
551 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
551 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
552
552
553 m_hMapper->setFirst(0);
553 m_hMapper->setFirst(0);
554 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
554 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
555 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
555 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
556
556
557 m_hMapper->setCount(-1);
557 m_hMapper->setCount(-1);
558 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
558 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
559 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 3 * insertCount);
559 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 3 * insertCount);
560 }
560 }
561
561
@@ -563,39 +563,39 void tst_qbarmodelmapper::horizontalModelRemoveColumns()
563 {
563 {
564 // setup the mapper
564 // setup the mapper
565 createHorizontalMapper();
565 createHorizontalMapper();
566 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
566 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
567 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
567 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
568 QVERIFY(m_hMapper->model() != 0);
568 QVERIFY(m_hMapper->model() != 0);
569
569
570 int removeCount = 2;
570 int removeCount = 2;
571 m_model->removeColumns(1, removeCount);
571 m_model->removeColumns(1, removeCount);
572 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
572 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
573 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount);
573 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount);
574
574
575 int first = 1;
575 int first = 1;
576 m_hMapper->setFirst(first);
576 m_hMapper->setFirst(first);
577 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
577 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
578 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount - first);
578 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount - first);
579
579
580 m_model->removeColumns(1, removeCount);
580 m_model->removeColumns(1, removeCount);
581 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
581 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
582 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 2 * removeCount - first);
582 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 2 * removeCount - first);
583
583
584 int countLimit = 3;
584 int countLimit = 3;
585 m_hMapper->setCount(countLimit);
585 m_hMapper->setCount(countLimit);
586 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
586 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
587 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
587 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
588
588
589 m_model->removeColumns(1, removeCount);
589 m_model->removeColumns(1, removeCount);
590 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
590 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
591 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
591 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
592
592
593 m_hMapper->setFirst(0);
593 m_hMapper->setFirst(0);
594 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
594 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
595 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
595 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
596
596
597 m_hMapper->setCount(-1);
597 m_hMapper->setCount(-1);
598 QCOMPARE(m_series->barsetCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
598 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
599 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 3 * removeCount);
599 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 3 * removeCount);
600 }
600 }
601
601
@@ -49,8 +49,8 private slots:
49 void remove();
49 void remove();
50 void appendList_data();
50 void appendList_data();
51 void appendList();
51 void appendList();
52 void barsetCount_data();
52 void count_data();
53 void barsetCount();
53 void count();
54 void barSets_data();
54 void barSets_data();
55 void barSets();
55 void barSets();
56 void setLabelsVisible_data();
56 void setLabelsVisible_data();
@@ -129,7 +129,7 void tst_QBarSeries::append_data()
129
129
130 void tst_QBarSeries::append()
130 void tst_QBarSeries::append()
131 {
131 {
132 QVERIFY(m_barseries->barsetCount() == 0);
132 QVERIFY(m_barseries->count() == 0);
133
133
134 bool ret = false;
134 bool ret = false;
135
135
@@ -138,24 +138,24 void tst_QBarSeries::append()
138 ret = m_barseries->append(barset);
138 ret = m_barseries->append(barset);
139
139
140 QVERIFY(ret == true);
140 QVERIFY(ret == true);
141 QVERIFY(m_barseries->barsetCount() == 1);
141 QVERIFY(m_barseries->count() == 1);
142
142
143 // Try adding another set
143 // Try adding another set
144 QBarSet *barset2 = new QBarSet("testset2");
144 QBarSet *barset2 = new QBarSet("testset2");
145 ret = m_barseries->append(barset2);
145 ret = m_barseries->append(barset2);
146
146
147 QVERIFY(ret == true);
147 QVERIFY(ret == true);
148 QVERIFY(m_barseries->barsetCount() == 2);
148 QVERIFY(m_barseries->count() == 2);
149
149
150 // Try adding same set again
150 // Try adding same set again
151 ret = m_barseries->append(barset2);
151 ret = m_barseries->append(barset2);
152 QVERIFY(ret == false);
152 QVERIFY(ret == false);
153 QVERIFY(m_barseries->barsetCount() == 2);
153 QVERIFY(m_barseries->count() == 2);
154
154
155 // Try adding null set
155 // Try adding null set
156 ret = m_barseries->append(0);
156 ret = m_barseries->append(0);
157 QVERIFY(ret == false);
157 QVERIFY(ret == false);
158 QVERIFY(m_barseries->barsetCount() == 2);
158 QVERIFY(m_barseries->count() == 2);
159
159
160 }
160 }
161
161
@@ -166,18 +166,18 void tst_QBarSeries::remove_data()
166 void tst_QBarSeries::remove()
166 void tst_QBarSeries::remove()
167 {
167 {
168 int count = m_testSets.count();
168 int count = m_testSets.count();
169 QVERIFY(m_barseries_with_sets->barsetCount() == count);
169 QVERIFY(m_barseries_with_sets->count() == count);
170
170
171 // Try to remove null pointer (should not remove, should not crash)
171 // Try to remove null pointer (should not remove, should not crash)
172 bool ret = false;
172 bool ret = false;
173 ret = m_barseries_with_sets->remove(0);
173 ret = m_barseries_with_sets->remove(0);
174 QVERIFY(ret == false);
174 QVERIFY(ret == false);
175 QVERIFY(m_barseries_with_sets->barsetCount() == count);
175 QVERIFY(m_barseries_with_sets->count() == count);
176
176
177 // Try to remove invalid pointer (should not remove, should not crash)
177 // Try to remove invalid pointer (should not remove, should not crash)
178 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
178 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
179 QVERIFY(ret == false);
179 QVERIFY(ret == false);
180 QVERIFY(m_barseries_with_sets->barsetCount() == count);
180 QVERIFY(m_barseries_with_sets->count() == count);
181
181
182 // remove some sets
182 // remove some sets
183 ret = m_barseries_with_sets->remove(m_testSets.at(2));
183 ret = m_barseries_with_sets->remove(m_testSets.at(2));
@@ -187,7 +187,7 void tst_QBarSeries::remove()
187 ret = m_barseries_with_sets->remove(m_testSets.at(4));
187 ret = m_barseries_with_sets->remove(m_testSets.at(4));
188 QVERIFY(ret == true);
188 QVERIFY(ret == true);
189
189
190 QVERIFY(m_barseries_with_sets->barsetCount() == 2);
190 QVERIFY(m_barseries_with_sets->count() == 2);
191
191
192 QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
192 QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
193
193
@@ -201,7 +201,7 void tst_QBarSeries::remove()
201 }
201 }
202
202
203 QVERIFY(ret == true);
203 QVERIFY(ret == true);
204 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
204 QVERIFY(m_barseries_with_sets->count() == 0);
205 }
205 }
206
206
207 void tst_QBarSeries::appendList_data()
207 void tst_QBarSeries::appendList_data()
@@ -212,7 +212,7 void tst_QBarSeries::appendList_data()
212 void tst_QBarSeries::appendList()
212 void tst_QBarSeries::appendList()
213 {
213 {
214 int count = 5;
214 int count = 5;
215 QVERIFY(m_barseries->barsetCount() == 0);
215 QVERIFY(m_barseries->count() == 0);
216
216
217 QList<QBarSet*> sets;
217 QList<QBarSet*> sets;
218 for (int i=0; i<count; i++) {
218 for (int i=0; i<count; i++) {
@@ -223,25 +223,25 void tst_QBarSeries::appendList()
223 bool ret = false;
223 bool ret = false;
224 ret = m_barseries->append(sets);
224 ret = m_barseries->append(sets);
225 QVERIFY(ret == true);
225 QVERIFY(ret == true);
226 QVERIFY(m_barseries->barsetCount() == count);
226 QVERIFY(m_barseries->count() == count);
227
227
228 // Append same sets again (should fail, count should remain same)
228 // Append same sets again (should fail, count should remain same)
229 ret = m_barseries->append(sets);
229 ret = m_barseries->append(sets);
230 QVERIFY(ret == false);
230 QVERIFY(ret == false);
231 QVERIFY(m_barseries->barsetCount() == count);
231 QVERIFY(m_barseries->count() == count);
232
232
233 // Try append empty list (should succeed, but count should remain same)
233 // Try append empty list (should succeed, but count should remain same)
234 QList<QBarSet*> invalidList;
234 QList<QBarSet*> invalidList;
235 ret = m_barseries->append(invalidList);
235 ret = m_barseries->append(invalidList);
236 QVERIFY(ret == true);
236 QVERIFY(ret == true);
237 QVERIFY(m_barseries->barsetCount() == count);
237 QVERIFY(m_barseries->count() == count);
238
238
239 // Try append list with one new and one existing set (should fail, count remains same)
239 // Try append list with one new and one existing set (should fail, count remains same)
240 invalidList.append(new QBarSet("ok set"));
240 invalidList.append(new QBarSet("ok set"));
241 invalidList.append(sets.at(0));
241 invalidList.append(sets.at(0));
242 ret = m_barseries->append(invalidList);
242 ret = m_barseries->append(invalidList);
243 QVERIFY(ret == false);
243 QVERIFY(ret == false);
244 QVERIFY(m_barseries->barsetCount() == count);
244 QVERIFY(m_barseries->count() == count);
245
245
246 // Try append list with null pointers (should fail, count remains same)
246 // Try append list with null pointers (should fail, count remains same)
247 QList<QBarSet*> invalidList2;
247 QList<QBarSet*> invalidList2;
@@ -250,18 +250,18 void tst_QBarSeries::appendList()
250 invalidList2.append(0);
250 invalidList2.append(0);
251 ret = m_barseries->append(invalidList2);
251 ret = m_barseries->append(invalidList2);
252 QVERIFY(ret == false);
252 QVERIFY(ret == false);
253 QVERIFY(m_barseries->barsetCount() == count);
253 QVERIFY(m_barseries->count() == count);
254 }
254 }
255
255
256 void tst_QBarSeries::barsetCount_data()
256 void tst_QBarSeries::count_data()
257 {
257 {
258
258
259 }
259 }
260
260
261 void tst_QBarSeries::barsetCount()
261 void tst_QBarSeries::count()
262 {
262 {
263 QVERIFY(m_barseries->barsetCount() == 0);
263 QVERIFY(m_barseries->count() == 0);
264 QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count());
264 QVERIFY(m_barseries_with_sets->count() == m_testSets.count());
265 }
265 }
266
266
267 void tst_QBarSeries::barSets_data()
267 void tst_QBarSeries::barSets_data()
General Comments 0
You need to be logged in to leave comments. Login now