MCPcopy Create free account
hub / github.com/KDE/labplot / childRemoved

Method childRemoved

src/backend/worksheet/InfoElement.cpp:615–656  ·  view source on GitHub ↗

! * Delete child and remove from markerpoint list if it is a markerpoint. If it is a textlabel delete complete InfoElement */

Source from the content-addressed store, hash-verified

613 * Delete child and remove from markerpoint list if it is a markerpoint. If it is a textlabel delete complete InfoElement
614 */
615void 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
658void InfoElement::childAdded(const AbstractAspect* child) {
659 const auto* point = dynamic_cast<const CustomPoint*>(child);

Callers

nothing calls this directly

Calls 5

lengthMethod · 0.80
setUndoAwareMethod · 0.80
setTextMethod · 0.45
removeMethod · 0.45
retransformMethod · 0.45

Tested by

no test coverage detected