X-Git-Url: https://git.siccegge.de//index.cgi?a=blobdiff_plain;f=src%2Fgui%2FMainwindow.cxx;h=625e7acad7d99ae890ee650615b4600f86032b51;hb=2f0e025080dfcfa7c8f7395692502ab80d88ed65;hp=a15aa66eb299da46b1f5a3da3735fa9c95849813;hpb=34f333f55fd3577c06c8383e568cb32829a00ec1;p=frida%2Ffrida.git diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index a15aa66..625e7ac 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -27,12 +27,12 @@ Mainwindow::Mainwindow(InformationManager* mgr) saveAction = new QAction(tr("&Save"), this); exitAction = new QAction(tr("E&xit"), this); - connect(openAction, SIGNAL(triggered()), - this, SLOT(open())); - connect(saveAction, SIGNAL(triggered()), - this, SLOT(save())); - connect(exitAction, SIGNAL(triggered()), - qApp, SLOT(quit())); + connect(openAction, &QAction::triggered, + this, &Mainwindow::open); + connect(saveAction, &QAction::triggered, + this, &Mainwindow::save); + connect(exitAction, &QAction::triggered, + qApp, &QApplication::quit); fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(openAction); @@ -128,15 +128,37 @@ void Mainwindow::switchMainPlane(QTreeWidgetItem* to) { } void Mainwindow::showListContextMenu(const QPoint& point) { + QAction * act; QTreeWidgetItem * item = listWidget->itemAt(point); QMenu menu(this); + + act = menu.addAction("Add Function"); + connect(act, &QAction::triggered, this, &Mainwindow::requestNewFunction); + + act = menu.addAction("Add Group"); + connect(act, &QAction::triggered, this, &Mainwindow::requestNewGroup); + if (item) { - QAction * act = menu.addAction("Rename Function"); - connect(act, &QAction::triggered, [=]() {this->renameFunction(objects_list[item]->getFunction());}); - } + if (objects_list.find(item) != objects_list.end()) { + act = menu.addAction("Rename Function"); + connect(act, &QAction::triggered, [=]() {this->renameFunction(objects_list[item]->getFunction());}); + } else { + act = menu.addAction("Rename Group"); + connect(act, &QAction::triggered, [=]() {renameGroup(item);}); + } + - QAction * act = menu.addAction("AddFunction"); - connect(act, SIGNAL(triggered()), this, SLOT(requestNewFunction())); + QMenu* submenu = menu.addMenu("Move to group"); + + for (QTreeWidgetItem* groupitem : group_list) { + act = submenu->addAction(groupitem->text(0)); + connect(act, &QAction::triggered, + [=] () { + listWidget->invisibleRootItem()->removeChild(item); + groupitem->addChild(item); + }); + } + } menu.exec(listWidget->mapToGlobal(point)); } @@ -151,6 +173,18 @@ void Mainwindow::requestNewFunction() { } } +void Mainwindow::requestNewGroup() { + SimpleStringDialog dialog("New Group"); + int result = dialog.exec(); + if (QDialog::Accepted == result) { + QTreeWidgetItem * external = new QTreeWidgetItem(listWidget, QStringList(dialog.result())); + external->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); + group_list.push_back(external); + } else { + LOG4CXX_DEBUG(logger, "requestNewGroup aborted"); + } +} + void Mainwindow::requestNewFunctionByAddress(uint64_t address) { LOG4CXX_DEBUG(logger, "requesting Function at " << std::hex << address); manager->getDisassembler()->disassembleFunctionAt(address); @@ -170,6 +204,18 @@ void Mainwindow::renameFunction(Function* function) { } } +void Mainwindow::renameGroup(QTreeWidgetItem* item) { + SimpleStringDialog dialog("New name"); + int result = dialog.exec(); + if (QDialog::Accepted == result) { + LOG4CXX_DEBUG(logger, "renaming group " << item->text(0).toStdString() + << " to " << dialog.result().toStdString()); + item->setText(0, dialog.result()); + } else { + LOG4CXX_DEBUG(logger, "renameFunction aborted"); + } +} + void Mainwindow::addFunction(Function* fun) { if (functions.find(fun->getStartAddress()) != functions.end()) return;