// virtual
void LLPanelOutfitsInventory::onSearchEdit(const std::string& string)
{
    mFilterSubString = string;
    if (string == "")
    {
        mActivePanel->setFilterSubString(LLStringUtil::null);

        // re-open folders that were initially open
        mSavedFolderState->setApply(TRUE);
        getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
        LLOpenFoldersWithSelection opener;
        getRootFolder()->applyFunctorRecursively(opener);
        getRootFolder()->scrollToShowSelection();
    }

    gInventory.startBackgroundFetch();

    if (mActivePanel->getFilterSubString().empty() && string.empty())
    {
        // current filter and new filter empty, do nothing
        return;
    }

    // save current folder open state if no filter currently applied
    if (getRootFolder()->getFilterSubString().empty())
    {
        mSavedFolderState->setApply(FALSE);
        getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
    }

    // set new filter string
    mActivePanel->setFilterSubString(string);
}
void LLPanelOutfitsInventory::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action)
{
    updateVerbs();
    if (getRootFolder()->needsAutoRename() && items.size())
    {
        getRootFolder()->startRenamingSelectedItem();
        getRootFolder()->setNeedsAutoRename(FALSE);
    }
}
void LLInventoryPanel::onSelectionChange(const std::deque<LLFolderViewItem*>& items, BOOL user_action)
{
	// Schedule updating the folder view context menu when all selected items become complete (STORM-373).
	mCompletionObserver->reset();
	for (std::deque<LLFolderViewItem*>::const_iterator it = items.begin(); it != items.end(); ++it)
	{
		LLUUID id = (*it)->getListener()->getUUID();
		LLViewerInventoryItem* inv_item = mInventory->getItem(id);

		if (inv_item && !inv_item->isFinished())
		{
			mCompletionObserver->watchItem(id);
		}
	}

	LLFolderView* fv = getRootFolder();
	if (fv->needsAutoRename()) // auto-selecting a new user-created asset and preparing to rename
	{
		fv->setNeedsAutoRename(FALSE);
		if (items.size()) // new asset is visible and selected
		{
			fv->startRenamingSelectedItem();
		}
	}
}
LLFolderViewEventListener *LLPanelOutfitsInventory::getCorrectListenerForAction()
{
    LLFolderViewItem* current_item = getRootFolder()->getCurSelectedItem();
    if (!current_item)
        return NULL;

    LLFolderViewEventListener* listenerp = current_item->getListener();
    if (getIsCorrectType(listenerp))
    {
        return listenerp;
    }
    return NULL;
}
void LLPanelOutfitsInventory::onSelectorButtonClicked()
{
    LLFolderViewItem* cur_item = getRootFolder()->getCurSelectedItem();

    LLFolderViewEventListener* listenerp = cur_item->getListener();
    if (getIsCorrectType(listenerp))
    {
        LLSD key;
        key["type"] = "look";
        key["id"] = listenerp->getUUID();

        LLSideTray::getInstance()->showPanel("sidepanel_appearance", key);
    }
}
BOOL LLPanelMarketplaceListings::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
					   EDragAndDropType cargo_type,
					   void* cargo_data,
					   EAcceptance* accept,
					   std::string& tooltip_msg)
{
	LLView * handled_view = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
	BOOL handled = (handled_view != NULL);
	// Special case the drop zone
	if (handled && (handled_view->getName() == "marketplace_drop_zone"))
	{
		LLFolderView* root_folder = getRootFolder();
		handled = root_folder->handleDragAndDropToThisFolder(mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
	}
	return handled;
}
	string WindowDataLayer::convet2CaffeFormat()
	{
		string layerStrStart = "layer\n{\n";
		string layerStrEnd = "}";

		string nameStrStart = "\tname: \"";
		string nameStrEnd = "\"\n";

		string typeStrStart = "\ttype: \"";
		string typeStrEnd = "\"\n";

		string topStrStart = "\ttop: \"";
		string topStrEnd = "\"\n";

		string bottomStrStart = "\tbottom: \"";
		string bottomStrEnd = "\"\n";

		string WindowDataParamStrStart = "\twindow_data_param\n\t{\n";
		string WindowDataParamStrEnd = "\t}\n";

		string SourceStrStart = "\t\tsource: ";
		string SourceStrEnd = "\n";

		string ScaleStrStart = "\t\tscale: ";
		string ScaleStrEnd = "\n";

		string MeanFileStrStart = "\t\tmean_file: ";
		string MeanFileStrEnd = "\n";

		string BatchSizeStrStart = "\t\tbatch_size: ";
		string BatchSizeStrEnd = "\n";

		string CropSizeStrStart = "\t\tcrop_size: ";
		string CropSizeStrEnd = "\n";

		string MirrorStrStart = "\t\tmirror: ";
		string MirrorStrEnd = "\n";

		string FgThresholdStrStrat = "\t\tfg_threshold: ";
		string FgThresholdStrEnd = "\n";

		string BgThresholdStrStrat = "\t\tbg_threshold: ";
		string BgThresholdStrEnd = "\n";

		string FgFractionStrStart = "\t\tfg_fraction: ";
		string FgFractionStrEnd = "\n";

		string ContextPadStrStart = "\t\tcontext_pad: "; 
		string ContextPadStrEnd = "\n";

		string CropModeStrStart = "\t\tcrop_mode: ";
		string CropModeStrEnd = "\n";

		string CacheImagesStrStart = "\t\tcache_images: ";
		string CacheImagesStrEnd = "\n";

		string RootFolderStrStart = "\t\troot_folder: ";
		string RootFolderStrEnd = "\n";

		string phaseStrStart = "\tinclude:\n\t{\n";		
		string phaseStrEnd = "\t}\n";

		string phaseStateStrStart = "\t\tphase: ";
		string phaseStateStrEnd = "\n";

		string outStr =  layerStrStart + 
						 nameStrStart + mName + nameStrEnd + 
						 typeStrStart + getLayerType() + typeStrEnd;

		for(size_t i = 0; i < mTops->size(); i++)
		{
			outStr = outStr + topStrStart + (*mTops)[i] + topStrEnd;
		}

		for(size_t i = 0; i < mBottoms->size(); i++)
		{
			outStr = outStr + bottomStrStart + (*mBottoms)[i] +bottomStrEnd;
		}

		outStr += WindowDataParamStrStart;

		if (getSource() == "")
		{

		}
		else
		{
			outStr += SourceStrStart + "\"" + getSource() + "\"" + SourceStrEnd;;
		}

		if(((WindowDataParam*)mParam)->mScale != 1)
		{
			outStr += ScaleStrStart + to_string(getScale()) + ScaleStrEnd;
		}
		
		if (getMeanFile() == "")
		{

		}
		else
		{
			outStr += MeanFileStrStart + "\"" + getMeanFile() + "\"" + MeanFileStrEnd;
		}

		outStr += BatchSizeStrStart + to_string(getBatchSize()) + BatchSizeStrEnd;

		if(((WindowDataParam*)mParam)->mCropSize != 0)
		{
			outStr += CropSizeStrStart + to_string(getCropSize()) + CropSizeStrEnd;
		}

		if(((WindowDataParam*)mParam)->mMirror != false)
		{
			outStr += MirrorStrStart + "true" + MirrorStrEnd;
		}

		if(((WindowDataParam*)mParam)->mFgThreshold != 0.5)
		{
			outStr += FgThresholdStrStrat + to_string(getFgThreshold()) + FgFractionStrEnd;
		}

		if(((WindowDataParam*)mParam)->mBgThreshold != 0.5)
		{
			outStr += BgThresholdStrStrat + to_string(getBgThreshold()) + BgThresholdStrEnd;
		}

		if(((WindowDataParam*)mParam)->mFgFraction != 0.25)
		{
			outStr += FgFractionStrStart + to_string(getFgFraction()) + FgFractionStrEnd;
		}

		if(((WindowDataParam*)mParam)->mContextPad != 0)
		{
			outStr += ContextPadStrStart + to_string(getContextPad()) + ContextPadStrEnd;
		}

		if(((WindowDataParam*)mParam)->mCropMode != CropMode::WARP)
		{
			outStr += CropModeStrStart + "\"" + "square" + "\"" + CropModeStrEnd;
		}
		
		if(((WindowDataParam*)mParam)->mCacheImages != false)
		{
			outStr +=  CacheImagesStrStart + "true" + CacheImagesStrEnd;
		}

		if(((WindowDataParam*)mParam)->mRootFolder != "")
		{
			outStr +=  RootFolderStrStart + "\"" + getRootFolder() + "\"" + RootFolderStrEnd ;
		}

		outStr += WindowDataParamStrEnd;

		if (mPhase != Phase::BOTH)
		{
			outStr += phaseStrStart + phaseStateStrStart;

			if (mPhase == Phase::TRAIN)
			{
				outStr += "TRAIN";
			}
			else if (mPhase == Phase::TEST)
			{
				outStr += "TEST";
			}

			outStr += phaseStateStrEnd + phaseStrEnd;
		}
		
		outStr += layerStrEnd;
		
		return outStr;
	}