! * Delete child and remove from markerpoint list if it is a markerpoint. If it is a textlabel delete complete InfoElement */
| 613 | * Delete child and remove from markerpoint list if it is a markerpoint. If it is a textlabel delete complete InfoElement |
| 614 | */ |
| 615 | void InfoElement::childRemoved(const AbstractAspect* parent, const AbstractAspect* /*before*/, const AbstractAspect* child) { |
| 616 | Q_D(InfoElement); |
| 617 | |
| 618 | // when childs are reordered, don't remove them |
| 619 | // problem: when the order was changed the elements are deleted for a short time and recreated. This function will called then |
| 620 | if (m_suppressChildRemoved) |
| 621 | return; |
| 622 | |
| 623 | if (parent != this) // why do I need this? |
| 624 | return; |
| 625 | |
| 626 | // point removed |
| 627 | const auto* point = dynamic_cast<const CustomPoint*>(child); |
| 628 | if (point) { |
| 629 | for (int i = 0; i < markerpoints.length(); i++) { |
| 630 | if (point == markerpoints[i].customPoint) |
| 631 | markerpoints.removeAt(i); |
| 632 | // no point->remove() needed, because it was already deleted |
| 633 | } |
| 634 | // recreate text, because when marker was deleted, |
| 635 | // the placeholder should not be replaced anymore by a value |
| 636 | m_title->setUndoAware(false); |
| 637 | m_title->setText(createTextLabelText()); |
| 638 | m_title->setUndoAware(true); |
| 639 | } |
| 640 | |
| 641 | // textlabel was deleted |
| 642 | const auto* textlabel = dynamic_cast<const TextLabel*>(child); |
| 643 | if (textlabel) { |
| 644 | Q_ASSERT(m_title == textlabel); |
| 645 | m_title = nullptr; |
| 646 | for (int i = 0; i < markerpoints.length(); i++) { // why it's not working without? |
| 647 | m_suppressChildRemoved = true; |
| 648 | markerpoints[i].customPoint->remove(); |
| 649 | markerpoints.removeAt(i); |
| 650 | m_suppressChildRemoved = false; |
| 651 | } |
| 652 | remove(); // delete marker if textlabel was deleted, because there is no use case of this |
| 653 | } |
| 654 | |
| 655 | d->retransform(); |
| 656 | } |
| 657 | |
| 658 | void InfoElement::childAdded(const AbstractAspect* child) { |
| 659 | const auto* point = dynamic_cast<const CustomPoint*>(child); |
nothing calls this directly
no test coverage detected