From 06584a38ab1a586282faf74dfd510d3a02da0520 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Wed, 1 Oct 2014 18:34:26 -0400 Subject: [PATCH] Stylistic changes and whatnot for LLDropTarget what with setValue and setItem --- indra/newview/lldroptarget.cpp | 30 +++++++++++++++++++++++------- indra/newview/lldroptarget.h | 7 ++++++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/indra/newview/lldroptarget.cpp b/indra/newview/lldroptarget.cpp index 51897a4be..9ae950db9 100644 --- a/indra/newview/lldroptarget.cpp +++ b/indra/newview/lldroptarget.cpp @@ -46,8 +46,9 @@ static LLRegisterWidget r("drop_target"); -std::string currently_set_to(const LLViewerInventoryItem* item) +std::string currently_set_to(const LLInventoryItem* item) { + if (!item) return LLTrans::getString("CurrentlyNotSet"); LLStringUtil::format_map_t args; args["[ITEM]"] = item->getName(); return LLTrans::getString("CurrentlySetTo", args); @@ -181,6 +182,26 @@ void LLDropTarget::fillParent(const LLView* parent) setRect(LLRect(0, parent_rect.getHeight(), parent_rect.getWidth(), 0)); } +void LLDropTarget::setControlValue(const std::string& val) +{ + if (mControl) + { + mControl->setValue(val); + } +} + +void LLDropTarget::setItem(const LLInventoryItem* item) +{ + mText->setText(currently_set_to(item)); + setControlValue(item ? item->getUUID().asString() : ""); +} + +void LLDropTarget::setValue(const LLSD& value) +{ + const LLUUID& id(value.asUUID()); + setItem(id.isNull() ? NULL : gInventory.getItem(id)); +} + void LLDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data) { llinfos << "LLDropTarget::doDrop()" << llendl; @@ -194,12 +215,7 @@ BOOL LLDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAn if (LLViewerInventoryItem* inv_item = static_cast(cargo_data)) { *accept = ACCEPT_YES_COPY_SINGLE; - if (drop) - { - mText->setText(currently_set_to(inv_item)); - if (mControl) - mControl->setValue(inv_item->getUUID().asString()); - } + if (drop) setItem(inv_item); } return true; } diff --git a/indra/newview/lldroptarget.h b/indra/newview/lldroptarget.h index 448208965..0da077575 100644 --- a/indra/newview/lldroptarget.h +++ b/indra/newview/lldroptarget.h @@ -69,11 +69,16 @@ public: virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); static LLView* fromXML(LLXMLNodePtr node, LLView* parent, class LLUICtrlFactory* factory); virtual void initFromXML(LLXMLNodePtr node, LLView* parent); - virtual void setControlName(const std::string& control, LLView* context); + virtual void setControlName(const std::string& control, LLView* context); + virtual void setValue(const LLSD& value); void fillParent(const LLView* parent); void setEntityID(const LLUUID& id) { mEntityID = id;} + protected: + virtual void setItem(const class LLInventoryItem* item); + void setControlValue(const std::string& val); + LLUUID mEntityID; class LLViewBorder* mBorder; LLControlVariable* mControl;