| 2303 | } |
| 2304 | |
| 2305 | void 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. |
| 2344 | void SpreadsheetView::fillSelectedCellsWithRandomNumbers() { |