diff options
Diffstat (limited to 'indra/newview/llsidepaneliteminfo.cpp')
-rw-r--r-- | indra/newview/llsidepaneliteminfo.cpp | 107 |
1 files changed, 84 insertions, 23 deletions
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 56bb7167b6..b053432f9c 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -2,31 +2,25 @@ * @file llsidepaneliteminfo.cpp * @brief A floater which shows an inventory item's properties. * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -81,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 @@ -92,10 +119,9 @@ static LLRegisterPanelClassWrapper<LLSidepanelItemInfo> t_item_info("sidepanel_i // Default constructor LLSidepanelItemInfo::LLSidepanelItemInfo() : mItemID(LLUUID::null) + , mObjectInventoryObserver(NULL) { mPropertiesObserver = new LLItemPropertiesObserver(this); - - //LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml"); } // Destroys the object @@ -103,6 +129,8 @@ LLSidepanelItemInfo::~LLSidepanelItemInfo() { delete mPropertiesObserver; mPropertiesObserver = NULL; + + stopObjectInventoryObserver(); } // virtual @@ -140,6 +168,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) @@ -153,6 +185,8 @@ void LLSidepanelItemInfo::reset() mObjectID = LLUUID::null; mItemID = LLUUID::null; + + stopObjectInventoryObserver(); } void LLSidepanelItemInfo::refresh() @@ -606,6 +640,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(); |