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

Method eventFilter

src/frontend/widgets/FitParametersWidget.cpp:198–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198bool 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
227void FitParametersWidget::resizeEvent(QResizeEvent*) {
228 updateTableSize();

Callers

nothing calls this directly

Calls 4

typeMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
selectAllMethod · 0.45

Tested by

no test coverage detected