X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2FMainwindow.cxx;h=fe48f8fd38cb4d0af385844466fc7e1921d5c22a;hp=0c08892642dd760b4f5e611254e9c8c67de2467e;hb=eaea9a6612e5dc13b5fda28e943e632e3de713da;hpb=ccde95277ce5e3929d09aef387c2f5956592d066;ds=sidebyside diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 0c08892..fe48f8f 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -44,7 +44,8 @@ Mainwindow::Mainwindow(InformationManager* mgr) scripting->setAllowedAreas(Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, scripting); - listWidget = new QListWidget(); + listWidget = new QTreeWidget(); + listWidget->setColumnCount(1); listWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(listWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showListContextMenu(const QPoint&))); @@ -57,15 +58,20 @@ Mainwindow::Mainwindow(InformationManager* mgr) addDockWidget(Qt::LeftDockWidgetArea, dockWidget); setCentralWidget(stackedWidget); - connect(listWidget, SIGNAL(currentRowChanged(int)), - this, SLOT(switchMainPlane(int))); + connect(listWidget, &QTreeWidget::currentItemChanged, + [=] (QTreeWidgetItem* current, QTreeWidgetItem*) { + switchMainPlane(current); + }); setWindowTitle(tr("FRIDA")); + QTreeWidgetItem * external = new QTreeWidgetItem(listWidget, QStringList("External Functions")); + external->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); + external->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd))); mgr->connect_new_function_signal([&] (Function* fun) {addFunction(fun);}); - mgr->connect_new_dyn_symbol_signal([&] (const std::string& name) { - auto item = new QListWidgetItem(name.c_str(), listWidget); - item->setBackground(QBrush(QColor(0xff, 0xdd, 0xdd))); + mgr->connect_new_dyn_symbol_signal([=] (const std::string& name) { + auto item = new QTreeWidgetItem(external, QStringList(name.c_str())); + item->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd))); }); setGlobalHotkeys(); } @@ -76,7 +82,7 @@ void Mainwindow::setGlobalHotkeys() { shortcut = new QShortcut(QKeySequence("r"), listWidget); connect(shortcut, &QShortcut::activated, [=]() { - QListWidgetItem * item = listWidget->currentItem(); + QTreeWidgetItem * item = listWidget->currentItem(); if (item) renameFunction(objects_list[item]->getFunction()); }); } @@ -107,7 +113,7 @@ void Mainwindow::save() { void Mainwindow::switchMainPlaneToAddress(uint64_t address) { if (objects_list_by_address.find(address) != objects_list_by_address.end()) { LOG4CXX_DEBUG(logger, "Switching to function " << std::hex << address); - QListWidgetItem * item = objects_list_by_address[address]; + QTreeWidgetItem * item = objects_list_by_address[address]; listWidget->setCurrentItem(item); stackedWidget->setCurrentWidget(objects_list[item]); } else { @@ -116,12 +122,13 @@ void Mainwindow::switchMainPlaneToAddress(uint64_t address) { } } -void Mainwindow::switchMainPlane(int) { - stackedWidget->setCurrentWidget(objects_list[listWidget->currentItem()]); +void Mainwindow::switchMainPlane(QTreeWidgetItem* to) { + if (objects_list.end() != objects_list.find(to)) + stackedWidget->setCurrentWidget(objects_list[to]); } void Mainwindow::showListContextMenu(const QPoint& point) { - QListWidgetItem * item = listWidget->itemAt(point); + QTreeWidgetItem * item = listWidget->itemAt(point); QMenu menu(this); if (item) { QAction * act = menu.addAction("Rename Function"); @@ -156,7 +163,7 @@ void Mainwindow::renameFunction(Function* function) { LOG4CXX_DEBUG(logger, "renaming Function " << function->getName() << " to " << dialog.result().toStdString()); function->setName(dialog.result().toStdString()); - objects_list_by_address[function->getStartAddress()]->setText(dialog.result()); + objects_list_by_address[function->getStartAddress()]->setText(0, dialog.result()); } else { LOG4CXX_DEBUG(logger, "renameFunction aborted"); } @@ -194,7 +201,7 @@ void Mainwindow::addFunction(Function* fun) { w->addTab(t, "Listing"); - QListWidgetItem * item = new QListWidgetItem(fun->getName().c_str(), listWidget); + 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