From 03622e0833fd2d2bdcc9ed3ed0c009ad9e9fee3e Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Thu, 20 Mar 2014 09:31:35 -0700
Subject: DD-50 : Adding new filter code for marketplace filtered tabs (active,
 unactive and unassociated)

---
 indra/newview/llfloateroutbox.cpp                  | 32 +++++++-----
 indra/newview/llinventoryfilter.cpp                | 58 ++++++++++++++++++++++
 indra/newview/llinventoryfilter.h                  |  8 ++-
 .../en/panel_marketplace_listings_inventory.xml    |  2 +-
 4 files changed, 85 insertions(+), 15 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp
index 92c120a0b6..d6da0ad971 100755
--- a/indra/newview/llfloateroutbox.cpp
+++ b/indra/newview/llfloateroutbox.cpp
@@ -831,16 +831,9 @@ void LLFloaterMarketplaceListings::setup()
 	llassert(mCategoriesObserver);
 	
 	// Set up the marketplace listings inventory view
-//	LLInventoryPanel* inventory_panel = mInventoryPanel.get();
-//    if (inventory_panel)
-//    {
-//        delete inventory_panel;
-//    }
-//    inventory_panel = LLUICtrlFactory::createFromFile<LLInventoryPanel>("panel_marketplace_listings_inventory.xml", mInventoryPlaceholder->getParent(), LLInventoryPanel::child_registry_t::instance());
-//    mInventoryPanel = inventory_panel->getInventoryPanelHandle();
     LLPanel* inventory_panel = LLUICtrlFactory::createFromFile<LLPanel>("panel_marketplace_listings_inventory.xml", mInventoryPlaceholder->getParent(), LLInventoryPanel::child_registry_t::instance());
-	LLInventoryPanel* all_items_panel = inventory_panel->getChild<LLInventoryPanel>("All Items");
-    mInventoryPanel = all_items_panel->getInventoryPanelHandle();
+	LLInventoryPanel* items_panel = inventory_panel->getChild<LLInventoryPanel>("All Items");
+    mInventoryPanel = items_panel->getInventoryPanelHandle();
 	llassert(mInventoryPanel.get() != NULL);
 	
 	// Reshape the inventory to the proper size
@@ -848,9 +841,23 @@ void LLFloaterMarketplaceListings::setup()
 	inventory_panel->setShape(inventory_placeholder_rect);
 	
 	// Set the sort order newest to oldest
-	all_items_panel->getFolderViewModel()->setSorter(LLInventoryFilter::SO_FOLDERS_BY_NAME);
-	all_items_panel->getFilter().markDefault();
+	items_panel->getFolderViewModel()->setSorter(LLInventoryFilter::SO_FOLDERS_BY_NAME);
+	items_panel->getFilter().markDefault();
     
+    // Set filters on the 3 prefiltered panels
+	items_panel = inventory_panel->getChild<LLInventoryPanel>("Active Items");
+	items_panel->getFolderViewModel()->setSorter(LLInventoryFilter::SO_FOLDERS_BY_NAME);
+	items_panel->getFilter().setFilterMarketplaceActiveFolders();
+	items_panel->getFilter().markDefault();
+	items_panel = inventory_panel->getChild<LLInventoryPanel>("Inactive Items");
+	items_panel->getFolderViewModel()->setSorter(LLInventoryFilter::SO_FOLDERS_BY_NAME);
+	items_panel->getFilter().setFilterMarketplaceInactiveFolders();
+	items_panel->getFilter().markDefault();
+	items_panel = inventory_panel->getChild<LLInventoryPanel>("Unassociated Items");
+	items_panel->getFolderViewModel()->setSorter(LLInventoryFilter::SO_FOLDERS_BY_NAME);
+	items_panel->getFilter().setFilterMarketplaceUnassociatedFolders();
+	items_panel->getFilter().markDefault();
+
 	// Get the content of the marketplace listings folder
 	fetchContents();
 }
@@ -969,8 +976,7 @@ BOOL LLFloaterMarketplaceListings::handleDragAndDrop(S32 x, S32 y, MASK mask, BO
 										EAcceptance* accept,
 										std::string& tooltip_msg)
 {
-	if ((mInventoryPanel.get() == NULL) ||
-        mRootFolderId.isNull())
+	if ((mInventoryPanel.get() == NULL) || mRootFolderId.isNull())
 	{
 		return FALSE;
 	}
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index 3c6974cf6d..284c354fc6 100755
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -33,6 +33,7 @@
 #include "llfolderviewitem.h"
 #include "llinventorymodel.h"
 #include "llinventorymodelbackgroundfetch.h"
+#include "llmarketplacefunctions.h"
 #include "llviewercontrol.h"
 #include "llfolderview.h"
 #include "llinventorybridge.h"
@@ -243,6 +244,48 @@ bool LLInventoryFilter::checkAgainstFilterType(const LLFolderViewModelItemInvent
 			}
 		}
 	}
+
+	////////////////////////////////////////////////////////////////////////////////
+	// FILTERTYPE_MARKETPLACE_ACTIVE
+	// Pass if this item is a folder and is active
+	if (filterTypes & FILTERTYPE_MARKETPLACE_ACTIVE)
+	{
+		if (object_type == LLInventoryType::IT_CATEGORY)
+		{
+			if (LLMarketplaceData::instance().getActivationState(object_id))
+			{
+				return FALSE;
+			}
+		}
+	}
+	
+	////////////////////////////////////////////////////////////////////////////////
+	// FILTERTYPE_MARKETPLACE_INACTIVE
+	// Pass if this item is a folder and is not active
+	if (filterTypes & FILTERTYPE_MARKETPLACE_INACTIVE)
+	{
+		if (object_type == LLInventoryType::IT_CATEGORY)
+		{
+			if (!LLMarketplaceData::instance().getActivationState(object_id))
+			{
+				return FALSE;
+			}
+		}
+	}
+	
+	////////////////////////////////////////////////////////////////////////////////
+	// FILTERTYPE_MARKETPLACE_UNASSOCIATED
+	// Pass if this item is a folder and is active
+	if (filterTypes & FILTERTYPE_MARKETPLACE_UNASSOCIATED)
+	{
+		if (object_type == LLInventoryType::IT_CATEGORY)
+		{
+			if (LLMarketplaceData::instance().getListingID(object_id).empty())
+			{
+				return FALSE;
+			}
+		}
+	}
 	
 	return TRUE;
 }
@@ -468,6 +511,21 @@ void LLInventoryFilter::setFilterEmptySystemFolders()
 	mFilterOps.mFilterTypes |= FILTERTYPE_EMPTYFOLDERS;
 }
 
+void LLInventoryFilter::setFilterMarketplaceActiveFolders()
+{
+	mFilterOps.mFilterTypes |= FILTERTYPE_MARKETPLACE_ACTIVE;
+}
+
+void LLInventoryFilter::setFilterMarketplaceInactiveFolders()
+{
+	mFilterOps.mFilterTypes |= FILTERTYPE_MARKETPLACE_INACTIVE;
+}
+
+void LLInventoryFilter::setFilterMarketplaceUnassociatedFolders()
+{
+	mFilterOps.mFilterTypes |= FILTERTYPE_MARKETPLACE_UNASSOCIATED;
+}
+
 void LLInventoryFilter::setFilterUUID(const LLUUID& object_id)
 {
 	if (mFilterOps.mFilterUUID == LLUUID::null)
diff --git a/indra/newview/llinventoryfilter.h b/indra/newview/llinventoryfilter.h
index ce516af0b9..e553355036 100755
--- a/indra/newview/llinventoryfilter.h
+++ b/indra/newview/llinventoryfilter.h
@@ -52,7 +52,10 @@ public:
 		FILTERTYPE_UUID	= 0x1 << 2,		// find the object with UUID and any links to it
 		FILTERTYPE_DATE = 0x1 << 3,		// search by date range
 		FILTERTYPE_WEARABLE = 0x1 << 4,	// search by wearable type
-		FILTERTYPE_EMPTYFOLDERS = 0x1 << 5		// pass if folder is not a system   folder to be hidden if
+		FILTERTYPE_EMPTYFOLDERS = 0x1 << 5,		// pass if folder is not a system folder to be hidden if empty
+        FILTERTYPE_MARKETPLACE_ACTIVE = 0x1 << 6,		// pass if folder is a marketplace active folder
+        FILTERTYPE_MARKETPLACE_INACTIVE = 0x1 << 7,		// pass if folder is a marketplace inactive folder
+        FILTERTYPE_MARKETPLACE_UNASSOCIATED = 0x1 << 8	// pass if folder is a marketplace non associated (no market ID) folder
 	};
 
 	enum EFilterLink
@@ -160,6 +163,9 @@ public:
 	void 				setFilterUUID(const LLUUID &object_id);
 	void				setFilterWearableTypes(U64 types);
 	void				setFilterEmptySystemFolders();
+	void				setFilterMarketplaceActiveFolders();
+	void				setFilterMarketplaceInactiveFolders();
+	void				setFilterMarketplaceUnassociatedFolders();
 	void				updateFilterTypes(U64 types, U64& current_types);
 
 	void 				setFilterSubString(const std::string& string);
diff --git a/indra/newview/skins/default/xui/en/panel_marketplace_listings_inventory.xml b/indra/newview/skins/default/xui/en/panel_marketplace_listings_inventory.xml
index 89020c7e80..3c184ba54b 100755
--- a/indra/newview/skins/default/xui/en/panel_marketplace_listings_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_marketplace_listings_inventory.xml
@@ -37,7 +37,7 @@
     width="308"
     height="340">
   <tab_container
-    name="inventory filter tabs"
+    name="marketplace filter tabs"
     follows="all"
     layout="topleft"
     top="0"
-- 
cgit v1.2.3