* \brief Move a child to another parent aspect and transfer ownership. */
| 637 | * \brief Move a child to another parent aspect and transfer ownership. |
| 638 | */ |
| 639 | void AbstractAspect::reparent(AbstractAspect* newParent, int newIndex) { |
| 640 | Q_ASSERT(parentAspect()); |
| 641 | Q_ASSERT(newParent); |
| 642 | int max_index = newParent->childCount<AbstractAspect>(ChildIndexFlag::IncludeHidden); |
| 643 | if (newIndex == -1) |
| 644 | newIndex = max_index; |
| 645 | Q_ASSERT(newIndex >= 0 && newIndex <= max_index); |
| 646 | |
| 647 | // AbstractAspect* old_parent = parentAspect(); |
| 648 | // int old_index = old_parent->indexOfChild<AbstractAspect>(this, IncludeHidden); |
| 649 | // auto* old_sibling = old_parent->child<AbstractAspect>(old_index+1, IncludeHidden); |
| 650 | // auto* new_sibling = newParent->child<AbstractAspect>(newIndex, IncludeHidden); |
| 651 | |
| 652 | // Q_EMIT newParent->aspectAboutToBeAdded(newParent, new_sibling, this); |
| 653 | exec(new AspectChildReparentCmd(parentAspect()->d, newParent->d, this, newIndex)); |
| 654 | // Q_EMIT old_parent->aspectRemoved(old_parent, old_sibling, this); |
| 655 | } |
| 656 | |
| 657 | QVector<AbstractAspect*> AbstractAspect::children(AspectType type, ChildIndexFlags flags) const { |
| 658 | QVector<AbstractAspect*> result; |
no outgoing calls
no test coverage detected