void LLPanelMarketplaceListings::buildAllPanels()
{
	// Build the All panel first
	LLInventoryPanel* panel_all_items;
	panel_all_items = buildInventoryPanel("All Items", "panel_marketplace_listings_inventory.xml");
	panel_all_items->getFilter().setEmptyLookupMessage("MarketplaceNoMatchingItems");
	panel_all_items->getFilter().markDefault();

	// Build the other panels
	LLInventoryPanel* panel;
	panel = buildInventoryPanel("Active Items", "panel_marketplace_listings_listed.xml");
	panel->getFilter().setFilterMarketplaceActiveFolders();
	panel->getFilter().setEmptyLookupMessage("MarketplaceNoMatchingItems");
	panel->getFilter().markDefault();
	panel = buildInventoryPanel("Inactive Items", "panel_marketplace_listings_unlisted.xml");
	panel->getFilter().setFilterMarketplaceInactiveFolders();
	panel->getFilter().setEmptyLookupMessage("MarketplaceNoMatchingItems");
	panel->getFilter().markDefault();
	panel = buildInventoryPanel("Unassociated Items", "panel_marketplace_listings_unassociated.xml");
	panel->getFilter().setFilterMarketplaceUnassociatedFolders();
	panel->getFilter().setEmptyLookupMessage("MarketplaceNoMatchingItems");
	panel->getFilter().markDefault();

	// Set the tab panel
	LLTabContainer* tabs_panel = getChild<LLTabContainer>("marketplace_filter_tabs");
	tabs_panel->setCommitCallback(boost::bind(&LLPanelMarketplaceListings::onTabChange, this));
	tabs_panel->selectTabPanel(panel_all_items);      // All panel selected by default
	mRootFolder = panel_all_items->getRootFolder();   // Keep the root of the all panel

	// Set the default sort order
	setSortOrder(gSavedSettings.getU32("MarketplaceListingsSortOrder"));
}
void LLPanelMarketplaceListings::onViewSortMenuItemClicked(const LLSD& userdata)
{
	std::string chosen_item = userdata.asString();

	// Sort options
	if ((chosen_item == "sort_by_stock_amount") || (chosen_item == "sort_by_name") || (chosen_item == "sort_by_recent"))
	{
		// We're making sort options exclusive, default is SO_FOLDERS_BY_NAME
		if (chosen_item == "sort_by_stock_amount")
		{
			setSortOrder(LLInventoryFilter::SO_FOLDERS_BY_WEIGHT);
		}
		else if (chosen_item == "sort_by_name")
		{
			setSortOrder(LLInventoryFilter::SO_FOLDERS_BY_NAME);
		}
		else if (chosen_item == "sort_by_recent")
		{
			setSortOrder(LLInventoryFilter::SO_DATE);
		}
	}
	// Filter option
	else if (chosen_item == "show_only_listing_folders")
	{
		mFilterListingFoldersOnly = !mFilterListingFoldersOnly;
		// Set each panel with that filter flag
		LLTabContainer* tabs_panel = getChild<LLTabContainer>("marketplace_filter_tabs");
		LLInventoryPanel* panel = (LLInventoryPanel*)tabs_panel->getPanelByName("All Items");
		panel->getFilter().setFilterMarketplaceListingFolders(mFilterListingFoldersOnly);
		panel = (LLInventoryPanel*)tabs_panel->getPanelByName("Active Items");
		panel->getFilter().setFilterMarketplaceListingFolders(mFilterListingFoldersOnly);
		panel = (LLInventoryPanel*)tabs_panel->getPanelByName("Inactive Items");
		panel->getFilter().setFilterMarketplaceListingFolders(mFilterListingFoldersOnly);
		panel = (LLInventoryPanel*)tabs_panel->getPanelByName("Unassociated Items");
		panel->getFilter().setFilterMarketplaceListingFolders(mFilterListingFoldersOnly);
	}
}