156 if ( ! ( event->buttons() & Qt::LeftButton ) )
161 if ( ( event->pos() -
StartDrag ).manhattanLength() < QApplication::startDragDistance() )
166 QDrag * drag =
new QDrag ( event->widget() );
169 QStringList DataList;
170 QMimeData * mimeData =
new QMimeData;
172 QDataStream DataStream ( &ItemData, QIODevice::WriteOnly );
176 DataStream << DataList;
177 mimeData->setData (
"application/vnd.text.list", ItemData );
179 drag->setMimeData ( mimeData );
180 drag->setPixmap ( Icon );
182 Qt::DropAction dropAction = drag->exec();
183 Q_UNUSED ( dropAction )
190 QByteArray encodedData =
event->mimeData()->data (
"application/vnd.text.list" );
191 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
192 QList<QStringList> NewItems;
194 while ( !stream.atEnd() )
201 QStringList ObjectList;
203 for ( QStringList & i : NewItems )
205 ObjectList.append ( i.at ( 0 ) );
208 for (
int i = 0; i < NewItems.size(); ++i )
210 if ( NewItems.at ( 0 ).at ( 1 ) != NewItems.at ( i ).at ( 1 ) )
216 QStringList PossibleRelationships;
217 QString ClassName = NewItems.at ( 0 ).at ( 1 );
221 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfoReceiverObject
226 if ( i.p_type == ClassName.toStdString() ) PossibleRelationships.append (
227 QString::fromStdString ( i.p_name ) );
232 std::vector<std::string> RelationshipListDropped = ClassInfoDroppedObject.
p_subclasses;
234 for ( std::string & j : RelationshipListDropped )
236 if ( j == ClassName.toStdString() ) PossibleRelationships.append (
237 QString::fromStdString ( i.p_name ) );
241 QString SelectedRelationship;
243 if ( PossibleRelationships.size() == 0 )
247 else if ( PossibleRelationships.size() == 1 ) SelectedRelationship = PossibleRelationships
251 QDialog * NewDialog =
new QDialog();
252 QHBoxLayout * NewLayout =
new QHBoxLayout();
253 QPushButton * OkButton =
new QPushButton (
"Ok" );
254 QComboBox * NewCombo =
new QComboBox();
255 QLabel * NewLabel =
new QLabel (
"Choose relationship : " );
256 NewCombo->addItems ( PossibleRelationships );
257 NewLayout->addWidget ( NewLabel );
258 NewLayout->addWidget ( NewCombo );
259 NewLayout->addWidget ( OkButton );
260 NewDialog->setLayout ( NewLayout );
261 NewDialog->adjustSize();
262 connect ( OkButton, SIGNAL ( clicked() ), NewDialog, SLOT ( accept() ),
263 Qt::UniqueConnection );
265 int Status = NewDialog->exec();
267 if ( Status == QDialog::Accepted )
269 SelectedRelationship = NewCombo->currentText();
286 if ( RelationshipData.
p_name == SelectedRelationship.toStdString() )
292 std::vector<std::string> RelationshipValues;
295 RelationshipValues.push_back (
296 RelationshipChildren->GetData ( 0 ).toString().toStdString() );
298 for ( QStringList &
Item : NewItems )
299 if ( std::find ( RelationshipValues.begin(), RelationshipValues.end(),
300 Item.at ( 0 ).toStdString() )
301 == RelationshipValues.end() ) RelationshipValues.push_back (
302 Item.at ( 0 ).toStdString() );
306 RelationshipValues );
310 QString SelectedObject;
312 if ( NewItems.size() > 1 )
314 QDialog * NewDialog =
new QDialog();
315 QHBoxLayout * NewLayout =
new QHBoxLayout();
316 QPushButton * OkButton =
new QPushButton (
"Ok" );
317 QComboBox * NewCombo =
new QComboBox();
318 QLabel * NewLabel =
new QLabel (
"Choose Object : " );
319 NewCombo->addItems ( ObjectList );
320 NewLayout->addWidget ( NewLabel );
321 NewLayout->addWidget ( NewCombo );
322 NewLayout->addWidget ( OkButton );
323 NewDialog->setLayout ( NewLayout );
324 NewDialog->adjustSize();
325 connect ( OkButton, SIGNAL ( clicked() ), NewDialog, SLOT ( accept() ),
326 Qt::UniqueConnection );
328 int Status = NewDialog->exec();
330 if ( Status == QDialog::Accepted )
332 SelectedObject = NewCombo->currentText();
337 SelectedObject = NewItems.at ( 0 ).at ( 0 );
342 { SelectedObject.toStdString() } );
395 for ( QGraphicsItem * i : this->childItems() )
400 double ThisOffsetX = 0;
401 double ThisOffsetY = 0;
404 QPointF ThisItemBottom = this->mapToScene ( this->
boundingRect().bottomRight() );
406 if ( !this->childItems().isEmpty() )
408 ThisOffsetX -= ThisItemBottom.x();
409 ThisOffsetY -= ThisItemBottom.y();
413 QGraphicsItem * AuxiliaryItem =
this;
415 while ( AuxiliaryItem->parentItem() !=
nullptr )
417 for (
int i = AuxiliaryItem->parentItem()->childItems().indexOf ( AuxiliaryItem ) + 1;
418 i < AuxiliaryItem->parentItem()->childItems().size(); ++i )
420 QGraphicsItem * Child = AuxiliaryItem->parentItem()->childItems().at ( i );
421 Child->setY ( Child->y() + ThisOffsetY );
424 AuxiliaryItem = AuxiliaryItem->parentItem();
429 double ThisTopLevelOffsetX = 0;
430 double ThisTopLevelOffsetY = 0;
431 GetOffsetX ( this->topLevelItem(), ThisTopLevelOffsetX );
432 GetOffsetY ( this->topLevelItem(), ThisTopLevelOffsetY );
433 QPointF ThisTopLevelItemBottom = this->topLevelItem()->mapToScene (
436 if ( !this->topLevelItem()->childItems().isEmpty() )
438 ThisTopLevelOffsetX -= ThisTopLevelItemBottom.x();
439 ThisTopLevelOffsetY -= ThisTopLevelItemBottom.y();
443 QList<QGraphicsItem *> TopLevelItems = scene()->items();
446 ( this->topLevelItem() );
447 double LineHighestOffsetY = 0;
449 for ( QGraphicsItem *
Item : TopLevelItems )
453 if (
Item->parentItem() ==
nullptr && ThisTopLevelItem->y() ==
Item->y()
454 && ThisTopLevelItem !=
Item )
458 if ( ItemObject && LineHighestOffsetY < ItemObject->
GetExpandedY() ) LineHighestOffsetY =
465 for ( QGraphicsItem *
Item : TopLevelItems )
467 if ( ThisTopLevelItem !=
Item &&
Item->parentItem() ==
nullptr )
469 if ( ThisTopLevelItem->y() <
Item->y() && ThisTopLevelOffsetY > LineHighestOffsetY )
471 if ( LineHighestOffsetY == 0 )
473 Item->setY (
Item->y() + ThisOffsetY );
477 if ( ThisTopLevelOffsetY - LineHighestOffsetY < ThisTopLevelOffsetY
479 Item->y() + ThisTopLevelOffsetY - LineHighestOffsetY );
486 if ( ThisTopLevelItem->y() ==
Item->y() && ThisTopLevelItem->x() <
Item->x()
487 &&
Item->parentItem() ==
nullptr )
489 if ( ThisTopLevelOffsetX > ThisTopLevelItem->
GetExpandedX() )
493 Item->setX (
Item->x() + ThisOffsetX );
512 double ThisOffsetX = 0;
513 double ThisOffsetY = 0;
516 QPointF ThisItemBottom = this->mapToScene ( this->
boundingRect().bottomRight() );
518 if ( !this->childItems().isEmpty() )
520 ThisOffsetX -= ThisItemBottom.x();
521 ThisOffsetY -= ThisItemBottom.y();
525 QGraphicsItem * AuxiliaryItem =
this;
527 while ( AuxiliaryItem->parentItem() !=
nullptr )
529 for (
int i = AuxiliaryItem->parentItem()->childItems().indexOf ( AuxiliaryItem ) + 1;
530 i < AuxiliaryItem->parentItem()->childItems().size(); ++i )
532 QGraphicsItem * Child = AuxiliaryItem->parentItem()->childItems().at ( i );
533 Child->setY ( Child->y() - ThisOffsetY );
536 AuxiliaryItem = AuxiliaryItem->parentItem();
543 for ( QGraphicsItem * i : this->childItems() )
548 double ThisTopLevelOffsetX = 0;
549 double ThisTopLevelOffsetY = 0;
550 GetOffsetX ( this->topLevelItem(), ThisTopLevelOffsetX );
551 GetOffsetY ( this->topLevelItem(), ThisTopLevelOffsetY );
552 QPointF ThisTopLevelItemBottom = this->topLevelItem()->mapToScene (
555 if ( !this->topLevelItem()->childItems().isEmpty()
556 && this->topLevelItem()->childItems().at (
559 ThisTopLevelOffsetX -= ThisTopLevelItemBottom.x();
560 ThisTopLevelOffsetY -= ThisTopLevelItemBottom.y();
564 QList<QGraphicsItem *> TopLevelItems = scene()->items();
567 ( this->topLevelItem() );
568 double LineHighestOffsetY = 0;
570 for ( QGraphicsItem *
Item : TopLevelItems )
574 if (
Item->parentItem() ==
nullptr && ThisTopLevelItem->y() ==
Item->y()
575 && ThisTopLevelItem !=
Item )
579 if ( ItemObject && LineHighestOffsetY < ItemObject->
GetExpandedY() ) LineHighestOffsetY =
586 for ( QGraphicsItem *
Item : TopLevelItems )
588 if ( ThisTopLevelItem !=
Item &&
Item->parentItem() ==
nullptr )
591 > LineHighestOffsetY )
593 if ( LineHighestOffsetY == 0 )
595 Item->setY (
Item->y() - ThisOffsetY );
599 if ( ThisTopLevelOffsetY >= LineHighestOffsetY && ThisTopLevelOffsetY
601 Item->y() - abs ( ThisTopLevelOffsetY - ThisTopLevelItem->
GetExpandedY() ) );
603 if ( ThisTopLevelItem->
GetExpandedY() > LineHighestOffsetY && ThisTopLevelOffsetY
604 < LineHighestOffsetY )
Item->setY (
605 Item->y() - abs ( ThisTopLevelItem->
GetExpandedY() - LineHighestOffsetY ) );
610 if ( ThisTopLevelItem->y() ==
Item->y() && ThisTopLevelItem->x() <
Item->x()
611 &&
Item->parentItem() ==
nullptr )
613 if ( ThisTopLevelOffsetX < ThisTopLevelItem->
GetExpandedX() )
801 if ( ChildNode->GetData ( 0 ).toString() == QString (
RelationshipData.p_name.c_str() ) )
807 if ( ChildChildNodeObject )
812 true, ChildChildNode->GetData ( 0 ).toString(), Dummy );
813 ObjectNodeGraphical->setParentItem (
this );
815 QPointF coord = ObjectNodeGraphical->mapFromParent (
boundingRect().topRight() );
816 ObjectNodeGraphical->setX ( coord.x() + OffsetX );
817 ObjectNodeGraphical->setY ( coord.y() + OffsetY );
818 OffsetY += ObjectNodeGraphical->
boundingRect().height();