| 501 | } |
| 502 | |
| 503 | FileSystemActor *FileSystemPile::convert(Pile *softPile, QString newDirPath) |
| 504 | { |
| 505 | LOG_LINE_REACHED(); |
| 506 | |
| 507 | FileSystemActor *fsData = NULL; |
| 508 | QString newPath; |
| 509 | Vec3 newPos; |
| 510 | |
| 511 | // Convert Soft Pile to Hard Pile |
| 512 | if (softPile->getPileType() == SoftPile && !owner) |
| 513 | { |
| 514 | for (uint i = 0; i < softPile->getNumItems(); i++) |
| 515 | { |
| 516 | fsData = (FileSystemActor *) (*softPile)[i]; |
| 517 | |
| 518 | // Check if this item can be put into a soft Pile |
| 519 | if (!fsData->isPilable(HardPile)) |
| 520 | { |
| 521 | return NULL; |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | if (softPile->getNumItems() == 0) return NULL; |
| 526 | |
| 527 | // Create the Directory that this can be moved into (May fail if exists - Thats ok) |
| 528 | if (fsManager->createDirectory(newDirPath)) |
| 529 | { |
| 530 | // Create the new Actor |
| 531 | fsData = (FileSystemActor *) softPile->getLastItem(); |
| 532 | owner = FileSystemActorFactory::createFileSystemActor(newDirPath); |
| 533 | owner->setDimsToDefault(); |
| 534 | owner->setGlobalPose(Mat34(true)); |
| 535 | owner->setFilePath(newDirPath); |
| 536 | |
| 537 | // Semi-Pileize the owner |
| 538 | owner->setPileizedPile(this); |
| 539 | owner->hideAndDisable(); |
| 540 | |
| 541 | // Add all items to the new pile |
| 542 | for (int i = 0; i < softPile->getNumItems(); i++) |
| 543 | { |
| 544 | fsData = (FileSystemActor *) (*softPile)[i]; |
| 545 | fsData->setParent(NULL); |
| 546 | |
| 547 | if (addToPile(fsData)) |
| 548 | { |
| 549 | // Success, remove item from pile |
| 550 | softPile->clear(i); |
| 551 | fsData->setParent(this); |
| 552 | i--; |
| 553 | }else{ |
| 554 | // Failed the move |
| 555 | fsData->setParent(softPile); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | // Update this Pile to reflect a full HardPile |
| 560 | setText(owner->getText()); |
no test coverage detected