Ejemplo n.º 1
0
void LLPanelOutfitsInventory::updateListCommands()
{
	bool trash_enabled = isActionEnabled("delete");
	bool wear_enabled =  isActionEnabled("wear");
	bool wear_visible = !isCOFPanelActive();
	bool make_outfit_enabled = isActionEnabled("save_outfit");

	mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled);
	mListCommands->childSetEnabled("wear_btn", wear_enabled);
	mListCommands->childSetVisible("wear_btn", wear_visible);
	mSaveComboBtn->setMenuItemEnabled("save_outfit", make_outfit_enabled);
	if (mMyOutfitsPanel->hasItemSelected())
	{
		mListCommands->childSetToolTip("wear_btn", getString("wear_items_tooltip"));
	}
	else
	{
		mListCommands->childSetToolTip("wear_btn", getString("wear_outfit_tooltip"));
	}
}
BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
{
    const std::string command_name = userdata.asString();
    if (command_name == "delete" || command_name == "remove")
    {
        BOOL can_delete = FALSE;
        LLFolderView *folder = getActivePanel()->getRootFolder();
        if (folder)
        {
            std::set<LLUUID> selection_set;
            folder->getSelectionList(selection_set);
            can_delete = (selection_set.size() > 0);
            for (std::set<LLUUID>::iterator iter = selection_set.begin();
                    iter != selection_set.end();
                    ++iter)
            {
                const LLUUID &item_id = (*iter);
                LLFolderViewItem *item = folder->getItemByID(item_id);
                can_delete &= item->getListener()->isItemRemovable();
            }
            return can_delete;
        }
        return FALSE;
    }
    if (command_name == "remove_link")
    {
        BOOL can_delete = FALSE;
        LLFolderView *folder = getActivePanel()->getRootFolder();
        if (folder)
        {
            std::set<LLUUID> selection_set;
            folder->getSelectionList(selection_set);
            can_delete = (selection_set.size() > 0);
            for (std::set<LLUUID>::iterator iter = selection_set.begin();
                    iter != selection_set.end();
                    ++iter)
            {
                const LLUUID &item_id = (*iter);
                LLViewerInventoryItem *item = gInventory.getItem(item_id);
                if (!item || !item->getIsLinkType())
                    return FALSE;
            }
            return can_delete;
        }
        return FALSE;
    }
    if (command_name == "rename" ||
            command_name == "delete_outfit")
    {
        return (getCorrectListenerForAction() != NULL) && hasItemsSelected();
    }

    if (command_name == "wear")
    {
        if (isCOFPanelActive())
        {
            return FALSE;
        }
    }
    if (command_name == "make_outfit")
    {
        return TRUE;
    }

    if (command_name == "edit" ||
            command_name == "add"
       )
    {
        return (getCorrectListenerForAction() != NULL);
    }
    return TRUE;
}