Пример #1
0
// static
bool LLAvatarActions::canShareSelectedItems(LLInventoryPanel* inv_panel /* = NULL*/)
{
	using namespace action_give_inventory;

	if (!inv_panel)
	{
		LLInventoryPanel* active_panel = get_active_inventory_panel();
		if (!active_panel) return false;
		inv_panel = active_panel;
	}

	// check selection in the panel
	LLFolderView* root_folder = inv_panel->getRootFolder();
    if (!root_folder)
    {
        return false;
    }
	const std::set<LLFolderViewItem*> inventory_selected = root_folder->getSelectionList();
	if (inventory_selected.empty()) return false; // nothing selected

	bool can_share = true;
	std::set<LLFolderViewItem*>::const_iterator it = inventory_selected.begin();
	const std::set<LLFolderViewItem*>::const_iterator it_end = inventory_selected.end();
	for (; it != it_end; ++it)
	{
		LLViewerInventoryCategory* inv_cat = gInventory.getCategory(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID());
		// any category can be offered.
		if (inv_cat)
		{
			continue;
		}

		// check if inventory item can be given
		LLFolderViewItem* item = *it;
		if (!item) return false;
		LLInvFVBridge* bridge = dynamic_cast<LLInvFVBridge*>(item->getViewModelItem());
		if (bridge && bridge->canShare())
		{
			continue;
		}

		// there are neither item nor category in inventory
		can_share = false;
		break;
	}

	return can_share;
}
Пример #2
0
void LLLandmarksPanel::onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param)
{
	bool new_visibility = param["visibility"].asBoolean();

	// We don't have to update items visibility if the menu is hiding.
	if (!new_visibility) return;

	BOOL are_any_items_in_trash = FALSE;
	BOOL are_all_items_in_trash = TRUE;

	LLFolderView* root_folder_view = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : NULL;
	if(root_folder_view)
	{
		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);

		std::set<LLFolderViewItem*> selected_items =    root_folder_view->getSelectionList();

		// Iterate through selected items to find out if any of these items are in Trash
		// or all the items are in Trash category.
		for (std::set<LLFolderViewItem*>::const_iterator iter =    selected_items.begin(); iter != selected_items.end(); ++iter)
		{
			LLFolderViewItem* item = *iter;

			// If no item is found it might be a folder id.
			if (!item) continue;

			LLFolderViewModelItemInventory* listenerp = static_cast<LLFolderViewModelItemInventory*>(item->getViewModelItem());
			if(!listenerp) continue;

			// Trash category itself should not be included because it can't be
			// actually restored from trash.
			are_all_items_in_trash &= listenerp->isItemInTrash() &&    listenerp->getUUID() != trash_id;

			// If there are any selected items in Trash including the Trash category itself
			// we show "Restore Item" in context menu and hide other irrelevant items.
			are_any_items_in_trash |= listenerp->isItemInTrash();
		}
	}

	// Display "Restore Item" menu entry if at least one of the selected items
	// is in Trash or the Trash category itself is among selected items.
	// Hide other menu entries in this case.
	// Enable this menu entry only if all selected items are in the Trash category.
	toggle_restore_menu((LLMenuGL*)ctrl, are_any_items_in_trash, are_all_items_in_trash);
}