From 95a228b2e9d8ff61710234c4564c025c41d74bda Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Fri, 19 Jul 2013 21:17:42 +0200 Subject: [PATCH] Actually use LLWearable::mDescription. Set LLWearable::mDescription and keep it up to date. This allows to export (and import) the description of wearables. --- indra/newview/llagentwearables.cpp | 31 ++++++++++++++++++++--- indra/newview/llagentwearables.h | 1 + indra/newview/llfoldervieweventlistener.h | 1 + indra/newview/llfolderviewitem.cpp | 12 ++++++++- indra/newview/llfolderviewitem.h | 2 ++ indra/newview/llinventorybridge.cpp | 23 +++++++++++++++++ indra/newview/llinventorybridge.h | 4 +++ indra/newview/llinventorymodel.cpp | 4 +++ indra/newview/llinventoryobserver.h | 1 + indra/newview/llinventorypanel.cpp | 11 ++++++++ indra/newview/llpanelobjectinventory.cpp | 18 +++++++++++++ indra/newview/llviewerwearable.cpp | 3 ++- indra/newview/llviewerwearable.h | 4 +-- indra/newview/llwearablelist.cpp | 3 ++- indra/newview/llwearablelist.h | 2 +- 15 files changed, 110 insertions(+), 10 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index d10bdc10b..2aa0ac9b0 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -473,7 +473,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32 LLViewerWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, - const std::string& description, + const std::string& new_description, BOOL save_in_lost_and_found) { if (!isWearableCopyable(type, index)) @@ -496,9 +496,12 @@ LLViewerWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType t } std::string trunc_name(new_name); LLStringUtil::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN); + std::string trunc_description(new_description); + LLStringUtil::truncate(trunc_description, DB_INV_ITEM_DESC_STR_LEN); LLViewerWearable* new_wearable = LLWearableList::instance().createCopy( old_wearable, - trunc_name); + trunc_name, + trunc_description); LLPointer cb = new addWearableToAgentInventoryCallback( LLPointer(NULL), @@ -506,7 +509,7 @@ LLViewerWearable* LLAgentWearables::saveWearableAs(const LLWearableType::EType t index, new_wearable, addWearableToAgentInventoryCallback::CALL_WEARITEM, - description + trunc_description ); LLUUID category_id; if (save_in_lost_and_found) @@ -595,6 +598,25 @@ void LLAgentWearables::setWearableName(const LLUUID& item_id, const std::string& } } +void LLAgentWearables::descriptionChanged(LLUUID const& item_id) +{ + for (S32 i=0; i < LLWearableType::WT_COUNT; i++) + { + for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++) + { + LLUUID curr_item_id = getWearableItemID((LLWearableType::EType)i,j); + if (curr_item_id == item_id) + { + LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)i,j); + llassert(wearable); + if (!wearable) continue; + + wearable->refreshNameAndDescription(); + break; + } + } + } +} BOOL LLAgentWearables::isWearableModifiable(LLWearableType::EType type, U32 index) const { @@ -751,7 +773,7 @@ void LLAgentWearables::wearableUpdated(LLWearable *wearable, BOOL removed) if (!removed) { LLViewerWearable* viewer_wearable = dynamic_cast(wearable); - viewer_wearable->refreshName(); + viewer_wearable->refreshNameAndDescription(); // Hack pt 2. If the wearable we just loaded has definition version 24, // then force a re-save of this wearable after slamming the version number to 22. @@ -1334,6 +1356,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it const LLWearableType::EType type = new_wearable->getType(); new_wearable->setName(new_item->getName()); + new_wearable->setDescription(new_item->getDescription()); new_wearable->setItemID(new_item->getUUID()); if (LLWearableType::getAssetType(type) == LLAssetType::AT_BODYPART) diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h index 5c0c060e7..318ff832b 100644 --- a/indra/newview/llagentwearables.h +++ b/indra/newview/llagentwearables.h @@ -116,6 +116,7 @@ public: // void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false); void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove); void setWearableName(const LLUUID& item_id, const std::string& new_name); + void descriptionChanged(LLUUID const& item_id); // *TODO: Move this into llappearance/LLWearableData ? void addLocalTextureObject(const LLWearableType::EType wearable_type, const LLAvatarAppearanceDefines::ETextureIndex texture_type, U32 wearable_index); diff --git a/indra/newview/llfoldervieweventlistener.h b/indra/newview/llfoldervieweventlistener.h index 69060653f..a679f43d2 100644 --- a/indra/newview/llfoldervieweventlistener.h +++ b/indra/newview/llfoldervieweventlistener.h @@ -67,6 +67,7 @@ public: virtual void showProperties(void) = 0; virtual BOOL isItemRenameable() const = 0; virtual BOOL renameItem(const std::string& new_name) = 0; + virtual void descriptionChanged(void) const = 0; virtual BOOL isItemMovable( void ) const = 0; // Can be moved to another folder virtual BOOL isItemRemovable( void ) const = 0; // Can be destroyed virtual BOOL isItemInTrash( void) const { return FALSE; } // TODO: make into pure virtual. diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 33a78838d..63be87aae 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -615,6 +615,15 @@ void LLFolderViewItem::rename(const std::string& new_name) } } +void LLFolderViewItem::descriptionChanged(void) const +{ + // We don't have a description, but the listener does! + if( mListener ) + { + mListener->descriptionChanged(); + } +} + void LLFolderViewItem::updateSearchLabelType() { mSearchType = mRoot->getSearchType(); @@ -2871,4 +2880,5 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde return (first_create > second_create); } } -} \ No newline at end of file +} + diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index ca9da12ea..f15978433 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -277,6 +277,8 @@ public: // just rename the object. void rename(const std::string& new_name); + // Alert mListener that the description of this item changed. + void descriptionChanged(void) const; // open virtual void openItem( void ); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a2658eb35..a780ce062 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1724,6 +1724,10 @@ BOOL LLItemBridge::renameItem(const std::string& new_name) return FALSE; } +void LLItemBridge::descriptionChanged(void) const +{ + // Nothing to do. +} BOOL LLItemBridge::removeItem() { @@ -2966,6 +2970,12 @@ BOOL LLFolderBridge::renameItem(const std::string& new_name) return FALSE; } +void LLFolderBridge::descriptionChanged(void) const +{ + // A folder has no description. + llerrs << "Calling LLFolderBridge::descriptionChanged" << llendl; +} + BOOL LLFolderBridge::removeItem() { if(!isItemRemovable()) @@ -5470,6 +5480,11 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name) return FALSE; } +void LLObjectBridge::descriptionChanged(void) const +{ + // Nothing to do. +} + // +=================================================+ // | LLLSLTextBridge | // +=================================================+ @@ -5628,6 +5643,14 @@ BOOL LLWearableBridge::renameItem(const std::string& new_name) return LLItemBridge::renameItem(new_name); } +void LLWearableBridge::descriptionChanged(void) const +{ + if (get_is_item_worn(mUUID)) + { + gAgentWearables.descriptionChanged(mUUID); + } +} + std::string LLWearableBridge::getLabelSuffix() const { if (get_is_item_worn(mUUID)) diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 0900820cf..b7dfc0623 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -211,6 +211,7 @@ public: virtual time_t getCreationDate() const; virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; virtual BOOL removeItem(); virtual BOOL isItemCopyable() const; virtual BOOL hasChildren() const { return FALSE; } @@ -257,6 +258,7 @@ public: static LLUIImagePtr getIcon(LLFolderType::EType preferred_type); virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; virtual BOOL removeItem(); BOOL removeSystemFolder(); @@ -466,6 +468,7 @@ public: virtual std::string getLabelSuffix() const; virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; LLInventoryObject* getObject() const; protected: static LLUUID sContextMenuItemID; // Only valid while the context menu is open. @@ -499,6 +502,7 @@ public: virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual std::string getLabelSuffix() const; virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; virtual LLWearableType::EType getWearableType() const { return mWearableType; } static void onWearOnAvatar( void* userdata ); // Access to wearOnAvatar() from menu diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 069508896..e36753bfe 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -854,6 +854,10 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) { mask |= LLInventoryObserver::LABEL; } + if(old_item->getDescription() != item->getDescription()) + { + mask |= LLInventoryObserver::DESCRIPTION; + } old_item->copyViewerItem(item); mask |= LLInventoryObserver::INTERNAL; } diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h index 55b2b29dd..13dcd9a12 100644 --- a/indra/newview/llinventoryobserver.h +++ b/indra/newview/llinventoryobserver.h @@ -58,6 +58,7 @@ public: GESTURE = 64, REBUILD = 128, // Item UI changed (e.g. item type different) SORT = 256, // Folder needs to be resorted. + DESCRIPTION = 0x10000, // Singu extension to keep track of description changes. ALL = 0xffffffff }; LLInventoryObserver(); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 5b90e524f..e04d7bb89 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -484,6 +484,17 @@ void LLInventoryPanel::modelChanged(U32 mask) } } + ////////////////////////////// + // DESCRIPTION Operation (singu only) + // Alert listener. + if ((mask & LLInventoryObserver::DESCRIPTION)) + { + if (view_item) + { + view_item->descriptionChanged(); + } + } + ////////////////////////////// // REBUILD Operation // Destroy and regenerate the UI. diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 53ca90be4..86f3d8be2 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -123,6 +123,7 @@ public: virtual void selectItem() {} virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; virtual BOOL isItemMovable() const; virtual BOOL isItemRemovable() const; virtual BOOL removeItem(); @@ -430,6 +431,11 @@ BOOL LLTaskInvFVBridge::renameItem(const std::string& new_name) return TRUE; } +void LLTaskInvFVBridge::descriptionChanged(void) const +{ + // Nothing to do. +} + BOOL LLTaskInvFVBridge::isItemMovable() const { //LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); @@ -814,6 +820,7 @@ public: virtual BOOL isItemRenameable() const; // virtual BOOL isItemCopyable() const { return FALSE; } virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; virtual BOOL isItemRemovable() const; virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual BOOL hasChildren() const; @@ -854,6 +861,12 @@ BOOL LLTaskCategoryBridge::renameItem(const std::string& new_name) return FALSE; } +void LLTaskCategoryBridge::descriptionChanged(void) const +{ + // A category has no description. + llerrs << "Calling LLTaskCategoryBridge::descriptionChanged" << llendl; +} + BOOL LLTaskCategoryBridge::isItemRemovable() const { return FALSE; @@ -1169,6 +1182,7 @@ public: virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); + virtual void descriptionChanged(void) const; }; BOOL LLTaskCallingCardBridge::isItemRenameable() const @@ -1181,6 +1195,10 @@ BOOL LLTaskCallingCardBridge::renameItem(const std::string& new_name) return FALSE; } +void LLTaskCallingCardBridge::descriptionChanged(void) const +{ + // Nothing to do. +} ///---------------------------------------------------------------------------- /// Class LLTaskScriptBridge diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp index 2c4c87caf..2ad5fc490 100644 --- a/indra/newview/llviewerwearable.cpp +++ b/indra/newview/llviewerwearable.cpp @@ -554,13 +554,14 @@ void LLViewerWearable::setUpdated() const gInventory.addChangedMask(LLInventoryObserver::LABEL, getItemID()); } -void LLViewerWearable::refreshName() +void LLViewerWearable::refreshNameAndDescription() { LLUUID item_id = getItemID(); LLInventoryItem* item = gInventory.getItem(item_id); if( item ) { mName = item->getName(); + mDescription = item->getDescription(); } } diff --git a/indra/newview/llviewerwearable.h b/indra/newview/llviewerwearable.h index 85d4faaf6..cd5a2dfff 100644 --- a/indra/newview/llviewerwearable.h +++ b/indra/newview/llviewerwearable.h @@ -85,9 +85,9 @@ public: // Something happened that requires the wearable's label to be updated (e.g. worn/unworn). void setUpdated() const; - // the wearable was worn. make sure the name of the wearable object matches the LLViewerInventoryItem, + // the wearable was worn. make sure the name and description of the wearable object matches the LLViewerInventoryItem, // not the wearable asset itself. - void refreshName(); + void refreshNameAndDescription(); // Update the baked texture hash. /*virtual*/void addToBakedTextureHash(LLMD5& hash) const; diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index ef1a953f5..43685188d 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -215,7 +215,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } -LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name) +LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name, const std::string& new_description) { lldebugs << "LLWearableList::createCopy()" << llendl; @@ -227,6 +227,7 @@ LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearabl wearable->setPermissions(perm); if (!new_name.empty()) wearable->setName(new_name); + if (!new_description.empty()) wearable->setDescription(new_description); // Send to the dataserver wearable->saveNewAsset(); diff --git a/indra/newview/llwearablelist.h b/indra/newview/llwearablelist.h index d6f0fd09a..3ed15e311 100644 --- a/indra/newview/llwearablelist.h +++ b/indra/newview/llwearablelist.h @@ -55,7 +55,7 @@ public: void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata); - LLViewerWearable* createCopy(const LLViewerWearable* old_wearable, const std::string& new_name = std::string()); + LLViewerWearable* createCopy(const LLViewerWearable* old_wearable, const std::string& new_name = std::string(), const std::string& new_description = std::string()); LLViewerWearable* createNewWearable(LLWearableType::EType type, LLAvatarAppearance *avatarp); // Callback