| 2421 | QCOMPARE(rowsRemovedCounter, 1); // undo() |
| 2422 | } |
| 2423 | void SpreadsheetTest::testRemoveRowsBegin() { |
| 2424 | Project project; |
| 2425 | auto* sheet = new Spreadsheet(QStringLiteral("test"), false); |
| 2426 | project.addChild(sheet); |
| 2427 | |
| 2428 | auto* model = new SpreadsheetModel(sheet); |
| 2429 | int rowsAboutToBeInsertedCounter = 0; |
| 2430 | connect(model, &SpreadsheetModel::rowsAboutToBeInserted, [&rowsAboutToBeInsertedCounter]() { |
| 2431 | rowsAboutToBeInsertedCounter++; |
| 2432 | }); |
| 2433 | int rowsInsertedCounter = 0; |
| 2434 | connect(model, &SpreadsheetModel::rowsInserted, [&rowsInsertedCounter]() { |
| 2435 | rowsInsertedCounter++; |
| 2436 | }); |
| 2437 | int rowsAboutToBeRemovedCounter = 0; |
| 2438 | connect(model, &SpreadsheetModel::rowsAboutToBeRemoved, [&rowsAboutToBeRemovedCounter]() { |
| 2439 | rowsAboutToBeRemovedCounter++; |
| 2440 | }); |
| 2441 | int rowsRemovedCounter = 0; |
| 2442 | connect(model, &SpreadsheetModel::rowsRemoved, [&rowsRemovedCounter]() { |
| 2443 | rowsRemovedCounter++; |
| 2444 | }); |
| 2445 | |
| 2446 | QCOMPARE(sheet->rowCount(), 100); |
| 2447 | QCOMPARE(model->rowCount(), 100); |
| 2448 | sheet->removeRows(0, 1); |
| 2449 | QCOMPARE(sheet->rowCount(), 99); |
| 2450 | QCOMPARE(model->rowCount(), 99); |
| 2451 | |
| 2452 | sheet->undoStack()->undo(); |
| 2453 | QCOMPARE(sheet->rowCount(), 100); |
| 2454 | QCOMPARE(model->rowCount(), 100); |
| 2455 | sheet->undoStack()->redo(); |
| 2456 | QCOMPARE(sheet->rowCount(), 99); |
| 2457 | QCOMPARE(model->rowCount(), 99); |
| 2458 | |
| 2459 | QCOMPARE(rowsAboutToBeInsertedCounter, 1); // undo |
| 2460 | QCOMPARE(rowsInsertedCounter, 1); // undo |
| 2461 | QCOMPARE(rowsAboutToBeRemovedCounter, 2); // set and redo() |
| 2462 | QCOMPARE(rowsRemovedCounter, 2); // set and redo() |
| 2463 | } |
| 2464 | |
| 2465 | void SpreadsheetTest::testInsertColumns() { |
| 2466 | Project project; |