@@ -362,19 +362,25 @@ void NetworkEditor::makeSubnetwork()
362362 }
363363 }
364364
365- if (underlyingModules.empty ())
366- {
367- QMessageBox::information (this , " Make subnetwork" , " Please select at least one module." );
368- return ;
369- }
370-
371365 bool ok;
372366 auto name = QInputDialog::getText (nullptr , " Make subnet" , " Enter subnet name:" , QLineEdit::Normal, " subnet" , &ok);
373367 if (!ok || name.isEmpty ())
374368 {
375369 QMessageBox::information (this , " Make subnetwork" , " Invalid name." );
376370 return ;
377371 }
372+
373+ if (currentSubnetNames_.contains (name))
374+ {
375+ QMessageBox::information (this , " Make subnetwork" , " A subnet by that name already exists." );
376+ return ;
377+ }
378+
379+ if (underlyingModules.empty ())
380+ {
381+ QMessageBox::information (this , " Make subnetwork" , " Please select at least one module." );
382+ return ;
383+ }
378384
379385 makeSubnetworkFromComponents (name, underlyingModules, includeConnections (items), rect);
380386}
@@ -456,6 +462,8 @@ class SubnetModuleFactory : public Modules::Factory::HardCodedModuleFactory
456462void NetworkEditor::makeSubnetworkFromComponents (const QString& name, const std::vector<ModuleHandle>& modules,
457463 QList<QGraphicsItem*> items, const QRectF& rect)
458464{
465+ currentSubnetNames_.insert (name);
466+
459467 SubnetModuleFactory factory;
460468 auto subnetModule = factory.makeSubnet (name, modules, items);
461469 portRewiringMap_ = factory.getMap ();
@@ -469,6 +477,7 @@ void NetworkEditor::makeSubnetworkFromComponents(const QString& name, const std:
469477 auto colorize = new QGraphicsDropShadowEffect;
470478 colorize->setColor (QColor (255 ,182 ,193 ,200 ));
471479 colorize->setOffset (8 ,8 );
480+ colorize->setBlurRadius (10 );
472481 proxy->setGraphicsEffect (colorize);
473482
474483 auto pic = grabSubnetPic (rect);
@@ -523,7 +532,7 @@ void NetworkEditor::makeSubnetworkFromComponents(const QString& name, const std:
523532 childrenNetworkItems_[name] = items;
524533
525534 addSubnetChild (name, subnetModule);
526- qDebug () << " port repl map out of scope" ;
535+ // qDebug() << "port repl map out of scope";
527536}
528537
529538QPixmap NetworkEditor::grabSubnetPic (const QRectF& rect)
0 commit comments