MCPcopy Create free account
hub / github.com/KDE/labplot / testLinkSpreadsheetsUndoRedo

Method testLinkSpreadsheetsUndoRedo

tests/spreadsheet/SpreadsheetTest.cpp:2685–2780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2683}
2684
2685void SpreadsheetTest::testLinkSpreadsheetsUndoRedo() {
2686#ifdef __FreeBSD__
2687 return;
2688#endif
2689 Project project;
2690 auto* sheetData = new Spreadsheet(QStringLiteral("data"), false);
2691 project.addChild(sheetData);
2692 sheetData->setColumnCount(3);
2693 sheetData->setRowCount(10);
2694
2695 auto* sheetData2 = new Spreadsheet(QStringLiteral("data2"), false);
2696 project.addChild(sheetData2);
2697 sheetData2->setColumnCount(3);
2698 sheetData2->setRowCount(100);
2699
2700 auto* sheetCalculations = new Spreadsheet(QStringLiteral("calculations"), false);
2701 project.addChild(sheetCalculations);
2702 sheetCalculations->setColumnCount(3);
2703 sheetCalculations->setRowCount(2);
2704
2705 SpreadsheetDock dock(nullptr);
2706 dock.setSpreadsheets({sheetCalculations});
2707 auto* modelSheetCalculations = new SpreadsheetModel(sheetCalculations);
2708
2709 QCOMPARE(dock.ui.cbLinkingEnabled->isChecked(), false);
2710 QCOMPARE(dock.ui.cbLinkedSpreadsheet->isVisible(), false);
2711 QCOMPARE(dock.ui.sbRowCount->isEnabled(), true);
2712 QCOMPARE(dock.m_spreadsheet->linking(), false);
2713
2714 dock.ui.cbLinkingEnabled->toggled(true);
2715
2716 // QCOMPARE(dock.ui.cbLinkingEnabled->isChecked(), true); // does not work here. Don't know why
2717 // QCOMPARE(dock.ui.cbLinkedSpreadsheet->isVisible(), true);
2718 // QCOMPARE(dock.ui.sbRowCount->isEnabled(), false);
2719 QCOMPARE(sheetCalculations->linking(), true);
2720 QCOMPARE(sheetCalculations->linkedSpreadsheet(), nullptr);
2721 QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), QLatin1String());
2722 QCOMPARE(sheetCalculations->rowCount(), 2);
2723 QCOMPARE(modelSheetCalculations->rowCount(), 2);
2724
2725 const auto index = dock.aspectModel()->modelIndexOfAspect(sheetData);
2726 QCOMPARE(index.isValid(), true);
2727 // dock.ui.cbLinkedSpreadsheet->setCurrentModelIndex(index); // Does not trigger the slot
2728 sheetCalculations->setLinkedSpreadsheet(sheetData);
2729
2730 QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetData);
2731 QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetData->path());
2732 QCOMPARE(sheetCalculations->rowCount(), 10);
2733 QCOMPARE(modelSheetCalculations->rowCount(), 10);
2734
2735 sheetCalculations->setLinkedSpreadsheet(sheetData2);
2736
2737 QCOMPARE(sheetCalculations->linking(), true);
2738 QCOMPARE(sheetCalculations->linkedSpreadsheet(), sheetData2);
2739 QCOMPARE(sheetCalculations->linkedSpreadsheetPath(), sheetData2->path());
2740 QCOMPARE(sheetCalculations->rowCount(), 100);
2741 QCOMPARE(modelSheetCalculations->rowCount(), 100);
2742

Callers

nothing calls this directly

Calls 15

linkedSpreadsheetPathMethod · 0.80
modelIndexOfAspectMethod · 0.80
aspectModelMethod · 0.80
setLinkedSpreadsheetMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
setSpreadsheetsMethod · 0.45
isVisibleMethod · 0.45
rowCountMethod · 0.45
isValidMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected