summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-04-08 18:12:48 -0700
committerMerov Linden <merov@lindenlab.com>2014-04-08 18:12:48 -0700
commitfc4e9d2572635903449ade6ebf2a45aa9e971023 (patch)
treec0abd7a79760e437fa89ed1fbd1ab054d2eea8fe /indra
parent8d20027ff904a29c9fb573372f89839bcab5a0c0 (diff)
DD-18 : Compute stock for all levels, get folders to update more consistently on all actions in the marketplace
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llinventorybridge.cpp24
-rwxr-xr-xindra/newview/llinventoryfunctions.cpp87
-rwxr-xr-xindra/newview/llinventoryfunctions.h1
-rwxr-xr-xindra/newview/llinventorymodel.cpp2
-rwxr-xr-xindra/newview/skins/default/xui/en/strings.xml1
5 files changed, 78 insertions, 37 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 8d87b40e4e..7ff0a445e8 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -652,7 +652,6 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
items.push_back(std::string("Rename"));
if (!isItemRenameable() || ((flags & FIRST_SELECTED_ITEM) == 0))
{
- llinfos << "Merov : rename disable, renameable = " << isItemRenameable() << ", flags = " << flags << llendl;
disabled_items.push_back(std::string("Rename"));
}
}
@@ -851,7 +850,6 @@ void LLInvFVBridge::addMarketplaceContextMenuOptions(U32 flags,
menuentry_vec_t &disabled_items)
{
S32 depth = depth_nesting_in_marketplace(mUUID);
- llinfos << "Merov : adding marketplace menu at depth = " << depth << llendl;
if (depth == 1)
{
// Options available at the Listing Folder level
@@ -2026,11 +2024,11 @@ std::string LLFolderBridge::getLabelSuffix() const
{
if (isMarketplaceListingsFolder())
{
+ std::string suffix = "";
// Listing folder case
if (LLMarketplaceData::instance().isListed(getUUID()))
{
- //llinfos << "Merov : in merchant folder and listed : id = " << getUUID() << llendl;
- std::string suffix = LLMarketplaceData::instance().getListingID(getUUID());
+ suffix = LLMarketplaceData::instance().getListingID(getUUID());
if (suffix.empty())
{
suffix = LLTrans::getString("MarketplaceNoID");
@@ -2040,31 +2038,25 @@ std::string LLFolderBridge::getLabelSuffix() const
{
suffix += " (" + LLTrans::getString("MarketplaceActive") + ")";
}
- return LLInvFVBridge::getLabelSuffix() + suffix;
}
// Version folder case
else if (LLMarketplaceData::instance().isVersionFolder(getUUID()))
{
- std::string suffix;
if (LLMarketplaceData::instance().getActivationState(getUUID()))
{
suffix += " (" + LLTrans::getString("MarketplaceActive") + ")";
}
- return LLInvFVBridge::getLabelSuffix() + suffix;
}
- // Stock folder case
- else if (getCategory()->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
+ S32 stock_count = compute_stock_count(getUUID());
+ if (stock_count == 0)
{
- //llinfos << "Merov : getLabelSuffix : stock folder : name = " << getCategory()->getName() << ", stock = " << getCategory()->getDescendentCount() << llendl;
- std::string stock = llformat("%d", getCategory()->getDescendentCount());
- std::string suffix = " (" + LLTrans::getString("MarketplaceStock") + ") (" + stock + ")";
- return LLInvFVBridge::getLabelSuffix() + suffix;
+ suffix += " (" + LLTrans::getString("MarketplaceNoStock") + ")";
}
- else
+ else if (stock_count != -1)
{
- //llinfos << "Merov : in merchant folder but not listed : id = " << getUUID() << llendl;
- return LLInvFVBridge::getLabelSuffix();
+ suffix += " (" + LLTrans::getString("MarketplaceStock") + "=" + llformat("%d", stock_count) + ")";
}
+ return LLInvFVBridge::getLabelSuffix() + suffix;
}
else
{
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index aef3bc9cca..20cbb06f07 100755
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -122,14 +122,31 @@ void append_path(const LLUUID& id, std::string& path)
void update_marketplace_category(const LLUUID& cat_id)
{
// When changing the marketplace status of a folder, the only thing that needs to happen is
- // for all observers of the folder to, possibly, change the display label of said folder.
- // At least that's the status for the moment so, even if that function seems small, we
- // prefer to encapsulate that behavior here.
- if (cat_id.notNull())
+ // for all observers of the folder to, possibly, change the display label of the folder
+ // as well as, potentially, change the display label of all parent folders up to the marketplace root.
+
+ const LLUUID marketplace_listings_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
+ // No marketplace, likely called in error then...
+ // Or not a descendent of the marketplace listings root, then just do the regular category update
+ if (marketplace_listings_uuid.isNull() || !gInventory.isObjectDescendentOf(cat_id, marketplace_listings_uuid))
+ {
+ LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
+ gInventory.updateCategory(cat);
+ gInventory.notifyObservers();
+ return;
+ }
+ // Explore all the hierarchy of folders up to the root to get them to update
+ // Note: this is not supposed to be deeper than 4
+ LLUUID cur_id = cat_id;
+ LLInventoryCategory* cur_cat = gInventory.getCategory(cur_id);
+ while (cur_id != marketplace_listings_uuid)
{
- gInventory.addChangedMask(LLInventoryObserver::LABEL, cat_id);
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, cur_id);
gInventory.notifyObservers();
+ cur_id = cur_cat->getParentUUID();
+ cur_cat = gInventory.getCategory(cur_id);
}
+ return;
}
void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name)
@@ -748,6 +765,41 @@ LLUUID nested_parent_id(LLUUID cur_uuid, S32 depth)
return cur_uuid;
}
+S32 compute_stock_count(LLUUID cat_uuid)
+{
+ LLInventoryModel::cat_array_t* cat_array;
+ LLInventoryModel::item_array_t* item_array;
+ gInventory.getDirectDescendentsOf(cat_uuid,cat_array,item_array);
+
+ // "-1" denotes a folder that doesn't countain any stock folders in its descendents
+ S32 curr_count = -1;
+
+ LLInventoryCategory* cat = gInventory.getCategory(cat_uuid);
+
+ if (cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
+ {
+ // Note: stock folders are *not* supposed to have nested subfolders so we stop recursion here
+ LLViewerInventoryCategory * viewer_cat = (LLViewerInventoryCategory *) (cat);
+ curr_count = viewer_cat->getDescendentCount();
+ }
+ else
+ {
+ // Note: marketplace listings have a maximum depth nesting of 4
+ LLInventoryModel::cat_array_t cat_array_copy = *cat_array;
+ for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++)
+ {
+ LLInventoryCategory* category = *iter;
+ S32 count = compute_stock_count(category->getUUID());
+ if ((curr_count == -1) || ((count != -1) && (count < curr_count)))
+ {
+ curr_count = count;
+ }
+ }
+ }
+
+ return curr_count;
+}
+
void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder, bool copy)
{
// Get the marketplace listings, exit with error if none
@@ -792,7 +844,6 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
// Get the parent folder of the moved item : we may have to update it
LLUUID src_folder = viewer_inv_item->getParentUUID();
- LLViewerInventoryCategory* src_cat = gInventory.getCategory(src_folder);
if (copy)
{
@@ -812,13 +863,12 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
gInventory.changeItemParent(viewer_inv_item, dest_folder, false);
}
- // Update the modified folders
- gInventory.updateCategory(src_cat);
- gInventory.updateCategory(dest_cat);
- gInventory.notifyObservers();
-
// Validate the destination : note that this will run the validation code only on one listing folder at most...
validate_marketplacelistings(dest_cat);
+
+ // Update the modified folders
+ update_marketplace_category(src_folder);
+ update_marketplace_category(dest_folder);
}
else
{
@@ -839,7 +889,6 @@ void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU
// Get the parent folder of the moved item : we may have to update it
LLUUID src_folder = inv_cat->getParentUUID();
- LLViewerInventoryCategory* src_cat = gInventory.getCategory(src_folder);
LLViewerInventoryCategory * viewer_inv_cat = (LLViewerInventoryCategory *) inv_cat;
if (copy)
@@ -853,13 +902,12 @@ void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU
gInventory.changeCategoryParent(viewer_inv_cat, dest_folder, false);
}
- // Update the modified folders
- gInventory.updateCategory(src_cat);
- gInventory.updateCategory(dest_cat);
- gInventory.notifyObservers();
-
// Check the destination folder recursively for no copy items and promote the including folders if any
validate_marketplacelistings(dest_cat);
+
+ // Update the modified folders
+ update_marketplace_category(src_folder);
+ update_marketplace_category(dest_folder);
}
}
@@ -948,9 +996,8 @@ void validate_marketplacelistings(LLInventoryCategory* cat)
stock_folder_cat = gInventory.getCategory(stock_folder_uuid);
}
gInventory.changeItemParent(viewer_inv_item, stock_folder_uuid, false);
- gInventory.updateCategory(viewer_cat);
- gInventory.updateCategory(stock_folder_cat);
- gInventory.notifyObservers();
+ update_marketplace_category(viewer_cat->getUUID());
+ update_marketplace_category(stock_folder_uuid);
}
}
diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index 69219c7c42..66f1c99630 100755
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -78,6 +78,7 @@ bool has_correct_permissions_for_sale(LLInventoryCategory* cat);
void validate_marketplacelistings(LLInventoryCategory* inv_cat);
S32 depth_nesting_in_marketplace(LLUUID cur_uuid);
LLUUID nested_parent_id(LLUUID cur_uuid, S32 depth);
+S32 compute_stock_count(LLUUID cat_uuid);
/** Miscellaneous global functions
** **
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 96a2db5afb..c0aedd3881 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -1013,7 +1013,7 @@ LLInventoryModel::item_array_t* LLInventoryModel::getUnlockedItemArray(const LLU
// an existing item with the matching id, or it will add the category.
void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
{
- if(cat->getUUID().isNull())
+ if(!cat || cat->getUUID().isNull())
{
return;
}
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index ce9bbbc8d2..55272750e7 100755
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -2274,6 +2274,7 @@ The [[MARKETPLACE_CREATE_STORE_URL] Marketplace store] is returning errors.
<string name="MarketplaceNoID">no Mkt ID</string>
<string name="MarketplaceActive">live</string>
<string name="MarketplaceStock">stock</string>
+ <string name="MarketplaceNoStock">out of stock</string>
<string name="Open landmarks">Open landmarks</string>