| 3432 | } |
| 3433 | |
| 3434 | void SpreadsheetView::clearSelectedCells() { |
| 3435 | // don't try to clear values if the selected cells don't have any values at all |
| 3436 | bool empty = true; |
| 3437 | |
| 3438 | const auto& columns = m_spreadsheet->children<Column>(); |
| 3439 | const auto& indexes = m_tableView->selectionModel()->selectedIndexes(); |
| 3440 | for (const auto& index : indexes) { |
| 3441 | if (columns.at(index.column())->isValid(index.row())) { |
| 3442 | empty = false; |
| 3443 | break; |
| 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | if (empty) |
| 3448 | return; |
| 3449 | |
| 3450 | WAIT_CURSOR; |
| 3451 | m_spreadsheet->beginMacro(i18n("%1: clear selected cells", m_spreadsheet->name())); |
| 3452 | for (auto* column : columns) { |
| 3453 | column->setSuppressDataChangedSignal(true); |
| 3454 | // if (formulaModeActive()) { |
| 3455 | // int col = m_spreadsheet->indexOfChild<Column>(column); |
| 3456 | // for (int row = last; row >= first; row--) |
| 3457 | // if (isCellSelected(row, col)) |
| 3458 | // column->setFormula(row, QString()); |
| 3459 | // } else { |
| 3460 | int index = m_spreadsheet->indexOfChild<Column>(column); |
| 3461 | if (isColumnSelected(index, true)) { |
| 3462 | // if the whole column is selected, clear directly instead of looping over the rows |
| 3463 | column->clear(); |
| 3464 | } else { |
| 3465 | for (const auto& index : indexes) |
| 3466 | columns.at(index.column())->asStringColumn()->setTextAt(index.row(), QString()); |
| 3467 | } |
| 3468 | |
| 3469 | column->setSuppressDataChangedSignal(false); |
| 3470 | column->setChanged(); |
| 3471 | } |
| 3472 | m_spreadsheet->endMacro(); |
| 3473 | RESET_CURSOR; |
| 3474 | } |
| 3475 | |
| 3476 | void SpreadsheetView::goToCell() { |
| 3477 | auto* dlg = new GoToDialog(this); |
nothing calls this directly
no test coverage detected