Add X-Refs context menu item for Flags Widget (#1499)

* add xrefs for flags
This commit is contained in:
Itay Cohen 2019-05-01 23:25:33 +03:00 committed by GitHub
parent 089be2b87c
commit f2cd0053a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include "ui_FlagsWidget.h" #include "ui_FlagsWidget.h"
#include "core/MainWindow.h" #include "core/MainWindow.h"
#include "dialogs/RenameDialog.h" #include "dialogs/RenameDialog.h"
#include "dialogs/XrefsDialog.h"
#include "common/Helpers.h" #include "common/Helpers.h"
#include <QComboBox> #include <QComboBox>
@ -150,6 +151,11 @@ FlagsWidget::FlagsWidget(MainWindow *main, QAction *action) :
tree->showItemsNumber(flags_proxy_model->rowCount()); tree->showItemsNumber(flags_proxy_model->rowCount());
}); });
auto xRefShortcut = new QShortcut(QKeySequence{Qt::CTRL + Qt::Key_X}, this);
xRefShortcut->setContext(Qt::WidgetWithChildrenShortcut);
ui->actionXrefs->setShortcut(Qt::CTRL + Qt::Key_X);
connect(xRefShortcut, SIGNAL(activated()), this, SLOT(on_actionXrefs_triggered()));
setScrollMode(); setScrollMode();
ui->flagsTreeView->setContextMenuPolicy(Qt::CustomContextMenu); ui->flagsTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
@ -198,11 +204,23 @@ void FlagsWidget::on_actionDelete_triggered()
Core()->delFlag(flag.name); Core()->delFlag(flag.name);
} }
void FlagsWidget::on_actionXrefs_triggered()
{
FlagDescription flag = ui->flagsTreeView->selectionModel()->currentIndex().data(
FlagsModel::FlagDescriptionRole).value<FlagDescription>();
XrefsDialog xresfDialog(nullptr);
xresfDialog.fillRefsForAddress(flag.offset, RAddressString(flag.offset), false);
xresfDialog.exec();
}
void FlagsWidget::showContextMenu(const QPoint &pt) void FlagsWidget::showContextMenu(const QPoint &pt)
{ {
QMenu *menu = new QMenu(ui->flagsTreeView); QMenu *menu = new QMenu(ui->flagsTreeView);
menu->addAction(ui->actionRename); menu->addAction(ui->actionRename);
menu->addAction(ui->actionDelete); menu->addAction(ui->actionDelete);
menu->addSeparator();
menu->addAction(ui->actionXrefs);
menu->exec(ui->flagsTreeView->mapToGlobal(pt)); menu->exec(ui->flagsTreeView->mapToGlobal(pt));
delete menu; delete menu;
} }

View File

@ -71,6 +71,7 @@ private slots:
void on_actionRename_triggered(); void on_actionRename_triggered();
void on_actionDelete_triggered(); void on_actionDelete_triggered();
void on_actionXrefs_triggered();
void showContextMenu(const QPoint &pt); void showContextMenu(const QPoint &pt);

View File

@ -98,11 +98,28 @@
<property name="text"> <property name="text">
<string>Rename</string> <string>Rename</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action> </action>
<action name="actionDelete"> <action name="actionDelete">
<property name="text"> <property name="text">
<string>Delete</string> <string>Delete</string>
</property> </property>
<property name="shortcut">
<string>Del</string>
</property>
</action>
<action name="actionXrefs">
<property name="text">
<string>X-Refs</string>
</property>
<property name="toolTip">
<string>Show X-Refs of this flag</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action> </action>
</widget> </widget>
<customwidgets> <customwidgets>