| 762 | } |
| 763 | |
| 764 | void MappingSequenceEditTableWidget::contextMenuEvent(QContextMenuEvent *event) |
| 765 | { |
| 766 | QMappingSequenceEdit *dlg = QMappingSequenceEdit::getInstance(); |
| 767 | if (!dlg || QKeyMapper::KEYMAP_IDLE != QKeyMapper::getInstance()->m_KeyMapStatus) { |
| 768 | QTableWidget::contextMenuEvent(event); |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | if (state() == QAbstractItemView::EditingState) { |
| 773 | QTableWidget::contextMenuEvent(event); |
| 774 | return; |
| 775 | } |
| 776 | |
| 777 | if (event->modifiers() & Qt::AltModifier) { |
| 778 | // Suppress the context menu so Alt + double-click can reach the existing trigger flow. |
| 779 | event->accept(); |
| 780 | return; |
| 781 | } |
| 782 | |
| 783 | const QList<QTableWidgetSelectionRange> selectionRanges = selectedRanges(); |
| 784 | const bool hasSelection = !selectionRanges.isEmpty(); |
| 785 | const bool hasCopiedItems = !QMappingSequenceEdit::s_CopiedMappingSequenceList.isEmpty(); |
| 786 | const bool hasSingleCopiedItem = (QMappingSequenceEdit::s_CopiedMappingSequenceList.size() == 1); |
| 787 | QTableWidgetItem *current = currentItem(); |
| 788 | |
| 789 | bool hasSingleSelectedRow = false; |
| 790 | if (selectionRanges.size() == 1) { |
| 791 | const QTableWidgetSelectionRange range = selectionRanges.first(); |
| 792 | hasSingleSelectedRow = (range.topRow() == range.bottomRow() |
| 793 | && range.topRow() >= 0 |
| 794 | && range.topRow() < rowCount()); |
| 795 | } |
| 796 | |
| 797 | const auto canEditCurrentItem = [this, &selectionRanges, current]() -> bool { |
| 798 | if (selectionRanges.isEmpty() || !current) { |
| 799 | return false; |
| 800 | } |
| 801 | |
| 802 | const int r = current->row(); |
| 803 | const int c = current->column(); |
| 804 | if (r < 0 || r >= rowCount() || c < 0 || c >= columnCount()) { |
| 805 | return false; |
| 806 | } |
| 807 | |
| 808 | return current->flags() & Qt::ItemIsEditable; |
| 809 | }; |
| 810 | |
| 811 | const auto canLoadCurrentItem = [this, &selectionRanges, current]() -> bool { |
| 812 | if (selectionRanges.isEmpty() || !current) { |
| 813 | return false; |
| 814 | } |
| 815 | |
| 816 | const int r = current->row(); |
| 817 | const int c = current->column(); |
| 818 | return (r >= 0 && r < rowCount() && c >= 0 && c < columnCount()); |
| 819 | }; |
| 820 | |
| 821 | QMenu contextMenu(this); |
nothing calls this directly
no test coverage detected