diff --git a/ui/registerswidget.cpp b/ui/registerswidget.cpp index 9040485..8d3f732 100644 --- a/ui/registerswidget.cpp +++ b/ui/registerswidget.cpp @@ -453,6 +453,11 @@ DebugRegistersWidget::DebugRegistersWidget(ViewFrame* view, BinaryViewRef data, m_menu->addAction(actionName, "Options", MENU_ORDER_FIRST); m_actionHandler.bindAction(actionName, UIAction([=]() { jump(); }, [&]() { return selectionNotEmpty(); })); + actionName = QString::fromStdString("Jump to Address in New Pane"); + UIAction::registerAction(actionName); + m_menu->addAction(actionName, "Options", MENU_ORDER_FIRST); + m_actionHandler.bindAction(actionName, UIAction([=]() { jumpInNewPane(); }, [&]() { return selectionNotEmpty(); })); + m_menu->addAction("Copy", "Options", MENU_ORDER_NORMAL); m_actionHandler.bindAction("Copy", UIAction([&]() { copy(); }, [&]() { return selectionNotEmpty(); })); m_actionHandler.setActionDisplayName("Copy", [&]() { @@ -577,6 +582,16 @@ void DebugRegistersWidget::jump() } +void DebugRegistersWidget::jumpInNewPane() +{ + QModelIndexList sel = selectionModel()->selectedIndexes(); + if (sel.empty()) + return; + + jumpInNewPaneInternal(sel[0]); +} + + void DebugRegistersWidget::copy() { QModelIndexList sel = selectionModel()->selectedIndexes(); @@ -668,46 +683,52 @@ void DebugRegistersWidget::onDoubleClicked() } -void DebugRegistersWidget::mousePressEvent(QMouseEvent *event) +void DebugRegistersWidget::jumpInNewPaneInternal(const QModelIndex &index) { - startHoverTimer(event); + if (!index.isValid()) + return; - if (event->button() == Qt::MiddleButton) + auto sourceIndex = m_filter->mapToSource(index); + if (!sourceIndex.isValid()) + return; + + auto reg = m_model->getRow(sourceIndex.row()); + uint64_t value = reg.value(); + + ViewFrame* frame = ViewFrame::viewFrameForWidget(this); + auto* currentWindow = UIContext::contextForWidget(m_view); + if (frame && currentWindow) { - auto index = indexAt(event->pos()); - if (!index.isValid()) + auto* splitPaneWidget = qobject_cast(currentWindow->getCurrentTab()); + if (!splitPaneWidget) return; - auto sourceIndex = m_filter->mapToSource(index); - if (!sourceIndex.isValid()) - return; + Qt::Orientation defaultSplitDirection = splitPaneWidget->defaultSplitDirection(); + splitPaneWidget->splitCurrentPane(defaultSplitDirection); - auto reg = m_model->getRow(sourceIndex.row()); - uint64_t value = reg.value(); + ViewPane* newPane = splitPaneWidget->currentViewPane(); - ViewFrame* frame = ViewFrame::viewFrameForWidget(this); - auto* currentWindow = UIContext::contextForWidget(m_view); - if (frame && currentWindow) - { - auto* splitPaneWidget = qobject_cast(currentWindow->getCurrentTab()); - if (!splitPaneWidget) - return; + if (!newPane) + return; - Qt::Orientation defaultSplitDirection = splitPaneWidget->defaultSplitDirection(); - splitPaneWidget->splitCurrentPane(defaultSplitDirection); + ViewFrame* newViewFrame = newPane->viewFrame(); + if (newViewFrame) + { + newViewFrame->disableSync(); + newViewFrame->navigate(m_controller->GetLiveView(), value); + } + } +} - ViewPane* newPane = splitPaneWidget->currentViewPane(); - if (!newPane) - return; +void DebugRegistersWidget::mousePressEvent(QMouseEvent *event) +{ + startHoverTimer(event); - ViewFrame* newViewFrame = newPane->viewFrame(); - if (newViewFrame) - { - newViewFrame->disableSync(); - newViewFrame->navigate(m_controller->GetLiveView(), value); - } - } + if (event->button() == Qt::MiddleButton) + { + auto index = indexAt(event->pos()); + jumpInNewPaneInternal(index); } else { diff --git a/ui/registerswidget.h b/ui/registerswidget.h index 45fc50b..aed6846 100644 --- a/ui/registerswidget.h +++ b/ui/registerswidget.h @@ -185,6 +185,7 @@ class DebugRegistersWidget : public QTableView, public FilterTarget virtual void activateFirstItem() override; void updateColumnWidths(); + void jumpInNewPaneInternal(const QModelIndex& index); void startHoverTimer(QMouseEvent* event); @@ -196,6 +197,7 @@ class DebugRegistersWidget : public QTableView, public FilterTarget private slots: void setToZero(); void jump(); + void jumpInNewPane(); void copy(); void paste(); void editValue();