mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 21:35:28 +00:00
Finish EditMethodDialog
This commit is contained in:
parent
7bdc28d07d
commit
1864e7b95d
@ -1,16 +1,22 @@
|
||||
#include "EditMethodDialog.h"
|
||||
#include "ui_EditMethodDialog.h"
|
||||
|
||||
EditMethodDialog::EditMethodDialog(QWidget *parent) :
|
||||
EditMethodDialog::EditMethodDialog(bool classFixed, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::EditMethodDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
|
||||
ui->classComboBox->clear();
|
||||
if (classFixed) {
|
||||
classLabel = new QLabel(this);
|
||||
ui->formLayout->setItem(0, QFormLayout::FieldRole, new QWidgetItem(classLabel));
|
||||
} else {
|
||||
classComboBox = new QComboBox(this);
|
||||
ui->formLayout->setItem(0, QFormLayout::FieldRole, new QWidgetItem(classComboBox));
|
||||
for (auto &cls : Core()->getAllAnalClasses()) {
|
||||
ui->classComboBox->addItem(cls, cls);
|
||||
classComboBox->addItem(cls, cls);
|
||||
}
|
||||
}
|
||||
|
||||
updateVirtualUI();
|
||||
@ -58,18 +64,23 @@ bool EditMethodDialog::inputValid()
|
||||
|
||||
void EditMethodDialog::setClass(const QString &className)
|
||||
{
|
||||
if (classComboBox) {
|
||||
if (className.isEmpty()) {
|
||||
ui->classComboBox->setCurrentIndex(0);
|
||||
classComboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i<ui->classComboBox->count(); i++) {
|
||||
QString cls = ui->classComboBox->itemData(i).toString();
|
||||
for (int i=0; i<classComboBox->count(); i++) {
|
||||
QString cls = classComboBox->itemData(i).toString();
|
||||
if (cls == className) {
|
||||
ui->classComboBox->setCurrentIndex(i);
|
||||
classComboBox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
classLabel->setText(className);
|
||||
fixedClass = className;
|
||||
}
|
||||
|
||||
validateInput();
|
||||
}
|
||||
@ -93,11 +104,15 @@ void EditMethodDialog::setMethod(const AnalMethodDescription &desc)
|
||||
|
||||
QString EditMethodDialog::getClass()
|
||||
{
|
||||
int index = ui->classComboBox->currentIndex();
|
||||
if (classComboBox) {
|
||||
int index = classComboBox->currentIndex();
|
||||
if (index < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return ui->classComboBox->itemData(index).value<BinClassDescription>().name;
|
||||
return classComboBox->itemData(index).toString();
|
||||
} else {
|
||||
return fixedClass;
|
||||
}
|
||||
}
|
||||
|
||||
AnalMethodDescription EditMethodDialog::getMethod()
|
||||
@ -105,7 +120,7 @@ AnalMethodDescription EditMethodDialog::getMethod()
|
||||
AnalMethodDescription ret;
|
||||
ret.name = ui->nameEdit->text();
|
||||
ret.addr = Core()->num(ui->addressEdit->text());
|
||||
if (ui->virtualCheckBox->isChecked()) {
|
||||
if (!ui->virtualCheckBox->isChecked()) {
|
||||
ret.vtableOffset = -1;
|
||||
} else {
|
||||
ret.vtableOffset = Core()->num(ui->vtableOffsetEdit->text());
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define EDITMETHODDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QComboBox>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Cutter.h"
|
||||
@ -15,7 +17,7 @@ class EditMethodDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditMethodDialog(QWidget *parent = nullptr);
|
||||
explicit EditMethodDialog(bool classFixed, QWidget *parent = nullptr);
|
||||
~EditMethodDialog();
|
||||
|
||||
void setClass(const QString &className);
|
||||
@ -38,6 +40,10 @@ private slots:
|
||||
private:
|
||||
std::unique_ptr<Ui::EditMethodDialog> ui;
|
||||
|
||||
QComboBox *classComboBox = nullptr;
|
||||
QLabel *classLabel = nullptr;
|
||||
QString fixedClass;
|
||||
|
||||
bool inputValid();
|
||||
};
|
||||
|
||||
|
@ -26,9 +26,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="classComboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
|
@ -224,6 +224,7 @@ AnalClassesModel::AnalClassesModel(QObject *parent)
|
||||
void AnalClassesModel::refreshClasses()
|
||||
{
|
||||
beginResetModel();
|
||||
attrs->clear();
|
||||
classes = Core()->getAllAnalClasses();
|
||||
endResetModel();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user