From ed28db50071c93f61d301880ecd735ae17302dd4 Mon Sep 17 00:00:00 2001 From: joern274 Date: Thu, 27 Jun 2024 13:15:56 +0200 Subject: [PATCH] 1.Added parameter to ModuleDialog 2.Bugfix ModuleModel --- plugins/gui/include/gui/module_dialog/module_dialog.h | 2 +- plugins/gui/src/graph_widget/graph_graphics_view.cpp | 4 ++-- plugins/gui/src/main_window/plugin_parameter_dialog.cpp | 2 +- plugins/gui/src/module_dialog/module_dialog.cpp | 4 ++-- plugins/gui/src/module_model/module_model.cpp | 6 +++++- plugins/gui/src/python/python_context.cpp | 2 +- .../gate_details_widget/gate_info_table.cpp | 2 +- .../module_details_widget/module_info_table.cpp | 2 +- .../selection_details_widget/selection_details_widget.cpp | 2 +- 9 files changed, 15 insertions(+), 11 deletions(-) diff --git a/plugins/gui/include/gui/module_dialog/module_dialog.h b/plugins/gui/include/gui/module_dialog/module_dialog.h index 409ee59e8fd..994d29807d1 100644 --- a/plugins/gui/include/gui/module_dialog/module_dialog.h +++ b/plugins/gui/include/gui/module_dialog/module_dialog.h @@ -69,7 +69,7 @@ namespace hal { * @param receiver - The receiver for graphical picker, picker will be hidden if nullptr * @param parent - The dialog's parent. */ - ModuleDialog(const QSet& excludeIds = {}, const QString& title=QString("Select module"), + ModuleDialog(const QSet& excludeIds = {}, const QString& title=QString("Select module"), bool omitCreateNew=false, ModuleSelectReceiver* receiver=nullptr, QWidget* parent=nullptr); /** diff --git a/plugins/gui/src/graph_widget/graph_graphics_view.cpp b/plugins/gui/src/graph_widget/graph_graphics_view.cpp index bc0768fa47b..a82806b6c0f 100644 --- a/plugins/gui/src/graph_widget/graph_graphics_view.cpp +++ b/plugins/gui/src/graph_widget/graph_graphics_view.cpp @@ -1029,7 +1029,7 @@ namespace hal // } // } - ModuleDialog module_dialog(getNotSelectableModules(),"Add module to view", nullptr, this); + ModuleDialog module_dialog(getNotSelectableModules(),"Add module to view", true, nullptr, this); if (module_dialog.exec() == QDialog::Accepted) { QSet module_to_add; @@ -1471,7 +1471,7 @@ namespace hal } AddToModuleReceiver* receiver = new AddToModuleReceiver(this); - ModuleDialog md(exclude_ids, "Move to module", receiver, this); + ModuleDialog md(exclude_ids, "Move to module", false, receiver, this); if (md.exec() != QDialog::Accepted) return; if (md.isNewModule()) { diff --git a/plugins/gui/src/main_window/plugin_parameter_dialog.cpp b/plugins/gui/src/main_window/plugin_parameter_dialog.cpp index b5c9c05544d..8fbd041683f 100644 --- a/plugins/gui/src/main_window/plugin_parameter_dialog.cpp +++ b/plugins/gui/src/main_window/plugin_parameter_dialog.cpp @@ -419,7 +419,7 @@ namespace hal { void PluginParameterNodeDialog::handleActivateModuleDialog() { - ModuleDialog md({}, "Select module", nullptr, this); + ModuleDialog md({}, "Select module", false, nullptr, this); if (md.exec() == QDialog::Accepted) { setModule(md.selectedId()); diff --git a/plugins/gui/src/module_dialog/module_dialog.cpp b/plugins/gui/src/module_dialog/module_dialog.cpp index 877da5fa2b1..4e2a651c25f 100644 --- a/plugins/gui/src/module_dialog/module_dialog.cpp +++ b/plugins/gui/src/module_dialog/module_dialog.cpp @@ -22,7 +22,7 @@ #include namespace hal { - ModuleDialog::ModuleDialog(const QSet& excludeIds, const QString &title, ModuleSelectReceiver* receiver, QWidget* parent) + ModuleDialog::ModuleDialog(const QSet& excludeIds, const QString &title, bool omitCreateNew, ModuleSelectReceiver* receiver, QWidget* parent) : QDialog(parent), mSelectedId(0), mExcludeIds(excludeIds), @@ -46,7 +46,7 @@ namespace hal { QPushButton* butSearch = new QPushButton("Search", this); connect(butSearch, &QPushButton::pressed, this, &ModuleDialog::handleToggleSearchbar); - if (title == "Add module to view") + if (omitCreateNew) { layout->addWidget(mButtonPick, 0, 0); layout->addWidget(butSearch, 0, 1); diff --git a/plugins/gui/src/module_model/module_model.cpp b/plugins/gui/src/module_model/module_model.cpp index 7763e37b833..e428195be7e 100644 --- a/plugins/gui/src/module_model/module_model.cpp +++ b/plugins/gui/src/module_model/module_model.cpp @@ -630,7 +630,11 @@ namespace hal while (itSubm != mModuleMap.upperBound(id)) { ModuleItem* submItem = itSubm.value(); - if (submItem->isToplevelItem()) continue; + if (submItem->isToplevelItem()) + { + ++itSubm; + continue; + } ModuleItem* oldParentItem = static_cast(submItem->getParent()); Q_ASSERT(oldParentItem); diff --git a/plugins/gui/src/python/python_context.cpp b/plugins/gui/src/python/python_context.cpp index be922a5b728..e3820e299f1 100644 --- a/plugins/gui/src/python/python_context.cpp +++ b/plugins/gui/src/python/python_context.cpp @@ -364,7 +364,7 @@ namespace hal QSet mods; if (gSelectionRelay->numberSelectedModules()) gSelectionRelay->clearAndUpdate(); PythonModuleSelectionReceiver* pms = new PythonModuleSelectionReceiver(mThread,this); - ModuleDialog md({}, prompt, pms, qApp->activeWindow()); + ModuleDialog md({}, prompt, false, pms, qApp->activeWindow()); Module* modSelect = (md.exec() == QDialog::Accepted) ? gNetlist->get_module_by_id(md.selectedId()) : nullptr; diff --git a/plugins/gui/src/selection_details_widget/gate_details_widget/gate_info_table.cpp b/plugins/gui/src/selection_details_widget/gate_details_widget/gate_info_table.cpp index 11ece14aca8..06a2507dc70 100644 --- a/plugins/gui/src/selection_details_widget/gate_details_widget/gate_info_table.cpp +++ b/plugins/gui/src/selection_details_widget/gate_details_widget/gate_info_table.cpp @@ -250,7 +250,7 @@ namespace hal { QSet excludeMods; if (mGate) excludeMods.insert(mGate->get_module()->get_id()); - ModuleDialog md(excludeMods, "Move to module", nullptr, this); + ModuleDialog md(excludeMods, "Move to module", false, nullptr, this); if (md.exec() != QDialog::Accepted) return; if (md.isNewModule()) { diff --git a/plugins/gui/src/selection_details_widget/module_details_widget/module_info_table.cpp b/plugins/gui/src/selection_details_widget/module_details_widget/module_info_table.cpp index 4c80cfabeb0..6a206f8d10a 100644 --- a/plugins/gui/src/selection_details_widget/module_details_widget/module_info_table.cpp +++ b/plugins/gui/src/selection_details_widget/module_details_widget/module_info_table.cpp @@ -486,7 +486,7 @@ namespace hal Module* parentMod = mModule->get_parent_module(); if (parentMod) excludeMods.insert(parentMod->get_id()); } - ModuleDialog md(excludeMods, "Move to module", nullptr, this); + ModuleDialog md(excludeMods, "Move to module", false, nullptr, this); if (md.exec() != QDialog::Accepted) return; if (md.isNewModule()) { diff --git a/plugins/gui/src/selection_details_widget/selection_details_widget.cpp b/plugins/gui/src/selection_details_widget/selection_details_widget.cpp index 7106b7cb729..9cd3a7c3dd4 100644 --- a/plugins/gui/src/selection_details_widget/selection_details_widget.cpp +++ b/plugins/gui/src/selection_details_widget/selection_details_widget.cpp @@ -165,7 +165,7 @@ namespace hal { if (gSelectionRelay->numberSelectedNodes() <= 0) return; - ModuleDialog md({},"Move to module",nullptr,this); + ModuleDialog md({},"Move to module",false,nullptr,this); if (md.exec() != QDialog::Accepted) return; if (md.isNewModule())