mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-23 06:54:49 +00:00
Xrefs enhancement (#2362)
* Add number of found results to xrefs dialog * Hide xref from if the item is not an VA
This commit is contained in:
parent
8f5fbeddde
commit
2cfa4916c3
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
|
XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent, bool hideXrefFrom) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
addr(0),
|
addr(0),
|
||||||
toModel(this),
|
toModel(this),
|
||||||
@ -52,6 +52,10 @@ XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
|
|||||||
|
|
||||||
connect(ui->toTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
connect(ui->toTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
||||||
connect(ui->fromTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
connect(ui->fromTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
||||||
|
|
||||||
|
if (hideXrefFrom) {
|
||||||
|
hideXrefFromSection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XrefsDialog::~XrefsDialog() { }
|
XrefsDialog::~XrefsDialog() { }
|
||||||
@ -134,8 +138,8 @@ void XrefsDialog::updatePreview(RVA addr)
|
|||||||
|
|
||||||
void XrefsDialog::updateLabels(QString name)
|
void XrefsDialog::updateLabels(QString name)
|
||||||
{
|
{
|
||||||
ui->label_xTo->setText(tr("X-Refs to %1:").arg(name));
|
ui->label_xTo->setText(tr("X-Refs to %1 (%2 results):").arg(name).arg(toModel.rowCount()));
|
||||||
ui->label_xFrom->setText(tr("X-Refs from %1:").arg(name));
|
ui->label_xFrom->setText(tr("X-Refs from %1 (%2 results):").arg(name).arg(fromModel.rowCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XrefsDialog::updateLabelsForVariables(QString name)
|
void XrefsDialog::updateLabelsForVariables(QString name)
|
||||||
@ -144,14 +148,21 @@ void XrefsDialog::updateLabelsForVariables(QString name)
|
|||||||
ui->label_xFrom->setText(tr("Reads from %1").arg(name));
|
ui->label_xFrom->setText(tr("Reads from %1").arg(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XrefsDialog::hideXrefFromSection()
|
||||||
|
{
|
||||||
|
ui->label_xFrom->hide();
|
||||||
|
ui->fromTreeWidget->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void XrefsDialog::fillRefsForAddress(RVA addr, QString name, bool whole_function)
|
void XrefsDialog::fillRefsForAddress(RVA addr, QString name, bool whole_function)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("X-Refs for %1").arg(name));
|
setWindowTitle(tr("X-Refs for %1").arg(name));
|
||||||
updateLabels(name);
|
|
||||||
|
|
||||||
toModel.readForOffset(addr, true, whole_function);
|
toModel.readForOffset(addr, true, whole_function);
|
||||||
fromModel.readForOffset(addr, false, whole_function);
|
fromModel.readForOffset(addr, false, whole_function);
|
||||||
|
|
||||||
|
updateLabels(name);
|
||||||
|
|
||||||
// Adjust columns to content
|
// Adjust columns to content
|
||||||
qhelpers::adjustColumns(ui->fromTreeWidget, fromModel.columnCount(), 0);
|
qhelpers::adjustColumns(ui->fromTreeWidget, fromModel.columnCount(), 0);
|
||||||
qhelpers::adjustColumns(ui->toTreeWidget, toModel.columnCount(), 0);
|
qhelpers::adjustColumns(ui->toTreeWidget, toModel.columnCount(), 0);
|
||||||
|
@ -44,7 +44,7 @@ class XrefsDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit XrefsDialog(MainWindow *main, QWidget *parent);
|
explicit XrefsDialog(MainWindow *main, QWidget *parent, bool hideXrefFrom=false);
|
||||||
~XrefsDialog();
|
~XrefsDialog();
|
||||||
|
|
||||||
void fillRefsForAddress(RVA addr, QString name, bool whole_function);
|
void fillRefsForAddress(RVA addr, QString name, bool whole_function);
|
||||||
@ -78,6 +78,7 @@ private:
|
|||||||
void updateLabels(QString name);
|
void updateLabels(QString name);
|
||||||
void updateLabelsForVariables(QString name);
|
void updateLabelsForVariables(QString name);
|
||||||
void updatePreview(RVA addr);
|
void updatePreview(RVA addr);
|
||||||
|
void hideXrefFromSection();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XREFSDIALOG_H
|
#endif // XREFSDIALOG_H
|
||||||
|
@ -85,7 +85,7 @@ void AddressableItemContextMenu::onActionCopyAddress()
|
|||||||
void AddressableItemContextMenu::onActionShowXrefs()
|
void AddressableItemContextMenu::onActionShowXrefs()
|
||||||
{
|
{
|
||||||
emit xrefsTriggered();
|
emit xrefsTriggered();
|
||||||
XrefsDialog dialog(mainWindow, nullptr);
|
XrefsDialog dialog(mainWindow, nullptr, true);
|
||||||
QString tmpName = name;
|
QString tmpName = name;
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name = RAddressString(offset);
|
name = RAddressString(offset);
|
||||||
|
Loading…
Reference in New Issue
Block a user