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

Method clearSelectedCells

src/frontend/spreadsheet/SpreadsheetView.cpp:3434–3474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3432}
3433
3434void 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
3476void SpreadsheetView::goToCell() {
3477 auto* dlg = new GoToDialog(this);

Callers

nothing calls this directly

Calls 13

selectionModelMethod · 0.80
beginMacroMethod · 0.80
asStringColumnMethod · 0.80
endMacroMethod · 0.80
QStringClass · 0.50
isValidMethod · 0.45
columnMethod · 0.45
rowMethod · 0.45
nameMethod · 0.45
clearMethod · 0.45
setTextAtMethod · 0.45

Tested by

no test coverage detected