STORM-2091 "Empty Trash"/"Empty Lost and Found" menu item is active even if empty

master
Jonathan Yap 2014-12-10 11:09:28 -05:00
parent 68413474c4
commit 0db6788347
4 changed files with 33 additions and 0 deletions

View File

@ -751,6 +751,7 @@ Jonathan Yap
STORM-2088
STORM-2094
STORM-2099
STORM-2091
Kadah Coba
STORM-1060
STORM-1843

View File

@ -3736,6 +3736,14 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
// This is the lost+found folder.
items.push_back(std::string("Empty Lost And Found"));
LLInventoryModel::cat_array_t* cat_array;
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array);
if (0 == cat_array->size() && 0 == item_array->size())
{
disabled_items.push_back(std::string("Empty Lost And Found"));
}
disabled_items.push_back(std::string("New Folder"));
disabled_items.push_back(std::string("New Script"));
disabled_items.push_back(std::string("New Note"));
@ -3780,6 +3788,14 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items
{
// This is the trash.
items.push_back(std::string("Empty Trash"));
LLInventoryModel::cat_array_t* cat_array;
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array);
if (0 == cat_array->size() && 0 == item_array->size())
{
disabled_items.push_back(std::string("Empty Trash"));
}
}
else if(isItemInTrash())
{

View File

@ -1194,6 +1194,16 @@ bool LLPanelMainInventory::isSaveTextureEnabled(const LLSD& userdata)
BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
{
const std::string command_name = userdata.asString();
if (command_name == "not_empty")
{
LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
if (!current_item) return FALSE;
const LLUUID& item_id = static_cast<LLFolderViewModelItemInventory*>(current_item->getViewModelItem())->getUUID();
LLInventoryModel::cat_array_t* cat_array;
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(item_id, cat_array, item_array);
return (0 == cat_array->size() && 0 == item_array->size());
}
if (command_name == "delete")
{
return getActivePanel()->isSelectionRemovable();

View File

@ -95,6 +95,9 @@
<on_click
function="Inventory.GearDefault.Custom.Action"
parameter="empty_lostnfound" />
<on_enable
function="Inventory.GearDefault.Enable"
parameter="not_empty" />
</menu_item_call>
<menu_item_separator
layout="topleft" />
@ -152,5 +155,8 @@
<on_click
function="Inventory.GearDefault.Custom.Action"
parameter="empty_trash" />
<on_enable
function="Inventory.GearDefault.Enable"
parameter="not_empty" />
</menu_item_call>
</toggleable_menu>