From: Christoph Egger Date: Wed, 4 Mar 2015 14:42:01 +0000 (+0100) Subject: Allow creation of custom groups X-Git-Tag: v0.1~75 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=acc34914344962b8af7656c54cd442dad1341c92;p=frida%2Ffrida.git Allow creation of custom groups Users can now create Groups of functions and move individual functions there --- diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index a15aa66..10046ba 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -128,15 +128,31 @@ 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"); + act = menu.addAction("Rename Function"); connect(act, &QAction::triggered, [=]() {this->renameFunction(objects_list[item]->getFunction());}); - } - 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 +167,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); diff --git a/src/gui/Mainwindow.hxx b/src/gui/Mainwindow.hxx index a3bd4bd..7e9cb3a 100644 --- a/src/gui/Mainwindow.hxx +++ b/src/gui/Mainwindow.hxx @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -50,6 +51,7 @@ private: std::map functions; std::map objects_list; std::map objects_list_by_address; + std::vector group_list; InformationManager* manager; log4cxx::LoggerPtr logger; @@ -61,6 +63,7 @@ private Q_SLOTS: void switchMainPlane(QTreeWidgetItem* item); void showListContextMenu(const QPoint&); void requestNewFunction(); + void requestNewGroup(); void renameFunction(Function* function); };