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&)));
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();
}
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());
});
}
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 {
}
}
-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");
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");
}
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
#include <QTextEdit>
#include <QPushButton>
#include <QMainWindow>
-#include <QListWidget>
+#include <QTreeWidget>
#include <QStackedWidget>
#include <log4cxx/logger.h>
QMenu *fileMenu;
QTabWidget * tabwidget;
- QListWidget * listWidget;
+ QTreeWidget * listWidget;
QStackedWidget * stackedWidget;
QDockWidget * dockWidget;
ScriptingDock * scripting;
std::map<uint64_t, BasicBlockWidget*> blocks;
std::map<uint64_t, Function*> functions;
- std::map<QListWidgetItem*, FunctionWidget*> objects_list;
- std::map<uint64_t, QListWidgetItem*> objects_list_by_address;
+ std::map<QTreeWidgetItem*, FunctionWidget*> objects_list;
+ std::map<uint64_t, QTreeWidgetItem*> objects_list_by_address;
InformationManager* manager;
log4cxx::LoggerPtr logger;
void quit();
void open();
void save();
- void switchMainPlane(int);
+ void switchMainPlane(QTreeWidgetItem* item);
void showListContextMenu(const QPoint&);
void requestNewFunction();
void renameFunction(Function* function);