Пример #1
0
bool FileSystemActor::isSourceValid()
{
	FileSystemActor *fsData = NULL;
	Actor *data = NULL;

	for (uint i = 0; i < source.size(); i++)
	{
		// Check to see if the icon is a filesystem icon
		if (source[i]->isBumpObjectType(BumpActor))
		{
			data = (Actor *) source[i];

			if (data->isActorType(FileSystem))
			{
				fsData = (FileSystemActor *) source[i];

				// Exclude Virtual folders
				if (fsData->isFileSystemType(Virtual)) return false;
				if (fsData->isFileSystemType(LogicalVolume)) return false;
				if (fsData == this) return false;
			}
			else if (data->isActorType(Webpage) && RecycleBin == winOS->GetIconTypeFromFileName(getFullPath()))
				return true; // can drop WebActor into Recycling Bin to delete
			else
				return false;

		}else if (source[i]->isBumpObjectType(BumpPile))
		{
			Pile *pile = (Pile *) source[i];

			// Check for any items that cannot be moved (ie. Virtual folders)
			for (uint i = 0; i < pile->getNumItems(); i++)
			{
				if (!(*pile)[i]->isPilable(HardPile))
				{
					return false;
				}
			}

			// Ignore gridded items because they are on the dynamic plane, above
			// all other items on the floor.
			if (pile->getPileState() == Grid) return false;

			// Allow Piles
			return true;
		
		}else{
			// Logical items are not allowed
			return false;
		}
	}

	return true;
}
Пример #2
0
vector<BumpObject *> FileSystemActor::onDrop(vector<BumpObject *> &objList)
{
	QString fPath;
	FileSystemActor *fsData;
	Pile *pile;
	FileSystemPile *fsPile;
	Vec3 topPt;
	bool moveItem = true;
	bool operationSucceeded = false;
	vector<FileSystemActor *> failedObj, fsObjList;
	vector<BumpObject *> failedBumpObjs;
	vector<FileSystemActor *> hardPileOwners;

	if (!isSourceValid())
	{
		return objList;
	}
	else
	{	
		// Convert Piles to Free Items
		for (int i = 0; i < objList.size(); i++)
		{
			// Do Pile to free Item conversions
			if (objList[i]->getObjectType() == ObjectType(BumpPile, HardPile, Stack))
			{
				// If its a Hard Pile, get its owner and use it instead of pile members
				fsPile = (FileSystemPile *) objList[i];

				objList.erase(objList.begin() + i);
				objList.push_back(fsPile->getOwner());
				hardPileOwners.push_back(fsPile->getOwner());

				fsPile->folderize(false);

				i--;

			}else if (objList[i]->getObjectType() == ObjectType(BumpPile, SoftPile, Stack))
			{
				pile = (Pile *) objList[i];

				objList.erase(objList.begin() + i);
				i--;

				// If its a Soft Pile, use its members instead of the pile
				for (uint j = 0; j < pile->getNumItems(); j++)
				{
					objList.push_back((*pile)[j]);
				}
			}
		}

		if (isFileSystemType(Executable))
		{
			for (uint i = 0; i < objList.size(); i++)
			{
				// Create a parameter list separated by spaces
				fsData = (FileSystemActor *) objList[i];

				if (!fsData || !scnManager->containsObject(fsData))
					continue;

				fPath.append(fsData->getFullPath());
				fPath.append(" ");
			}

			// We just tossed into an executable
			// QString lnkTarget, dummyLnkArgs, lnkWorkingDir;
			QString lnkArgs = fPath;
			/*
			if (isFileSystemType(Link))
			{
				fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &dummyLnkArgs, &lnkWorkingDir);
				fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir);
			}
			else
			*/
				fsManager->launchFileAsync(filePath, lnkArgs);

		}else if (isFileSystemType(Folder))
		{
			bool itemNeedsPrompt = false;
			bool onlyPhotoFrame = true;

			int iconType = winOS->GetIconTypeFromFileName(getFullPath());
			bool isRecycleBin = iconType == RecycleBin;
			bool isMyDocuments = iconType == MyDocuments;

			// Convert BumpObject to FileSystemActors, delete WebActors since they are not FileSystemActors
			for (uint i = 0; i < objList.size(); i++)
			{
				if (objList[i]->isObjectType(ObjectType(BumpActor, Webpage)))
				{
					if (isRecycleBin)
					{
						sel->remove(objList[i]);
						objList[i]->markDragCancelled(true);
						objList[i]->onDragEnd();
						FadeAndDeleteActor((Actor *)objList[i]);
						objList.erase(objList.begin() + i);
					}
					else
						_ASSERT(0);
				}
				else
				{
					fsObjList.push_back((FileSystemActor *) objList[i]);

					if (fsObjList[i]->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
						itemNeedsPrompt = true;
					else
						onlyPhotoFrame = false;
				}
			}

			if (isFileSystemType(Virtual))
			{
				// Handle tossing into the recycle bin
				if (isRecycleBin || isMyDocuments)
				{
					if (itemNeedsPrompt)
					{
						dlgManager->clearState();
						dlgManager->setPrompt(QT_TR_NOOP("A Photo Frame was detected in the selection, would you like to delete it?"));
						dlgManager->setCaption(QT_NT("BumpTop"));

						if (dlgManager->promptDialog(DialogYesNo))
						{
							vector<FileSystemActor *>::iterator iter = fsObjList.begin();
							while (iter != fsObjList.end())
							{
								FileSystemActor * fsActor = *iter;
								if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
								{
									// Remove the photo frame by deferring deletion until after the anim is over
									fsActor->fadeOut();
									animManager->removeAnimation(fsActor);
									animManager->addAnimation(AnimationEntry(fsActor, (FinishedCallBack) DeleteActorAfterAnim, NULL, true));

									iter = fsObjList.erase(iter);
								}
								else
									iter++;
							}
						}
						else
						{
							vector<FileSystemActor *>::iterator iter = fsObjList.begin();
							while (iter != fsObjList.end())
							{
								FileSystemActor * fsActor = *iter;
								if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame))
								{
									failedObj.push_back(fsActor);
									iter = fsObjList.erase(iter);
								}
								else
									iter++;
							}
						}
					}

					if (!fsObjList.empty())
					{
						if (isRecycleBin)
							operationSucceeded = fsManager->deleteFiles(fsObjList, failedObj, !onlyPhotoFrame);
						else
							operationSucceeded = fsManager->moveFiles(fsObjList, winOS->GetSystemPath(iconType), failedObj, true);
					}
				}
			}else{
				if (!isCopyIntoActor(objList)) // Shift forces move, Ctrl forces copy, common root defaults to move
				{
					// Handle tossing into a regular folder
					operationSucceeded = fsManager->moveFiles(fsObjList, getTargetPath(), failedObj, true);
					if (operationSucceeded)
					{
						printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) moved to %2").arg(fsObjList.size()).arg(getText()));
					}
				}
				else
				{
					// Handle tossing into a regular folder on another resource (will copy instead of move)
					operationSucceeded = fsManager->copyFiles(fsObjList, getTargetPath(), failedObj, true);
					if (operationSucceeded)
					{
						printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) copied to %2").arg(fsObjList.size()).arg(getText()));
					}

					// Animate back to the original starting pose
					animateObjectsBackToPreDropPose(objList);
				}
			}
		}

		if (!operationSucceeded)
		{
			// re-pileize hard piles if move failed
			vector<FileSystemActor *>::iterator iter = hardPileOwners.begin();
			while (iter != hardPileOwners.end())
			{
				(*iter)->pileize();
				iter++;
			}
		}

		// record this drop
		statsManager->getStats().bt.interaction.dragAndDrop.toActor++;
	}

	// Convert from a list of FileSYstemActors to BumpObjects
	for (uint i = 0; i < failedObj.size(); i++)
	{
		failedBumpObjs.push_back(failedObj[i]);
	}

	return failedBumpObjs;
}