-void Mainwindow::populateSymbolInformation(const std::string& sym) {
- QTabWidget * w = new QTabWidget();
-
- // Listing
- QTableWidget * t = new QTableWidget();
- t->setColumnCount(3);
- t->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- curBin->for_each_instruction(sym, [&t](long add, std::string bytes, std::string mnemonic) {
- int row = t->rowCount();
- std::stringstream s;
- t->setRowCount(t->rowCount() + 1);
- s << std::hex << add;
- t->setItem(row,0,new QTableWidgetItem(s.str().c_str()));
- s.str("");
- s << std::hex;
- for_each(bytes.begin(), bytes.end(), [&s](char c){s << (unsigned int)((unsigned char)c) << ' ';});
- t->setItem(row,1,new QTableWidgetItem(s.str().c_str()));
- t->setItem(row,2,new QTableWidgetItem(mnemonic.c_str() + 1));
- });
- w->addTab(t, "Listing");
-
- // CFG
- QGraphicsScene * scene = new QGraphicsScene;
- QGraphicsRectItem *rect = scene->addRect(QRectF(0, 0, 100, 100));
- rect->setFlag(QGraphicsItem::ItemIsMovable);
- QGraphicsView * view = new QGraphicsView(scene);
- w->addTab(view, "CFG");
-
-
-
- listWidget->addItem(sym.c_str());
- stackedWidget->addWidget(w);
+void Mainwindow::requestNewFunction() {
+ NewFunctionDialog dialog;
+ int result = dialog.exec();
+ if (QDialog::Accepted == result) {
+ requestNewFunctionByAddress(dialog.result());
+ } else {
+ LOG4CXX_DEBUG(logger, "requestNewFunction aborted");
+ }
+}
+
+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);
+ switchMainPlaneToAddress(address);
+}
+
+void Mainwindow::renameFunction(Function* function) {
+ SimpleStringDialog dialog("New name");
+ int result = dialog.exec();
+ if (QDialog::Accepted == result) {
+ LOG4CXX_DEBUG(logger, "renaming Function " << function->getName()
+ << " to " << dialog.result().toStdString());
+ function->setName(dialog.result().toStdString());
+ } else {
+ LOG4CXX_DEBUG(logger, "renameFunction aborted");
+ }
+}
+
+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;
+
+ functions.insert(std::make_pair(fun->getStartAddress(), fun));
+
+ FunctionWidget * w = new FunctionWidget(fun, this);
+
+ QTreeWidgetItem * item = new QTreeWidgetItem(listWidget, QStringList(fun->getName().c_str()));
+ stackedWidget->addWidget(w);
+ objects_list.insert(std::make_pair(item, w));
+ LOG4CXX_DEBUG(logger, "Adding function widget at " << std::hex
+ << fun->getStartAddress());
+ objects_list_by_address.insert(std::make_pair(fun->getStartAddress(), item));