mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 18:38:51 +00:00
Add FlagsWidget Context Menu
This commit is contained in:
parent
6b7a5c9227
commit
cd28e00bb5
@ -324,6 +324,12 @@ void CutterCore::delFlag(RVA addr)
|
||||
emit flagsChanged();
|
||||
}
|
||||
|
||||
void CutterCore::delFlag(const QString &name)
|
||||
{
|
||||
cmdRaw("f-" + name);
|
||||
emit flagsChanged();
|
||||
}
|
||||
|
||||
void CutterCore::editInstruction(RVA addr, const QString &inst)
|
||||
{
|
||||
cmd("wa " + inst + " @ " + RAddressString(addr));
|
||||
|
@ -305,6 +305,7 @@ public:
|
||||
void delFunction(RVA addr);
|
||||
void renameFlag(QString old_name, QString new_name);
|
||||
void delFlag(RVA addr);
|
||||
void delFlag(const QString &name);
|
||||
|
||||
void editInstruction(RVA addr, const QString &inst);
|
||||
void nopInstruction(RVA addr);
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include <QDockWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QComboBox>
|
||||
#include <QMenu>
|
||||
|
||||
#include "FlagsWidget.h"
|
||||
#include "ui_FlagsWidget.h"
|
||||
#include "MainWindow.h"
|
||||
#include "dialogs/RenameDialog.h"
|
||||
#include "utils/Helpers.h"
|
||||
|
||||
FlagsModel::FlagsModel(QList<FlagDescription> *flags, QObject *parent)
|
||||
@ -139,6 +142,9 @@ FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
|
||||
|
||||
setScrollMode();
|
||||
|
||||
ui->flagsTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->flagsTreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &)));
|
||||
|
||||
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(flagsChanged()));
|
||||
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshFlagspaces()));
|
||||
}
|
||||
@ -158,6 +164,35 @@ void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1)
|
||||
refreshFlags();
|
||||
}
|
||||
|
||||
void FlagsWidget::on_actionRename_triggered()
|
||||
{
|
||||
FlagDescription flag = ui->flagsTreeView->selectionModel()->currentIndex().data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();
|
||||
|
||||
RenameDialog *r = new RenameDialog(this);
|
||||
r->setName(flag.name);
|
||||
if (r->exec())
|
||||
{
|
||||
QString new_name = r->getName();
|
||||
CutterCore::getInstance()->renameFlag(flag.name, new_name);
|
||||
}
|
||||
}
|
||||
|
||||
void FlagsWidget::on_actionDelete_triggered()
|
||||
{
|
||||
FlagDescription flag = ui->flagsTreeView->selectionModel()->currentIndex().data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();
|
||||
Core()->delFlag(flag.name);
|
||||
}
|
||||
|
||||
void FlagsWidget::showContextMenu(const QPoint &pt)
|
||||
{
|
||||
QMenu *menu = new QMenu(ui->flagsTreeView);
|
||||
menu->addAction(ui->actionRename);
|
||||
menu->addAction(ui->actionDelete);
|
||||
menu->exec(ui->flagsTreeView->mapToGlobal(pt));
|
||||
delete menu;
|
||||
}
|
||||
|
||||
|
||||
void FlagsWidget::flagsChanged()
|
||||
{
|
||||
refreshFlagspaces();
|
||||
|
@ -69,6 +69,11 @@ private slots:
|
||||
void on_flagsTreeView_doubleClicked(const QModelIndex &index);
|
||||
void on_flagspaceCombo_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_actionRename_triggered();
|
||||
void on_actionDelete_triggered();
|
||||
|
||||
void showContextMenu(const QPoint &pt);
|
||||
|
||||
void flagsChanged();
|
||||
void refreshFlagspaces();
|
||||
|
||||
|
@ -94,6 +94,16 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<action name="actionRename">
|
||||
<property name="text">
|
||||
<string>Rename</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user