| 4494 | } |
| 4495 | |
| 4496 | void GuiTreeViewCtrl::reparentItems(Vector<Item*> selectedItems, Item* newParent) |
| 4497 | { |
| 4498 | for (S32 i = 0; i < selectedItems.size(); i++) |
| 4499 | { |
| 4500 | Item* item = selectedItems[i]; |
| 4501 | |
| 4502 | if (mDebug) |
| 4503 | Con::printf("----------------------------"); |
| 4504 | |
| 4505 | // clear old highlighting of the item |
| 4506 | item->mState.clear(Item::MouseOverBmp | Item::MouseOverText); |
| 4507 | |
| 4508 | // move the selected item to the newParent |
| 4509 | Item * oldParent = item->mParent; |
| 4510 | // Snag the current parent set if any for future reference |
| 4511 | SimSet * parentSet = NULL; |
| 4512 | |
| 4513 | if (oldParent != nullptr && oldParent->isInspectorData()) |
| 4514 | { |
| 4515 | parentSet = dynamic_cast<SimSet*>(oldParent->getObject()); |
| 4516 | } |
| 4517 | else |
| 4518 | { |
| 4519 | // parent is probably script data so we search up the tree for a |
| 4520 | // set to put our object in |
| 4521 | Item* temp = oldParent; |
| 4522 | while (temp) |
| 4523 | { |
| 4524 | if (temp->isInspectorData()) |
| 4525 | break; |
| 4526 | temp = temp->mParent; |
| 4527 | } |
| 4528 | // found an ancestor who is an inspectorData |
| 4529 | if (temp) |
| 4530 | { |
| 4531 | if (temp->isInspectorData()) |
| 4532 | parentSet = dynamic_cast<SimSet*>(temp->getObject()); |
| 4533 | } |
| 4534 | } |
| 4535 | |
| 4536 | // unlink from the current position in the list |
| 4537 | unlinkItem(item); |
| 4538 | |
| 4539 | // update the parent's children |
| 4540 | |
| 4541 | // check if we an only child |
| 4542 | if (item->mParent && item->mParent->mChild == item) |
| 4543 | { |
| 4544 | if (item->mNext) |
| 4545 | item->mParent->mChild = item->mNext; |
| 4546 | else |
| 4547 | item->mParent->mChild = NULL; |
| 4548 | } |
| 4549 | |
| 4550 | if (mDragMidPoint != NomDragMidPoint) |
| 4551 | { |
| 4552 | |
| 4553 | //if it is below an expanded tree, place as last item in the tree |
no test coverage detected