]> git.siccegge.de Git - frida/frida.git/commitdiff
Renaming functions
authorChristoph Egger <Christoph.Egger@fau.de>
Mon, 16 Feb 2015 12:16:03 +0000 (13:16 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Mon, 16 Feb 2015 12:17:01 +0000 (13:17 +0100)
It's now possible to arbitrarily rename functions. Currently only the
name displayed in the sidebar is updated.

CMakeLists.txt
src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx
src/gui/dialogs/RenameFunctionDialog.cxx [new file with mode: 0644]
src/gui/dialogs/RenameFunctionDialog.hxx [new file with mode: 0644]

index 5b42ebe56fe1abe0a911d52a514fb837b4e738dc..1d811d5fba00392068223496f2bc79183d70b48a 100644 (file)
@@ -47,6 +47,7 @@ SET(frida_SOURCES
   src/gui/widgets/CFGScene.cxx
   src/gui/widgets/ScriptingDock.cxx
   src/gui/dialogs/NewFunctionDialog.cxx
+  src/gui/dialogs/RenameFunctionDialog.cxx
   src/disassembler/Disassembler.cxx
   src/disassembler/llvm/LLVMDisassembler.cxx
   )
@@ -59,6 +60,7 @@ SET(frida_HEADERS
   src/gui/widgets/CFGScene.hxx
   src/gui/widgets/ScriptingDock.hxx
   src/gui/dialogs/NewFunctionDialog.hxx
+  src/gui/dialogs/RenameFunctionDialog.hxx
   src/disassembler/llvm/LLVMDisassembler.hxx
   src/disassembler/Disassembler.hxx
   )
index 0f2486ddc13e2ed82227107d0f791368f82bb8b6..611f3da62822307dc1043944f944f6a079a60ed0 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "widgets/CFGScene.hxx"
 #include "dialogs/NewFunctionDialog.hxx"
+#include "dialogs/RenameFunctionDialog.hxx"
 
 #include <sstream>
 
@@ -99,15 +100,15 @@ void Mainwindow::switchMainPlane(int index) {
 
 void Mainwindow::showListContextMenu(const QPoint& point) {
        QListWidgetItem * item = listWidget->itemAt(point);
+       QMenu menu(this);
        if (item) {
-               LOG4CXX_DEBUG(logger, "WOHO " << item->text().toStdString());
+               QAction * act = menu.addAction("Rename Function");
+               connect(act, &QAction::triggered, [=]() {this->renameFunction(item);});
        } else {
-               QMenu menu(this);
                QAction * act = menu.addAction("AddFunction");
                connect(act, SIGNAL(triggered()), this, SLOT(requestNewFunction()));
-
-               menu.exec(listWidget->mapToGlobal(point));
        }
+       menu.exec(listWidget->mapToGlobal(point));
 }
 
 void Mainwindow::requestNewFunction() {
@@ -121,6 +122,18 @@ void Mainwindow::requestNewFunction() {
        }
 }
 
+void Mainwindow::renameFunction(QListWidgetItem * item) {
+       RenameFunctionDialog dialog;
+       int result = dialog.exec();
+       if (QDialog::Accepted == result) {
+               LOG4CXX_DEBUG(logger, "renaming Function" << item->text().toStdString()
+                             << " to " << dialog.result().toStdString());
+               item->setText(dialog.result());
+       } else {
+               LOG4CXX_DEBUG(logger, "renameFunction aborted");
+       }
+}
+
 void Mainwindow::addFunction(Function* fun) {
        if (functions.find(fun) != functions.end())
                return;
index 14d41b3fa6ebe46ae8ea035f0ea739c53927d037..a78b44617f5ee7d4f8db3238045fb366d3362125 100644 (file)
@@ -54,6 +54,7 @@ private Q_SLOTS:
        void switchMainPlane(int);
        void showListContextMenu(const QPoint&);
        void requestNewFunction();
+       void renameFunction(QListWidgetItem * item);
 };
 
 #endif /* INCLUDE__Mainwindow_hxx_ */
diff --git a/src/gui/dialogs/RenameFunctionDialog.cxx b/src/gui/dialogs/RenameFunctionDialog.cxx
new file mode 100644 (file)
index 0000000..1cd6ceb
--- /dev/null
@@ -0,0 +1,26 @@
+#include "RenameFunctionDialog.hxx"
+
+RenameFunctionDialog::RenameFunctionDialog() {
+       QGridLayout * layout = new QGridLayout;
+
+       edit = new QLineEdit;
+       layout->addWidget(edit, 0, 0, 1, 2);
+
+       QPushButton * cancelButton = new QPushButton("Cancel");
+       QPushButton * okButton = new QPushButton("OK");
+       layout->addWidget(okButton, 1, 1, 1, 1);
+       connect(okButton, SIGNAL(clicked()),
+               this, SLOT(accept()));
+       layout->addWidget(cancelButton, 1, 0, 1, 1);
+       connect(cancelButton, SIGNAL(clicked()),
+               this, SLOT(reject()));
+
+       setLayout(layout);
+       setWindowTitle("Add function");
+}
+
+QString RenameFunctionDialog::result() {
+       bool ok;
+       QString result = edit->text();
+       return result;
+}
diff --git a/src/gui/dialogs/RenameFunctionDialog.hxx b/src/gui/dialogs/RenameFunctionDialog.hxx
new file mode 100644 (file)
index 0000000..8c02828
--- /dev/null
@@ -0,0 +1,11 @@
+#include "gui/qt.hxx"
+
+class RenameFunctionDialog : public QDialog {
+       Q_OBJECT
+public:
+       RenameFunctionDialog();
+
+       QString result();
+private:
+       QLineEdit * edit;
+};