コード例 #1
0
ファイル: llavataractions.cpp プロジェクト: Belxjander/Kirito
// 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
bool LLSidepanelInventory::canShare()
{
	LLPanelMainInventory* panel_main_inventory =
		mInventoryPanel->findChild<LLPanelMainInventory>("panel_main_inventory");

	LLFolderView* root_folder =
		panel_main_inventory->getActivePanel()->getRootFolder();

	LLFolderViewItem* current_item = root_folder->hasVisibleChildren()
		? root_folder->getCurSelectedItem()
		: NULL;

	LLInvFVBridge* bridge = current_item
		? dynamic_cast <LLInvFVBridge*> (current_item->getListener())
		: NULL;

	return bridge ? bridge->canShare() : false;
}