Exemplo n.º 1
0
bool doToSelected(LLFolderView* folder, std::string action)
{
	LLInventoryModel* model = &gInventory;
	if ("rename" == action)
	{
		folder->startRenamingSelectedItem();
		return true;
	}
	if ("delete" == action)
	{
		folder->removeSelectedItems();
		return true;
	}

	if ("copy" == action)
	{	
		LLInventoryClipboard::instance().reset();
	}

	std::set<LLUUID> selected_items;
	folder->getSelectionList(selected_items);

	if ( ("attach" == action) && (selected_items.size() > 1) )
	{
		wear_attachments_on_avatar(selected_items, FALSE);
		return true;
	}

	LLMultiPreview* multi_previewp = NULL;
	LLMultiProperties* multi_propertiesp = NULL;

	if (("task_open" == action  || "open" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_previewp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100));
		gFloaterView->addChild(multi_previewp);

		LLFloater::setFloaterHost(multi_previewp);
	
	}
	else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_propertiesp = new LLMultiProperties(LLRect(left, top, left + 100, top - 100));
		gFloaterView->addChild(multi_propertiesp);

		LLFloater::setFloaterHost(multi_propertiesp);
	}

	std::set<LLUUID>::iterator set_iter;

	for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
	{
		LLFolderViewItem* folder_item = folder->getItemByID(*set_iter);
		if(!folder_item) continue;
		LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
		if(!bridge) continue;

		bridge->performAction(folder, model, action);
	}

	LLFloater::setFloaterHost(NULL);
	if (multi_previewp)
	{
		multi_previewp->open();
	}
	else if (multi_propertiesp)
	{
		multi_propertiesp->open();		/*Flawfinder: ignore*/
	}

	return true;
}
Exemplo n.º 2
0
bool doToSelected(LLFolderView* folder, std::string action)
{
	LLInventoryModel* model = &gInventory;
	if ("rename" == action)
	{
		folder->startRenamingSelectedItem();
		return true;
	}
	if ("delete" == action)
	{
		folder->removeSelectedItems();
		return true;
	}

	if ("copy" == action)
	{	
		LLInventoryClipboard::instance().reset();
	}
	// <edit>
	if("save_as" == action)
	{
		LLInventoryBackup::save(folder);
		return true;
	}
	else if("save_invcache" == action)
	{
		LLFilePicker& file_picker = LLFilePicker::instance();
		if(file_picker.getSaveFile( LLFilePicker::FFSAVE_INVGZ ))
		{
			std::string file_name = file_picker.getFirstFile();
			LLLocalInventory::saveInvCache(file_name, folder);
		}
		return true;
	}
/*
	else if("acquire_asset_id" == action)
	{
		if(LLCheats::cheatCodes["AcquireAssetID"].entered)
		{
			std::set<LLUUID> selected_items_set;
			folder->getSelectionList(selected_items_set);

			if(selected_items_set.size() > 0)
			{
				LLAssetIDAcquirer::acquire(selected_items_set);
			}
		}
		return true;
	}
	else if("magic_get" == action)
	{
		std::set<LLUUID> selected_items_set;
		folder->getSelectionList(selected_items_set);

		if(selected_items_set.size() > 0)
		{
			LLNotecardMagic::acquire(selected_items_set);
		}
	}
*/
	// </edit>

	std::set<LLUUID> selected_items;
	folder->getSelectionList(selected_items);

	LLMultiPreview* multi_previewp = NULL;
	LLMultiProperties* multi_propertiesp = NULL;

	if (("task_open" == action  || "open" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_previewp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100));
		gFloaterView->addChild(multi_previewp);

		LLFloater::setFloaterHost(multi_previewp);
	
	}
	else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_propertiesp = new LLMultiProperties(LLRect(left, top, left + 100, top - 100));
		gFloaterView->addChild(multi_propertiesp);

		LLFloater::setFloaterHost(multi_propertiesp);
	}

	std::set<LLUUID>::iterator set_iter;

	for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
	{
		LLFolderViewItem* folder_item = folder->getItemByID(*set_iter);
		if(!folder_item) continue;
		LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
		if(!bridge) continue;

		bridge->performAction(folder, model, action);
	}

	LLFloater::setFloaterHost(NULL);
	if (multi_previewp)
	{
		multi_previewp->open();
	}
	else if (multi_propertiesp)
	{
		multi_propertiesp->open();		/*Flawfinder: ignore*/
	}

	return true;
}
bool LLInventoryAction::doToSelected(LLFolderView* folder, std::string action)
{
	if (!folder)
		return true;
	LLInventoryModel* model = &gInventory;
	if ("rename" == action)
	{
		folder->startRenamingSelectedItem();
		return true;
	}
	else if ("delete" == action)
	{
		folder->removeSelectedItems();
		return true;
	}
	else if ("copy" == action || "cut" == action)
	{	
		LLInventoryClipboard::instance().reset();
	}
	else if ("save_as" == action)
	{
		LLInventoryBackup::save(folder);
		return true;
	}
	else if ("save_invcache" == action)
	{
		//AIFilePicker* filepicker = AIFilePicker::create();
		//filepicker->open(FFLOAD_INVGZ, "", "invgz");
		LLLocalInventory::saveInvCache(folder);
	}

	std::set<LLUUID> selected_items = folder->getSelectionList();

	LLMultiFloater* multi_floaterp = NULL;

	if (("task_open" == action  || "open" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_floaterp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100));
		gFloaterView->addChild(multi_floaterp);

		LLFloater::setFloaterHost(multi_floaterp);
	}
	else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_floaterp = new LLMultiProperties(LLRect(left, top, left + 100, top - 100));
		gFloaterView->addChild(multi_floaterp);

		LLFloater::setFloaterHost(multi_floaterp);
	}

	std::set<LLUUID>::iterator set_iter;

	for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
	{
		LLFolderViewItem* folder_item = folder->getItemByID(*set_iter);
		if(!folder_item) continue;
		LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
		if(!bridge) continue;

		bridge->performAction(model, action);
	}

	LLFloater::setFloaterHost(NULL);
	if (multi_floaterp)
	{
		multi_floaterp->open();
	}

	return true;
}
bool LLInventoryAction::doToSelected(LLFolderView* root, std::string action, BOOL user_confirm)
{
	if (!root)
		return true;

	std::set<LLUUID> selected_items = root->getSelectionList();

	// Prompt the user and check for authorization for some marketplace active listing edits
	if (user_confirm && (("delete" == action) || ("cut" == action) || ("rename" == action) || ("properties" == action) || ("task_properties" == action) || ("open" == action)))
	{
		std::set<LLUUID>::iterator set_iter = std::find_if(selected_items.begin(), selected_items.end(), boost::bind(&depth_nesting_in_marketplace, _1) >= 0);
		if (set_iter != selected_items.end())
		{
			if ("open" == action)
			{
				if (get_can_item_be_worn(*set_iter))
				{
					// Wearing an object from any listing, active or not, is verbotten
					LLNotificationsUtil::add("AlertMerchantListingCannotWear");
					return true;
				}
				// Note: we do not prompt for change when opening items (e.g. textures or note cards) on the marketplace...
			}
			else if (LLMarketplaceData::instance().isInActiveFolder(*set_iter) ||
					 LLMarketplaceData::instance().isListedAndActive(*set_iter))
			{
				// If item is in active listing, further confirmation is required
				if ((("cut" == action) || ("delete" == action)) && (LLMarketplaceData::instance().isListed(*set_iter) || LLMarketplaceData::instance().isVersionFolder(*set_iter)))
				{
					// Cut or delete of the active version folder or listing folder itself will unlist the listing so ask that question specifically
					LLNotificationsUtil::add("ConfirmMerchantUnlist", LLSD(), LLSD(), boost::bind(&LLInventoryAction::callback_doToSelected, _1, _2, root, action));
					return true;
				}
				// Any other case will simply modify but not unlist a listing
				LLNotificationsUtil::add("ConfirmMerchantActiveChange", LLSD(), LLSD(), boost::bind(&LLInventoryAction::callback_doToSelected, _1, _2, root, action));
				return true;
			}
			// Cutting or deleting a whole listing needs confirmation as SLM will be archived and inaccessible to the user
			else if (LLMarketplaceData::instance().isListed(*set_iter) && (("cut" == action) || ("delete" == action)))
			{
				LLNotificationsUtil::add("ConfirmListingCutOrDelete", LLSD(), LLSD(), boost::bind(&LLInventoryAction::callback_doToSelected, _1, _2, root, action));
				return true;
			}
		}
	}
	// Copying to the marketplace needs confirmation if nocopy items are involved
	if (("copy_to_marketplace_listings" == action))
	{
		std::set<LLUUID>::iterator set_iter = selected_items.begin();
		if (contains_nocopy_items(*set_iter))
		{
			LLNotificationsUtil::add("ConfirmCopyToMarketplace", LLSD(), LLSD(), boost::bind(&LLInventoryAction::callback_copySelected, _1, _2, root, action));
			return true;
		}
	}

	// Keep track of the marketplace folders that will need update of their status/name after the operation is performed
	buildMarketplaceFolders(root);

	LLInventoryModel* model = &gInventory;
	if ("rename" == action)
	{
		root->startRenamingSelectedItem();
		// Update the marketplace listings that have been affected by the operation
		updateMarketplaceFolders();
		return true;
	}

	if ("delete" == action)
	{
		root->removeSelectedItems();

		// Update the marketplace listings that have been affected by the operation
		updateMarketplaceFolders();
		return true;
	}
	if ("copy" == action || "cut" == action)
	{	
		LLInventoryClipboard::instance().reset();
	}

	LLMultiFloater* multi_floaterp = NULL;

	if (("task_open" == action  || "open" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_floaterp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100));
		gFloaterView->addChild(multi_floaterp);

		LLFloater::setFloaterHost(multi_floaterp);
	}
	else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1)
	{
		S32 left, top;
		gFloaterView->getNewFloaterPosition(&left, &top);

		multi_floaterp = new LLMultiProperties(LLRect(left, top, left + 100, top - 100));
		gFloaterView->addChild(multi_floaterp);

		LLFloater::setFloaterHost(multi_floaterp);
	}

	std::set<LLUUID>::iterator set_iter;


	// This rather warty piece of code is to allow items to be removed
	// from the avatar in a batch, eliminating redundant
	// updateAppearanceFromCOF() requests further down the line. (MAINT-4918)
	//
	// There are probably other cases where similar batching would be
	// desirable, but the current item-by-item performAction()
	// approach would need to be reworked.
	uuid_vec_t object_uuids_to_remove;
	if (isRemoveAction(action) && get_selection_object_uuids(root, object_uuids_to_remove))
	{
		LLAppearanceMgr::instance().removeItemsFromAvatar(object_uuids_to_remove);
	}
	else
	{
		for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
		{
			LLFolderViewItem* folder_item = root->getItemByID(*set_iter);
			if(!folder_item) continue;
			LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
			if(!bridge) continue;

			bridge->performAction(model, action);
		}
	}

	LLFloater::setFloaterHost(NULL);
	if (multi_floaterp)
	{
		multi_floaterp->open();
	}

	return true;
}