From 2b057d0cd0501832d789b31551192e7e4202f4ca Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Wed, 4 Mar 2015 16:20:17 +0100 Subject: [PATCH] Support for Renaming Groups --- src/gui/Mainwindow.cxx | 22 ++++++++++++++++++++-- src/gui/Mainwindow.hxx | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 10046ba..3b805d5 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -139,8 +139,14 @@ void Mainwindow::showListContextMenu(const QPoint& point) { 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"); @@ -198,6 +204,18 @@ void Mainwindow::renameFunction(Function* function) { } } +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; diff --git a/src/gui/Mainwindow.hxx b/src/gui/Mainwindow.hxx index 7e9cb3a..3a2e10d 100644 --- a/src/gui/Mainwindow.hxx +++ b/src/gui/Mainwindow.hxx @@ -65,6 +65,7 @@ private Q_SLOTS: void requestNewFunction(); void requestNewGroup(); void renameFunction(Function* function); + void renameGroup(QTreeWidgetItem* item); }; #endif /* INCLUDE__Mainwindow_hxx_ */ -- 2.39.5