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

Method fillWithRowNumbers

src/frontend/spreadsheet/SpreadsheetView.cpp:2305–2341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2303}
2304
2305void SpreadsheetView::fillWithRowNumbers() {
2306 const auto& columns = selectedColumns();
2307 if (columns.isEmpty())
2308 return;
2309
2310 WAIT_CURSOR;
2311 m_spreadsheet->beginMacro(i18np("%1: fill column with row numbers", "%1: fill columns with row numbers", m_spreadsheet->name(), columns.count()));
2312
2313 const int rows = m_spreadsheet->rowCount();
2314
2315 QVector<int> int_data(rows);
2316 for (int i = 0; i < rows; ++i)
2317 int_data[i] = i + 1;
2318
2319 for (auto* col : columns) {
2320 col->clearFormula(); // clear the potentially available column formula
2321
2322 switch (col->columnMode()) {
2323 case AbstractColumn::ColumnMode::Integer:
2324 col->replaceInteger(0, int_data);
2325 break;
2326 case AbstractColumn::ColumnMode::Double:
2327 case AbstractColumn::ColumnMode::BigInt:
2328 col->setColumnMode(AbstractColumn::ColumnMode::Integer);
2329 col->replaceInteger(0, int_data);
2330 break;
2331 case AbstractColumn::ColumnMode::Text:
2332 case AbstractColumn::ColumnMode::DateTime:
2333 case AbstractColumn::ColumnMode::Day:
2334 case AbstractColumn::ColumnMode::Month:
2335 break;
2336 }
2337 }
2338
2339 m_spreadsheet->endMacro();
2340 RESET_CURSOR;
2341}
2342
2343// TODO: this function is not used currently.
2344void SpreadsheetView::fillSelectedCellsWithRandomNumbers() {

Callers 1

exportImportMethod · 0.80

Calls 10

beginMacroMethod · 0.80
clearFormulaMethod · 0.80
endMacroMethod · 0.80
isEmptyMethod · 0.45
nameMethod · 0.45
countMethod · 0.45
rowCountMethod · 0.45
columnModeMethod · 0.45
replaceIntegerMethod · 0.45
setColumnModeMethod · 0.45

Tested by 1

exportImportMethod · 0.64