| 3502 | } |
| 3503 | |
| 3504 | void SpreadsheetView::showSearchReplace(bool replace) { |
| 3505 | if (!m_searchReplaceWidget) { |
| 3506 | m_searchReplaceWidget = new SearchReplaceWidget(m_spreadsheet, this); |
| 3507 | static_cast<QVBoxLayout*>(this->layout())->addWidget(m_searchReplaceWidget); |
| 3508 | } |
| 3509 | |
| 3510 | m_searchReplaceWidget->setReplaceEnabled(replace); |
| 3511 | |
| 3512 | const auto& indexes = m_tableView->selectionModel()->selectedIndexes(); |
| 3513 | if (!indexes.isEmpty()) { |
| 3514 | const auto& firstIndex = indexes.constFirst(); |
| 3515 | const auto* column = m_spreadsheet->column(firstIndex.column()); |
| 3516 | const int row = firstIndex.row(); |
| 3517 | m_searchReplaceWidget->setInitialPattern(column->columnMode(), column->asStringColumn()->textAt(row)); |
| 3518 | } |
| 3519 | |
| 3520 | m_searchReplaceWidget->show(); |
| 3521 | |
| 3522 | // interrupt the event loop to show/render the widget first and set the focus |
| 3523 | // after this otherwise the focus in the search field is not set |
| 3524 | QTimer::singleShot(0, this, [=]() { |
| 3525 | m_searchReplaceWidget->setFocus(); |
| 3526 | }); |
| 3527 | } |
| 3528 | |
| 3529 | /*! |
| 3530 | * sorts the selected columns separately of each other in ascending order. |
nothing calls this directly
no test coverage detected