Skip to content

Commit 112b1ed

Browse files
committed
Add a modal dialog option for cross references
1 parent 0cf8ae7 commit 112b1ed

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ui/xreflist.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QtWidgets/QCheckBox>
1616
#include <QtWidgets/QFrame>
1717
#include <QtWidgets/QGridLayout>
18+
#include <QtWidgets/QDialog>
1819

1920
#include <vector>
2021
#include <deque>
@@ -534,6 +535,7 @@ class BINARYNINJAUIAPI CrossReferenceContainer
534535
virtual QModelIndex nextIndex() = 0;
535536
virtual QModelIndex prevIndex() = 0;
536537
virtual QModelIndexList selectedRows() const = 0;
538+
virtual void setSavedSelection(std::optional<int> idx) = 0;
537539
virtual bool hasSelection() const = 0;
538540
virtual void setNewSelection(std::vector<XrefItem>& refs, bool newRefTarget, const SelectionInfoForXref& ref,
539541
bool dependentRefsExceeded) = 0;
@@ -574,6 +576,7 @@ class BINARYNINJAUIAPI CrossReferenceTree : public QTreeView, public CrossRefere
574576
virtual void keyPressEvent(QKeyEvent* e) override;
575577
virtual bool event(QEvent* event) override;
576578
virtual QModelIndexList selectedRows() const override { return selectionModel()->selectedRows(); }
579+
virtual void setSavedSelection(std::optional<int> idx) override;
577580
virtual QModelIndex translateIndex(const QModelIndex& idx) const override { return m_model->mapToSource(idx); }
578581
virtual void updateFonts() override;
579582
virtual int leafCount() const override;
@@ -617,6 +620,7 @@ class BINARYNINJAUIAPI CrossReferenceTable : public QTableView, public CrossRefe
617620
virtual QModelIndex prevIndex() override;
618621
virtual bool hasSelection() const override { return selectionModel()->selectedRows().size() != 0; }
619622
virtual QModelIndexList selectedRows() const override { return selectionModel()->selectedRows(); }
623+
virtual void setSavedSelection(std::optional<int> idx) override;
620624
virtual bool getReference(const QModelIndex& idx, XrefItem** refPtr) const override;
621625
virtual void mouseMoveEvent(QMouseEvent* e) override;
622626
virtual void mousePressEvent(QMouseEvent* e) override;
@@ -704,6 +708,8 @@ class BINARYNINJAUIAPI CrossReferenceWidget : public SidebarWidget, public UICon
704708
virtual bool selectFirstRow();
705709
virtual bool hasSelection() const;
706710
virtual void goToReference(const QModelIndex& idx);
711+
QModelIndexList selectedRows() const;
712+
void setSavedSelection(std::optional<int> idx);
707713

708714
virtual void restartHoverTimer(QMouseEvent* e);
709715
virtual void startHoverTimer(QMouseEvent* e);
@@ -741,6 +747,9 @@ public Q_SLOTS:
741747
void selectionChanged();
742748
void typeChanged(int index, bool checked);
743749
void directionChanged(int change, bool checked);
750+
751+
Q_SIGNALS:
752+
void navigatedToCrossReference();
744753
};
745754

746755
/*!
@@ -771,6 +780,23 @@ class BINARYNINJAUIAPI PinnedCrossReferenceSidebarWidgetType : public SidebarWid
771780
};
772781

773782

783+
class BINARYNINJAUIAPI CrossReferenceDialog : public QDialog
784+
{
785+
Q_OBJECT
786+
787+
CrossReferenceWidget* m_widget;
788+
789+
static constexpr int MINIMUM_WIDTH = 720;
790+
static constexpr int MINIMUM_HEIGHT = 480;
791+
792+
public:
793+
CrossReferenceDialog(UIContext* context, View* view, BinaryViewRef data, const SelectionInfoForXref& selection);
794+
795+
void setSavedSelection(std::optional<int> idx);
796+
std::optional<int> selection() const;
797+
};
798+
799+
774800
// https://github.com/CuriousCrow/QCheckboxCombo
775801
/*! QCheckboxCombo is a combobox widget that contains items with checkboxes.
776802

ui/xrefstate.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
#pragma once
22

3+
#include <QtCore/QModelIndex>
34
#include "binaryninjaapi.h"
45
#include "uicontext.h"
6+
#include "viewframe.h"
57

68
class SplitPaneContainer;
79
class SplitPaneWidget;
810

911
class BINARYNINJAUIAPI CrossReferenceState
1012
{
11-
std::map<SplitPaneContainer*, std::map<QString, SelectionInfoForXref>> m_curXref;
13+
struct Selection
14+
{
15+
SelectionInfoForXref selectionInfo;
16+
std::optional<int> previousDialogSelection;
17+
};
18+
19+
std::map<SplitPaneContainer*, std::map<QString, Selection>> m_selections;
1220
SplitPaneContainer* m_currentContainer = nullptr;
1321
QString m_currentDataType;
1422

1523
public:
1624
CrossReferenceState();
1725

1826
std::optional<SelectionInfoForXref> getCurrentSelection() const;
27+
std::optional<int> getPreviousDialogSelection() const;
1928

2029
void updateCrossReferences(ViewFrame* frame, const SelectionInfoForXref& selection);
2130
void beginNavigationForCrossReference(ViewFrame* frame, const SelectionInfoForXref& selection);
@@ -25,6 +34,8 @@ class BINARYNINJAUIAPI CrossReferenceState
2534

2635
void newPinnedTab();
2736
void newPinnedPane();
37+
void modalDialog();
38+
void focusSidebar();
2839

2940
void bindActions(UIContext* context);
3041
};

0 commit comments

Comments
 (0)