connect(act, &QAction::triggered, this, &Mainwindow::requestNewGroup);
if (item) {
- act = menu.addAction("Rename Function");
- connect(act, &QAction::triggered, [=]() {this->renameFunction(objects_list[item]->getFunction());});
+ if (objects_list.find(item) != objects_list.end()) {
+ act = menu.addAction("Rename Function");
+ connect(act, &QAction::triggered, [=]() {this->renameFunction(objects_list[item]->getFunction());});
+ } else {
+ act = menu.addAction("Rename Group");
+ connect(act, &QAction::triggered, [=]() {renameGroup(item);});
+ }
+
QMenu* submenu = menu.addMenu("Move to group");
}
}
+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;