| 388 | } |
| 389 | |
| 390 | void FunctionValuesDialog::generate() { |
| 391 | Q_ASSERT(m_spreadsheet); |
| 392 | |
| 393 | WAIT_CURSOR; |
| 394 | m_spreadsheet->beginMacro(i18np("%1: fill column with function values", "%1: fill columns with function values", m_spreadsheet->name(), m_columns.size())); |
| 395 | |
| 396 | // determine variable names and data vectors of the specified columns |
| 397 | QStringList variableNames; |
| 398 | QVector<Column*> variableColumns; |
| 399 | for (int i = 0; i < m_variableLineEdits.size(); ++i) { |
| 400 | variableNames << m_variableLineEdits.at(i)->text().simplified(); |
| 401 | |
| 402 | auto* aspect{static_cast<AbstractAspect*>(m_variableDataColumns.at(i)->currentModelIndex().internalPointer())}; |
| 403 | if (aspect) { |
| 404 | auto* column{dynamic_cast<Column*>(aspect)}; |
| 405 | if (column) |
| 406 | variableColumns << column; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | // set the new values and store the expression, variable names and used data columns |
| 411 | const QString& expression{ui.teEquation->toPlainText()}; |
| 412 | bool autoUpdate{(ui.chkAutoUpdate->checkState() == Qt::Checked)}; |
| 413 | bool autoResize{(ui.chkAutoResize->checkState() == Qt::Checked)}; |
| 414 | for (auto* col : m_columns) { |
| 415 | col->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 416 | col->setFormula(expression, variableNames, variableColumns, autoUpdate, autoResize); |
| 417 | col->updateFormula(); |
| 418 | } |
| 419 | m_spreadsheet->endMacro(); |
| 420 | RESET_CURSOR; |
| 421 | } |
nothing calls this directly
no test coverage detected