STORM-383 FIXED Added "Restore Item" context menu entry for landmarks and folders in Trash category in Places->My Landmarks->My Inventory accordion tab.
parent
7314ad41be
commit
7461f1ca2b
|
|
@ -71,6 +71,7 @@ static void collapse_all_folders(LLFolderView* root_folder);
|
|||
static void expand_all_folders(LLFolderView* root_folder);
|
||||
static bool has_expanded_folders(LLFolderView* root_folder);
|
||||
static bool has_collapsed_folders(LLFolderView* root_folder);
|
||||
static void toggle_restore_menu(LLMenuGL* menu, BOOL visible, BOOL enabled);
|
||||
|
||||
/**
|
||||
* Functor counting expanded and collapsed folders in folder view tree to know
|
||||
|
|
@ -708,6 +709,9 @@ void LLLandmarksPanel::initListCommandsHandlers()
|
|||
mGearFolderMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_places_gear_folder.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
|
||||
mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_place_add_button.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
|
||||
|
||||
mGearLandmarkMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
|
||||
mGearFolderMenu->setVisibilityChangeCallback(boost::bind(&LLLandmarksPanel::onMenuVisibilityChange, this, _1, _2));
|
||||
|
||||
mListCommands->childSetAction(ADD_BUTTON_NAME, boost::bind(&LLLandmarksPanel::showActionMenu, this, mMenuAdd, ADD_BUTTON_NAME));
|
||||
}
|
||||
|
||||
|
|
@ -1079,6 +1083,60 @@ void LLLandmarksPanel::onCustomAction(const LLSD& userdata)
|
|||
{
|
||||
doActionOnCurSelectedLandmark(boost::bind(&LLLandmarksPanel::doCreatePick, this, _1));
|
||||
}
|
||||
else if ("restore" == command_name && mCurrentSelectedList)
|
||||
{
|
||||
mCurrentSelectedList->doToSelected(userdata);
|
||||
}
|
||||
}
|
||||
|
||||
void LLLandmarksPanel::onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param)
|
||||
{
|
||||
bool new_visibility = param["visibility"].asBoolean();
|
||||
|
||||
// We don't have to update items visibility if the menu is hiding.
|
||||
if (!new_visibility) return;
|
||||
|
||||
BOOL are_any_items_in_trash = FALSE;
|
||||
BOOL are_all_items_in_trash = TRUE;
|
||||
|
||||
LLFolderView* root_folder_view = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : NULL;
|
||||
if(root_folder_view)
|
||||
{
|
||||
const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
|
||||
|
||||
std::set<LLUUID> selected_uuids = root_folder_view->getSelectionList();
|
||||
|
||||
// Iterate through selected items to find out if any of these items are in Trash
|
||||
// or all the items are in Trash category.
|
||||
for (std::set<LLUUID>::const_iterator iter = selected_uuids.begin(); iter != selected_uuids.end(); ++iter)
|
||||
{
|
||||
LLFolderViewItem* item = root_folder_view->getItemByID(*iter);
|
||||
|
||||
// If no item is found it might be a folder id.
|
||||
if (!item)
|
||||
{
|
||||
item = root_folder_view->getFolderByID(*iter);
|
||||
}
|
||||
if (!item) continue;
|
||||
|
||||
LLFolderViewEventListener* listenerp = item->getListener();
|
||||
if(!listenerp) continue;
|
||||
|
||||
// Trash category itself should not be included because it can't be
|
||||
// actually restored from trash.
|
||||
are_all_items_in_trash &= listenerp->isItemInTrash() && *iter != trash_id;
|
||||
|
||||
// If there are any selected items in Trash including the Trash category itself
|
||||
// we show "Restore Item" in context menu and hide other irrelevant items.
|
||||
are_any_items_in_trash |= listenerp->isItemInTrash();
|
||||
}
|
||||
}
|
||||
|
||||
// Display "Restore Item" menu entry if at least one of the selected items
|
||||
// is in Trash or the Trash category itself is among selected items.
|
||||
// Hide other menu entries in this case.
|
||||
// Enable this menu entry only if all selected items are in the Trash category.
|
||||
toggle_restore_menu((LLMenuGL*)ctrl, are_any_items_in_trash, are_all_items_in_trash);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1414,4 +1472,31 @@ static bool has_collapsed_folders(LLFolderView* root_folder)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Displays "Restore Item" context menu entry while hiding
|
||||
// all other entries or vice versa.
|
||||
// Sets "Restore Item" enabled state.
|
||||
void toggle_restore_menu(LLMenuGL *menu, BOOL visible, BOOL enabled)
|
||||
{
|
||||
if (!menu) return;
|
||||
|
||||
const LLView::child_list_t *list = menu->getChildList();
|
||||
for (LLView::child_list_t::const_iterator itor = list->begin();
|
||||
itor != list->end();
|
||||
++itor)
|
||||
{
|
||||
LLView *menu_item = (*itor);
|
||||
std::string name = menu_item->getName();
|
||||
|
||||
if ("restore_item" == name)
|
||||
{
|
||||
menu_item->setVisible(visible);
|
||||
menu_item->setEnabled(enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_item->setVisible(!visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
// EOF
|
||||
|
|
|
|||
|
|
@ -128,6 +128,14 @@ private:
|
|||
bool isActionEnabled(const LLSD& command_name) const;
|
||||
void onCustomAction(const LLSD& command_name);
|
||||
|
||||
/**
|
||||
* Updates context menu depending on the selected items location.
|
||||
*
|
||||
* For items in Trash category the menu includes the "Restore Item"
|
||||
* context menu entry.
|
||||
*/
|
||||
void onMenuVisibilityChange(LLUICtrl* ctrl, const LLSD& param);
|
||||
|
||||
/**
|
||||
* Determines if an item can be modified via context/gear menu.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@
|
|||
function="Places.LandmarksGear.Enable"
|
||||
parameter="category" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Restore Item"
|
||||
layout="topleft"
|
||||
name="restore_item">
|
||||
<menu_item_call.on_click
|
||||
function="Places.LandmarksGear.Custom.Action"
|
||||
parameter="restore" />
|
||||
</menu_item_call>
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
<menu_item_call
|
||||
|
|
|
|||
|
|
@ -60,6 +60,14 @@
|
|||
function="Places.LandmarksGear.Enable"
|
||||
parameter="category" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Restore Item"
|
||||
layout="topleft"
|
||||
name="restore_item">
|
||||
<menu_item_call.on_click
|
||||
function="Places.LandmarksGear.Custom.Action"
|
||||
parameter="restore" />
|
||||
</menu_item_call>
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
<menu_item_call
|
||||
|
|
|
|||
Loading…
Reference in New Issue