SLOTs for changes triggered in XYFunctionCurveDock
| 176 | //**** SLOTs for changes triggered in XYFunctionCurveDock **** |
| 177 | //************************************************************* |
| 178 | void XYFunctionCurveDock::addVariable() { |
| 179 | const auto row{m_variableLineEdits.size()}; |
| 180 | |
| 181 | // text field for the variable name |
| 182 | auto* le{new QLineEdit}; |
| 183 | le->setToolTip(i18n("Variable name can contain letters, digits and '_' only and should start with a letter")); |
| 184 | auto* validator = new QRegularExpressionValidator(QRegularExpression(QLatin1String("[a-zA-Z][a-zA-Z0-9_]*")), le); |
| 185 | le->setValidator(validator); |
| 186 | // le->setMaximumWidth(40); // hardcoding size is bad. 40 is enough for three letters |
| 187 | connect(le, &QLineEdit::textChanged, this, &XYFunctionCurveDock::variableNameChanged); |
| 188 | m_gridLayoutVariables->addWidget(le, row, 0, 1, 1); |
| 189 | m_variableLineEdits << le; |
| 190 | |
| 191 | // combo box for the data column |
| 192 | auto* cb{new TreeViewComboBox()}; |
| 193 | cb->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); |
| 194 | connect(cb, &TreeViewComboBox::currentModelIndexChanged, this, &XYFunctionCurveDock::variableColumnChanged); |
| 195 | m_gridLayoutCurves->addWidget(cb, row, 2, 1, 1); |
| 196 | m_variableComboBoxes << cb; |
| 197 | |
| 198 | setModelCurve(cb); |
| 199 | |
| 200 | // don't allow to select columns to be calculated as variable columns (avoid circular dependencies) |
| 201 | QList<const AbstractAspect*> aspects; |
| 202 | for (auto* c : m_curvesList) |
| 203 | aspects << c; |
| 204 | cb->setHiddenAspects(aspects); |
| 205 | |
| 206 | // for the variable curve select the first non-selected curve |
| 207 | const auto& plot = m_curve->plot(); |
| 208 | for (auto* c : plot->children<XYCurve>()) { |
| 209 | if (m_curvesList.indexOf(c) == -1) { |
| 210 | cb->setCurrentModelIndex(aspectModel()->modelIndexOfAspect(c)); |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | // add delete-button for the just added variable |
| 216 | if (row != 0) { |
| 217 | auto* b{new QToolButton()}; |
| 218 | b->setIcon(QIcon::fromTheme(QStringLiteral("list-remove"))); |
| 219 | b->setToolTip(i18n("Delete variable")); |
| 220 | m_gridLayoutCurves->addWidget(b, row, 3, 1, 1); |
| 221 | m_variableDeleteButtons << b; |
| 222 | connect(b, &QToolButton::pressed, this, &XYFunctionCurveDock::deleteVariable); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | void XYFunctionCurveDock::removeAllVariableWidgets() { |
| 227 | while (!m_variableLineEdits.isEmpty()) |
nothing calls this directly
no test coverage detected