diff options
| author | Seth ProductEngine <slitovchuk@productengine.com> | 2011-01-17 19:03:49 +0200 | 
|---|---|---|
| committer | Seth ProductEngine <slitovchuk@productengine.com> | 2011-01-17 19:03:49 +0200 | 
| commit | 7461f1ca2be2851b76ded50d2eb9c0fcc46cfd5f (patch) | |
| tree | 661e1a475ccdded2244b004d5034cd1c46b5b274 | |
| parent | 7314ad41be6142463123e8523c8b97b38400dd9b (diff) | |
STORM-383 FIXED Added "Restore Item" context menu entry for landmarks and folders in Trash category in Places->My Landmarks->My Inventory accordion tab.
| -rw-r--r-- | indra/newview/llpanellandmarks.cpp | 85 | ||||
| -rw-r--r-- | indra/newview/llpanellandmarks.h | 8 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/menu_places_gear_folder.xml | 8 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml | 8 | 
4 files changed, 109 insertions, 0 deletions
| diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index e8c8273a9d..80f6862169 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -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 diff --git a/indra/newview/llpanellandmarks.h b/indra/newview/llpanellandmarks.h index 8dcbca0440..b2f4e92473 100644 --- a/indra/newview/llpanellandmarks.h +++ b/indra/newview/llpanellandmarks.h @@ -129,6 +129,14 @@ private:  	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.  	 *  	 * It validates Places Landmarks rules first. And then LLFolderView permissions. diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml index 6f46165883..1aeb166e01 100644 --- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml +++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml @@ -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 diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml index 121e7cc07a..ff5fdd3795 100644 --- a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml +++ b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml @@ -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 | 
