void CNOutBarCtrl::insertItem(int folder, int pos, CNOutBarItem *item)
{
	if (folder >= 0 && folder < getFolderCount()) {
		vector<CNOutBarItem *> &items = folders[folder]->items;
		items.insert(items.begin() + pos, item);
	}
}
void CNOutBarCtrl::getFolderName(int i, CString &name)
{
	if (i >= 0 && i < getFolderCount())
		name = folders[i]->text;
}
void CNOutBarCtrl::setSelFolder(int i)
{
	if (i != selFolder && i < getFolderCount())
		selFolder = i;
}
void CNOutBarCtrl::addItem(int folder, const char *text, int image)
{
	if (folder >= 0 && folder < getFolderCount())
		folders[folder]->addItem(text, image);
}
void LLFloaterMarketplaceListings::updateView()
{
	U32 mkt_status = LLMarketplaceData::instance().getSLMStatus();
	bool is_merchant = (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MERCHANT) || (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MIGRATED_MERCHANT);
	U32 data_fetched = LLMarketplaceData::instance().getSLMDataFetched();

	// Get or create the root folder if we are a merchant and it hasn't been done already
	if (mRootFolderId.isNull() && is_merchant)
	{
		setRootFolder();
	}

	// Update the bottom initializing status and progress dial if we are initializing or if we're a merchant and still loading
	if ((mkt_status <= MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING) || (is_merchant && (data_fetched <= MarketplaceFetchCodes::MARKET_FETCH_LOADING)) )
	{
		// Just show the loading indicator in that case and fetch the data (fetch will be skipped if it's already loading)
		mInventoryInitializationInProgress->setVisible(true);
		mPanelListings->setVisible(FALSE);
		fetchContents();
		return;
	}
	else
	{
		mInventoryInitializationInProgress->setVisible(false);
	}

	// Update the middle portion : tabs or messages
	if (getFolderCount() > 0)
	{
		if (!mPanelListingsSet)
		{
			// We need to rebuild the tabs cleanly the first time we make them visible
			setPanels();
		}
		mPanelListings->setVisible(TRUE);
		mInventoryPlaceholder->setVisible(FALSE);
	}
	else
	{
		mPanelListings->setVisible(FALSE);
		mInventoryPlaceholder->setVisible(TRUE);

		std::string text;
		std::string title;
		std::string tooltip;

		const LLSD& subs = LLMarketplaceData::instance().getMarketplaceStringSubstitutions();

		// Update the top message or flip to the tabs and folders view
		// *TODO : check those messages and create better appropriate ones in strings.xml
		if (mRootFolderId.notNull())
		{
			// "Marketplace listings is empty!" message strings
			text = LLTrans::getString("InventoryMarketplaceListingsNoItems", subs);
			title = LLTrans::getString("InventoryMarketplaceListingsNoItemsTitle");
			tooltip = LLTrans::getString("InventoryMarketplaceListingsNoItemsTooltip");
		}
		else if (mkt_status <= MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING)
		{
			// "Initializing!" message strings
			text = LLTrans::getString("InventoryOutboxInitializing", subs);
			title = LLTrans::getString("InventoryOutboxInitializingTitle");
			tooltip = LLTrans::getString("InventoryOutboxInitializingTooltip");
		}
		else if (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT)
		{
			// "Not a merchant!" message strings
			text = LLTrans::getString("InventoryOutboxNotMerchant", subs);
			title = LLTrans::getString("InventoryOutboxNotMerchantTitle");
			tooltip = LLTrans::getString("InventoryOutboxNotMerchantTooltip");
		}
		else
		{
			// "Errors!" message strings
			text = LLTrans::getString("InventoryMarketplaceError", subs);
			title = LLTrans::getString("InventoryOutboxErrorTitle");
			tooltip = LLTrans::getString("InventoryOutboxErrorTooltip");
		}

		mInventoryText->setValue(text);
		mInventoryTitle->setValue(title);
		mInventoryPlaceholder->getParent()->setToolTip(tooltip);
	}
}