Skip to content

Commit

Permalink
1.Added parameter to ModuleDialog 2.Bugfix ModuleModel
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Jun 27, 2024
1 parent 0e30de2 commit ed28db5
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugins/gui/include/gui/module_dialog/module_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>& excludeIds = {}, const QString& title=QString("Select module"),
ModuleDialog(const QSet<u32>& excludeIds = {}, const QString& title=QString("Select module"), bool omitCreateNew=false,
ModuleSelectReceiver* receiver=nullptr, QWidget* parent=nullptr);

/**
Expand Down
4 changes: 2 additions & 2 deletions plugins/gui/src/graph_widget/graph_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32> module_to_add;
Expand Down Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/src/main_window/plugin_parameter_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions plugins/gui/src/module_dialog/module_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <QApplication>

namespace hal {
ModuleDialog::ModuleDialog(const QSet<u32>& excludeIds, const QString &title, ModuleSelectReceiver* receiver, QWidget* parent)
ModuleDialog::ModuleDialog(const QSet<u32>& excludeIds, const QString &title, bool omitCreateNew, ModuleSelectReceiver* receiver, QWidget* parent)
: QDialog(parent),
mSelectedId(0),
mExcludeIds(excludeIds),
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion plugins/gui/src/module_model/module_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleItem*>(submItem->getParent());
Q_ASSERT(oldParentItem);

Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/src/python/python_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ namespace hal
QSet<u32> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace hal
{
QSet<u32> 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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit ed28db5

Please sign in to comment.