]> git.siccegge.de Git - frida/frida.git/commitdiff
Allow creation of custom groups
authorChristoph Egger <Christoph.Egger@fau.de>
Wed, 4 Mar 2015 14:42:01 +0000 (15:42 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Wed, 4 Mar 2015 14:42:01 +0000 (15:42 +0100)
Users can now create Groups of functions and move individual functions
there

src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx

index a15aa66eb299da46b1f5a3da3735fa9c95849813..10046bab3ef862b090cbc3de77036608a00d575f 100644 (file)
@@ -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);
index a3bd4bdfa88ff354c0ee09a557ceb4d6d8c668c3..7e9cb3a975b8fc3c92102b098975a8794272724d 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <memory>
 #include <map>
+#include <vector>
 
 #include <QTextEdit>
 #include <QPushButton>
@@ -50,6 +51,7 @@ private:
        std::map<uint64_t, Function*> functions;
        std::map<QTreeWidgetItem*, FunctionWidget*> objects_list;
        std::map<uint64_t, QTreeWidgetItem*> objects_list_by_address;
+       std::vector<QTreeWidgetItem*> 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);
 };