From a6475e379e972776761a9d69b76fcbb392959a26 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 29 Jun 2011 15:12:21 -0400 Subject: STORM-1459 "Wearing Tab" - Add ability to copy displayed inventory names to clipboard Made changes with input from Oz & Vadim --- indra/newview/llpanelwearing.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpanelwearing.cpp') diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index e0109675a6..c2f39524c4 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -60,6 +60,7 @@ public: registrar.add("Gear.Edit", boost::bind(&edit_outfit)); registrar.add("Gear.TakeOff", boost::bind(&LLWearingGearMenu::onTakeOff, this)); + registrar.add("Gear.Copy", boost::bind(&LLPanelWearing::copyToClipboard, mPanelWearing)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLPanelWearing::isActionEnabled, mPanelWearing, _2)); @@ -184,7 +185,6 @@ BOOL LLPanelWearing::postBuild() { mCOFItemsList = getChild("cof_items_list"); mCOFItemsList->setRightMouseDownCallback(boost::bind(&LLPanelWearing::onWearableItemsListRightClick, this, _1, _2, _3)); - childSetAction("copy_to_clipboard", boost::bind(&LLPanelWearing::copyToClipboard, this)); LLMenuButton* menu_gear_btn = getChild("options_gear_btn"); @@ -286,24 +286,22 @@ void LLPanelWearing::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const void LLPanelWearing::copyToClipboard() { std::string text; - bool need_cr = false; std::vector data; mCOFItemsList->getValues(data); - for(std::vector::iterator iter = data.begin(); iter != data.end(); iter++) + + for(std::vector::const_iterator iter = data.begin(); iter != data.end();) { LLSD uuid = (*iter); LLViewerInventoryItem* item = gInventory.getItem(uuid); - if (!need_cr) - { - text += item->getName(); - need_cr = true; - } - else + + iter++; + if (item != NULL) { - text += "\n" + item->getName(); + // Append a CR to all but the last line + text += iter != data.end() ? item->getName() + "\n" : item->getName(); } } + gClipboard.copyFromString(utf8str_to_wstring(text)); } - // EOF -- cgit v1.3