diff options
author | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-09-15 17:21:40 +0300 |
---|---|---|
committer | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-09-15 17:21:40 +0300 |
commit | ab199473f72cee8020ff4c650c451f9881246a68 (patch) | |
tree | 27d5f34a540f5ba306d9bb315c747774d302312f /indra/newview | |
parent | 1dbcc3fff79b55038178e493df0cc0c3a4d66221 (diff) |
STORM-148 FIXED Added updating Item Profile info upon changes of objects inventory items.
The 'Item Profile' panel was observing changes in agent's inventory only, so when an item inside an object was renamed its name wasn't updated in 'Item Profile' panel.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llsidepaneliteminfo.cpp | 69 | ||||
-rw-r--r-- | indra/newview/llsidepaneliteminfo.h | 5 |
2 files changed, 74 insertions, 0 deletions
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 731079fb5d..e41bbe43df 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -75,7 +75,40 @@ void LLItemPropertiesObserver::changed(U32 mask) } } +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLObjectInventoryObserver +// +// Helper class to watch for changes in an object inventory. +// Used to update item properties in LLSidepanelItemInfo. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLObjectInventoryObserver : public LLVOInventoryListener +{ +public: + LLObjectInventoryObserver(LLSidepanelItemInfo* floater, LLViewerObject* object) + : mFloater(floater) + { + registerVOInventoryListener(object, NULL); + } + virtual ~LLObjectInventoryObserver() + { + removeVOInventoryListener(); + } + /*virtual*/ void inventoryChanged(LLViewerObject* object, + LLInventoryObject::object_list_t* inventory, + S32 serial_num, + void* user_data); +private: + LLSidepanelItemInfo* mFloater; +}; +/*virtual*/ +void LLObjectInventoryObserver::inventoryChanged(LLViewerObject* object, + LLInventoryObject::object_list_t* inventory, + S32 serial_num, + void* user_data) +{ + mFloater->dirty(); +} ///---------------------------------------------------------------------------- /// Class LLSidepanelItemInfo @@ -86,6 +119,7 @@ static LLRegisterPanelClassWrapper<LLSidepanelItemInfo> t_item_info("sidepanel_i // Default constructor LLSidepanelItemInfo::LLSidepanelItemInfo() : mItemID(LLUUID::null) + , mObjectInventoryObserver(NULL) { mPropertiesObserver = new LLItemPropertiesObserver(this); @@ -97,6 +131,8 @@ LLSidepanelItemInfo::~LLSidepanelItemInfo() { delete mPropertiesObserver; mPropertiesObserver = NULL; + + stopObjectInventoryObserver(); } // virtual @@ -134,6 +170,10 @@ BOOL LLSidepanelItemInfo::postBuild() void LLSidepanelItemInfo::setObjectID(const LLUUID& object_id) { mObjectID = object_id; + + // Start monitoring changes in the object inventory to update + // selected inventory item properties in Item Profile panel. See STORM-148. + startObjectInventoryObserver(); } void LLSidepanelItemInfo::setItemID(const LLUUID& item_id) @@ -147,6 +187,8 @@ void LLSidepanelItemInfo::reset() mObjectID = LLUUID::null; mItemID = LLUUID::null; + + stopObjectInventoryObserver(); } void LLSidepanelItemInfo::refresh() @@ -600,6 +642,33 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) } } +void LLSidepanelItemInfo::startObjectInventoryObserver() +{ + if (!mObjectInventoryObserver) + { + stopObjectInventoryObserver(); + + // Previous object observer should be removed before starting to observe a new object. + llassert(mObjectInventoryObserver == NULL); + } + + if (mObjectID.isNull()) + { + llwarns << "Empty object id passed to inventory observer" << llendl; + return; + } + + LLViewerObject* object = gObjectList.findObject(mObjectID); + + mObjectInventoryObserver = new LLObjectInventoryObserver(this, object); +} + +void LLSidepanelItemInfo::stopObjectInventoryObserver() +{ + delete mObjectInventoryObserver; + mObjectInventoryObserver = NULL; +} + void LLSidepanelItemInfo::onClickCreator() { LLViewerInventoryItem* item = findItem(); diff --git a/indra/newview/llsidepaneliteminfo.h b/indra/newview/llsidepaneliteminfo.h index 82ebbfa7ec..10e93dd7de 100644 --- a/indra/newview/llsidepaneliteminfo.h +++ b/indra/newview/llsidepaneliteminfo.h @@ -37,6 +37,7 @@ class LLButton; class LLViewerInventoryItem; class LLItemPropertiesObserver; +class LLObjectInventoryObserver; class LLViewerObject; class LLPermissions; @@ -63,9 +64,13 @@ protected: void refreshFromItem(LLViewerInventoryItem* item); private: + void startObjectInventoryObserver(); + void stopObjectInventoryObserver(); + LLUUID mItemID; // inventory UUID for the inventory item. LLUUID mObjectID; // in-world task UUID, or null if in agent inventory. LLItemPropertiesObserver* mPropertiesObserver; // for syncing changes to item + LLObjectInventoryObserver* mObjectInventoryObserver; // for syncing changes to items inside an object // // UI Elements |