@@ -232,20 +232,64 @@ namespace hal
232
232
233
233
switch (itemType){
234
234
case PinItem::TreeItemType::PinGroup:
235
+ /* {
236
+ pinItem->setDirection(direction);
237
+ qInfo()<<pinItem->getChildren().length();
238
+ for(auto child : pinItem->getChildren()) //set same direction for all pins of the pingroup
239
+ {
240
+ PinItem* pin = static_cast<PinItem*>(child);
241
+ qInfo()<<"1";
242
+ pin->setDirection(direction);
243
+ }
244
+ handleInvalidGroupUpdate(pinItem);
245
+ //qInfo()<<"handleEditDirection PinGroup";
246
+ break;
247
+ }*/
235
248
case PinItem::TreeItemType::InvalidPinGroup:{
236
- handleGroupDirectionUpdate (pinItem, enum_from_string<PinDirection>(direction.toStdString ()));
249
+ pinItem->setDirection (direction);
250
+ for (auto child : pinItem->getChildren ()) // set same direction for all pins of the pingroup
251
+ {
252
+ PinItem* pin = static_cast <PinItem*>(child);
253
+ if (pin->getItemType () == PinItem::TreeItemType::Pin || pin->getItemType () == PinItem::TreeItemType::InvalidPin){
254
+ pin->setDirection (direction);
255
+ handleInvalidPinUpdate (pin);
256
+ }
257
+ }
258
+ handleInvalidGroupUpdate (pinItem);
237
259
break ;
238
260
}
239
- case PinItem::TreeItemType::Pin:{
261
+ case PinItem::TreeItemType::Pin:
262
+ /* {
240
263
pinItem->setDirection(direction);
241
264
//get the groupItem and update it
242
- auto groupItem = static_cast <PinItem*>(pinItem->getParent ());
243
- handleGroupDirectionUpdate (groupItem);
265
+ //auto groupItem = static_cast<PinItem*>(pinItem->getParent());
266
+ //handleGroupDirectionUpdate(groupItem);
267
+ handleInvalidPinUpdate(pinItem);
244
268
break;
245
- }
269
+ }*/
246
270
case PinItem::TreeItemType::InvalidPin:{
247
- pinItem->setDirection (direction);
248
- handleInvalidPinUpdate (pinItem);
271
+ QMessageBox warning;
272
+ QPushButton* acceptBtn = warning.addButton (tr (" Continue with changes" ), QMessageBox::AcceptRole);
273
+ QPushButton* abortBtn = warning.addButton (QMessageBox::Abort);
274
+ PinItem* parentGroup = static_cast <PinItem*>(pinItem->getParent ());
275
+ warning.setWindowTitle (" New pin creation" );
276
+ warning.setText (QString (" You are about to create an %1 pin in an %2 pin group" )
277
+ .arg (direction)
278
+ .arg (parentGroup->getDirection ()));
279
+ if (direction != parentGroup->getDirection ())
280
+ {
281
+ warning.exec ();
282
+ if (warning.clickedButton () == acceptBtn){
283
+ pinItem->setDirection (direction);
284
+ handleInvalidPinUpdate (pinItem);
285
+ }
286
+ }
287
+ else
288
+ {
289
+ pinItem->setDirection (direction);
290
+ handleInvalidPinUpdate (pinItem);
291
+ }
292
+
249
293
break ;
250
294
}
251
295
}
@@ -259,13 +303,24 @@ namespace hal
259
303
260
304
switch (itemType)
261
305
{
306
+ case PinItem::TreeItemType::InvalidPin:
262
307
case PinItem::TreeItemType::Pin: {
263
308
pinItem->setType (type);
309
+ handleInvalidPinUpdate (pinItem);
264
310
break ;
265
311
}
266
- case PinItem::TreeItemType::InvalidPin: {
312
+ case PinItem::TreeItemType::InvalidPinGroup:
313
+ case PinItem::TreeItemType::PinGroup: {
267
314
pinItem->setType (type);
268
- handleInvalidPinUpdate (pinItem);
315
+ for (auto child : pinItem->getChildren ()) // set same direction for all pins of the pingroup
316
+ {
317
+ PinItem* pin = static_cast <PinItem*>(child);
318
+ if (pin->getItemType () == PinItem::TreeItemType::Pin || pin->getItemType () == PinItem::TreeItemType::InvalidPin){
319
+ pin->setType (type);
320
+ handleInvalidPinUpdate (pin);
321
+ }
322
+ }
323
+ handleInvalidGroupUpdate (pinItem);
269
324
break ;
270
325
}
271
326
}
@@ -374,7 +429,6 @@ namespace hal
374
429
375
430
void PinModel::handleInvalidPinUpdate (PinItem* pinItem)
376
431
{
377
-
378
432
if (!isNameAvailable (pinItem->getName (), pinItem)
379
433
|| enum_from_string<PinDirection>(pinItem->getDirection ().toStdString ()) == PinDirection::none)
380
434
return ; // Pin is not valid
@@ -393,7 +447,7 @@ namespace hal
393
447
bool isValid = true ;
394
448
395
449
// calculate new direction
396
- handleGroupDirectionUpdate (groupItem);
450
+ // handleGroupDirectionUpdate(groupItem);
397
451
398
452
// check each pin in the group if its valid or not
399
453
QList<PinItem*> childs = QList<PinItem*>();
@@ -442,7 +496,7 @@ namespace hal
442
496
// direction has to be calculated based on contained pins
443
497
444
498
// bitmask with inout = 2³, out = 2², in = 2¹, internal = 2⁰
445
- int directionMask = 0 ;
499
+ /* int directionMask = 0;
446
500
447
501
for(BaseTreeItem* pin : groupItem->getChildren()){
448
502
QString dir = static_cast<PinItem*>(pin)->getDirection();
@@ -481,7 +535,7 @@ namespace hal
481
535
//else it should stay to what it was before
482
536
483
537
//set calculated direction
484
- groupItem->setDirection (QString::fromStdString (enum_to_string (calcDir)));
538
+ groupItem->setDirection(QString::fromStdString(enum_to_string(calcDir)));*/
485
539
}
486
540
487
541
void PinModel::printGateMember ()
0 commit comments