Esempio n. 1
0
void LLSidepanelAppearance::onOpenOutfitButtonClicked()
{
	const LLViewerInventoryItem *outfit_link = LLAppearanceMgr::getInstance()->getBaseOutfitLink();
	if (!outfit_link)
		return;
	if (!outfit_link->getIsLinkType())
		return;

	LLAccordionCtrlTab* tab_outfits = mPanelOutfitsInventory->findChild<LLAccordionCtrlTab>("tab_outfits");
	if (tab_outfits)
	{
		tab_outfits->changeOpenClose(FALSE);
		LLInventoryPanel *inventory_panel = tab_outfits->findChild<LLInventoryPanel>("outfitslist_tab");
		if (inventory_panel)
		{
			LLFolderView* root = inventory_panel->getRootFolder();
			LLFolderViewItem *outfit_folder = root->getItemByID(outfit_link->getLinkedUUID());
			if (outfit_folder)
			{
				outfit_folder->setOpen(!outfit_folder->isOpen());
				root->setSelectionFromRoot(outfit_folder,TRUE);
				root->scrollToShowSelection();
			}
		}
	}
}
LLFolderViewItem* LLLandmarksPanel::selectItemInAccordionTab(LLPlacesInventoryPanel* inventory_list,
															 const std::string& tab_name,
															 const LLUUID& obj_id,
															 BOOL take_keyboard_focus) const
{
	if (!inventory_list)
		return NULL;

	LLFolderView* root = inventory_list->getRootFolder();

	LLFolderViewItem* item = root->getItemByID(obj_id);
	if (!item)
		return NULL;

	LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(tab_name);
	if (!tab->isExpanded())
	{
		tab->changeOpenClose(false);
	}

	root->setSelection(item, FALSE, take_keyboard_focus);

	LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("landmarks_accordion");
	LLRect screen_rc;
	localRectToScreen(item->getRect(), &screen_rc);
	accordion->notifyParent(LLSD().with("scrollToShowRect", screen_rc.getValue()));

	return item;
}
void LLPanelOutfitEdit::saveListSelection()
{
	if(mWearablesListViewPanel->getVisible())
	{
		std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList();

		if(!selected_ids.size()) return;

		for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
		{
			mWearableItemsList->selectItemByUUID(*item_id, true);
		}
		mWearableItemsList->scrollToShowFirstSelectedItem();
	}
	else if(mInventoryItemsPanel->getVisible())
	{
		std::vector<LLUUID> selected_ids;
		mWearableItemsList->getSelectedUUIDs(selected_ids);

		if(!selected_ids.size()) return;

		mInventoryItemsPanel->clearSelection();
		LLFolderView* root = mInventoryItemsPanel->getRootFolder();

		if(!root) return;

		for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id)
		{
			LLFolderViewItem* item = root->getItemByID(*item_id);
			if (!item) continue;

			LLFolderViewFolder* parent = item->getParentFolder();
			if(parent)
			{
				parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP);
			}
			mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE);
		}
		mInventoryItemsPanel->getRootFolder()->scrollToShowSelection();
	}
}
BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
{
	const std::string command_name = userdata.asString();
	if (command_name == "delete")
	{
		BOOL can_delete = FALSE;
		LLFolderView* root = getActivePanel()->getRootFolder();
		if (root)
		{
			can_delete = TRUE;
			std::set<LLUUID> selection_set = root->getSelectionList();
			if (selection_set.empty()) return FALSE;
			for (std::set<LLUUID>::iterator iter = selection_set.begin();
				 iter != selection_set.end();
				 ++iter)
			{
				const LLUUID &item_id = (*iter);
				LLFolderViewItem *item = root->getItemByID(item_id);
				const LLFolderViewEventListener *listener = item->getListener();
				llassert(listener);
				if (!listener) return FALSE;
				can_delete &= listener->isItemRemovable();
				can_delete &= !listener->isItemInTrash();
			}
			return can_delete;
		}
		return FALSE;
	}
	if (command_name == "save_texture")
	{
		return isSaveTextureEnabled(userdata);
	}
	if (command_name == "find_original")
	{
		LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
		if (!current_item) return FALSE;
		const LLUUID& item_id = current_item->getListener()->getUUID();
		const LLViewerInventoryItem *item = gInventory.getItem(item_id);
		if (item && item->getIsLinkType() && !item->getIsBrokenLink())
		{
			return TRUE;
		}
		return FALSE;
	}

	if (command_name == "find_links")
	{
		LLFolderView* root = getActivePanel()->getRootFolder();
		std::set<LLUUID> selection_set = root->getSelectionList();
		if (selection_set.size() != 1) return FALSE;
		LLFolderViewItem* current_item = root->getCurSelectedItem();
		if (!current_item) return FALSE;
		const LLUUID& item_id = current_item->getListener()->getUUID();
		const LLInventoryObject *obj = gInventory.getObject(item_id);
		if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType()))
		{
			return TRUE;
		}
		return FALSE;
	}
	// This doesn't currently work, since the viewer can't change an assetID an item.
	if (command_name == "regenerate_link")
	{
		LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
		if (!current_item) return FALSE;
		const LLUUID& item_id = current_item->getListener()->getUUID();
		const LLViewerInventoryItem *item = gInventory.getItem(item_id);
		if (item && item->getIsBrokenLink())
		{
			return TRUE;
		}
		return FALSE;
	}

	if (command_name == "share")
	{
		LLSidepanelInventory* parent = dynamic_cast<LLSidepanelInventory*>(LLSideTray::getInstance()->getPanel("sidepanel_inventory"));
		return parent ? parent->canShare() : FALSE;
	}

	return TRUE;
}
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;
}