| 196 | } |
| 197 | |
| 198 | bool FitParametersWidget::eventFilter(QObject* watched, QEvent* event) { |
| 199 | if (watched == ui.tableWidget) { |
| 200 | if (event->type() == QEvent::KeyPress) { |
| 201 | const auto* keyEvent = static_cast<QKeyEvent*>(event); |
| 202 | if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) && keyEvent->modifiers() == Qt::NoModifier) { |
| 203 | const int row = ui.tableWidget->currentRow(); |
| 204 | const int col = ui.tableWidget->currentColumn(); |
| 205 | |
| 206 | if (row < ui.tableWidget->rowCount() - 1) { |
| 207 | ui.tableWidget->setCurrentCell(row + 1, col); // go to the next cell in the same column |
| 208 | } else { |
| 209 | if (col < ui.tableWidget->columnCount() - 1) |
| 210 | ui.tableWidget->setCurrentCell(0, col + 1); // go to the first cell in the next column |
| 211 | else |
| 212 | ui.tableWidget->setCurrentCell(0, 1); // go to the first cell in the first column (index=1 since 0 is for the parameter name) |
| 213 | } |
| 214 | |
| 215 | // select the current text so it can be easier overwritten |
| 216 | auto* le = dynamic_cast<QLineEdit*>(ui.tableWidget->cellWidget(ui.tableWidget->currentRow(), ui.tableWidget->currentColumn())); |
| 217 | if (le) |
| 218 | le->selectAll(); |
| 219 | return true; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | return QWidget::eventFilter(watched, event); |
| 225 | } |
| 226 | |
| 227 | void FitParametersWidget::resizeEvent(QResizeEvent*) { |
| 228 | updateTableSize(); |
nothing calls this directly
no test coverage detected