}
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));
}
}
}
+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);
#include <memory>
#include <map>
+#include <vector>
#include <QTextEdit>
#include <QPushButton>
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;
void switchMainPlane(QTreeWidgetItem* item);
void showListContextMenu(const QPoint&);
void requestNewFunction();
+ void requestNewGroup();
void renameFunction(Function* function);
};