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

Method testSearchFindAll

tests/spreadsheet/SpreadsheetTest.cpp:2104–2132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2102}
2103
2104void SpreadsheetTest::testSearchFindAll() {
2105#ifdef __FreeBSD__
2106 // ASSERT failure in QBoxLayout::insert: "index out of range"
2107 return;
2108#endif
2109 Project project;
2110 auto* sheet = createSearchReplaceSpreadsheet();
2111 project.addChild(sheet);
2112
2113 // initialize the search&replace widget
2114 auto* searchReplaceWidget = new SearchReplaceWidget(sheet, nullptr);
2115 searchReplaceWidget->setReplaceEnabled(true);
2116 searchReplaceWidget->setDataType(SearchReplaceWidget::DataType::Text);
2117 searchReplaceWidget->setOrder(SearchReplaceWidget::Order::ColumnMajor);
2118 searchReplaceWidget->setTextOperator(SearchReplaceWidget::OperatorText::StartsWith);
2119
2120 // search for cells starting with "B" and highlight them ("find")
2121 searchReplaceWidget->setInitialPattern(AbstractColumn::ColumnMode::Text, QLatin1String("B"));
2122 searchReplaceWidget->findAll();
2123
2124 // checks
2125 auto* view = static_cast<SpreadsheetView*>(sheet->view());
2126 auto indexes = view->selectionModel()->selectedIndexes();
2127 QCOMPARE(indexes.size(), 2);
2128 QCOMPARE(indexes.at(0).row(), 1);
2129 QCOMPARE(indexes.at(0).column(), 0);
2130 QCOMPARE(indexes.at(1).row(), 0);
2131 QCOMPARE(indexes.at(1).column(), 2);
2132}
2133
2134/*!
2135 * replace a numeric value in int and double columns via "replace next"

Callers

nothing calls this directly

Calls 12

setReplaceEnabledMethod · 0.80
setOrderMethod · 0.80
setTextOperatorMethod · 0.80
setInitialPatternMethod · 0.80
findAllMethod · 0.80
selectionModelMethod · 0.80
addChildMethod · 0.45
setDataTypeMethod · 0.45
viewMethod · 0.45
sizeMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected