| 514 | } |
| 515 | |
| 516 | void QMappingSequenceEdit::insertMappingKeyToTable(int insertMode) |
| 517 | { |
| 518 | const MappingSequenceEditTableWidget *table = ui->mappingSequenceEditTable; |
| 519 | const bool hadSelectionBeforeInsert = !table->selectedRanges().isEmpty(); |
| 520 | |
| 521 | QString mappingkeystr = ui->MappingSequenceEdit_MappingKeyLineEdit->text(); |
| 522 | mappingkeystr = QKeyMapper::getTrimmedMappingKeyString(mappingkeystr); |
| 523 | |
| 524 | #ifdef DEBUG_LOGOUT_ON |
| 525 | qDebug().nospace().noquote() << "[" << __func__ << "] MappingKeyText after trimmed -> " << mappingkeystr; |
| 526 | #endif |
| 527 | |
| 528 | QString popupMessage; |
| 529 | QString trimmed = mappingkeystr; |
| 530 | if (!validateOrAllowEmptyMappingKey(&trimmed, &popupMessage)) { |
| 531 | emitValidationFailurePopup(popupMessage); |
| 532 | return; |
| 533 | } |
| 534 | |
| 535 | const int insertRow = getInsertRowFromSelectionOrAppend(insertMode); |
| 536 | if (insertRow < 0) { |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | ensureBaseSnapshotBeforeListChange(); |
| 541 | |
| 542 | if (insertRow >= m_MappingSequenceList.size()) { |
| 543 | m_MappingSequenceList.append(trimmed); |
| 544 | } else { |
| 545 | m_MappingSequenceList.insert(insertRow, trimmed); |
| 546 | } |
| 547 | |
| 548 | refreshMappingSequenceEditTableWidget(ui->mappingSequenceEditTable, m_MappingSequenceList); |
| 549 | |
| 550 | if (hadSelectionBeforeInsert) { |
| 551 | reselectionRangeAndScroll(insertRow, insertRow); |
| 552 | } |
| 553 | else { |
| 554 | keepSelectionEmptyAndScrollToRow(insertRow); |
| 555 | } |
| 556 | |
| 557 | commitHistorySnapshotIfNeeded(); |
| 558 | } |
| 559 | |
| 560 | void QMappingSequenceEdit::mappingSequenceTableItemDoubleClicked(QTableWidgetItem *item) |
| 561 | { |