diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-22 23:45:44 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-27 00:39:47 +0300 |
commit | a220acb45496dfbfb154fa9e16943102eda922fc (patch) | |
tree | 2a00328f379d5b470f9a370914f4e1b6b6db2e33 /indra/llinventory/llinventory.cpp | |
parent | f886a438ed11468a90ecca9ba8046a6719f0402c (diff) |
viewer#1300 Inventory favorites basic framework
Diffstat (limited to 'indra/llinventory/llinventory.cpp')
-rw-r--r-- | indra/llinventory/llinventory.cpp | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index 6334a35fd0..cef469e11e 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -46,6 +46,7 @@ static const std::string INV_ITEM_ID_LABEL("item_id"); static const std::string INV_FOLDER_ID_LABEL("cat_id"); static const std::string INV_PARENT_ID_LABEL("parent_id"); static const std::string INV_THUMBNAIL_LABEL("thumbnail"); +static const std::string INV_FAVORITE_LABEL("favorite"); static const std::string INV_THUMBNAIL_ID_LABEL("thumbnail_id"); static const std::string INV_ASSET_TYPE_LABEL("type"); static const std::string INV_PREFERRED_TYPE_LABEL("preferred_type"); @@ -82,14 +83,16 @@ LLInventoryObject::LLInventoryObject(const LLUUID& uuid, mParentUUID(parent_uuid), mType(type), mName(name), - mCreationDate(0) + mCreationDate(0), + mFavorite(false) { correctInventoryName(mName); } LLInventoryObject::LLInventoryObject() : mType(LLAssetType::AT_NONE), - mCreationDate(0) + mCreationDate(0), + mFavorite(false) { } @@ -104,6 +107,7 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other) mType = other->mType; mName = other->mName; mThumbnailUUID = other->mThumbnailUUID; + mFavorite = other->mFavorite; } const LLUUID& LLInventoryObject::getUUID() const @@ -121,6 +125,11 @@ const LLUUID& LLInventoryObject::getThumbnailUUID() const return mThumbnailUUID; } +bool LLInventoryObject::getIsFavorite() const +{ + return mFavorite; +} + const std::string& LLInventoryObject::getName() const { return mName; @@ -175,6 +184,11 @@ void LLInventoryObject::setThumbnailUUID(const LLUUID& thumbnail_uuid) mThumbnailUUID = thumbnail_uuid; } +void LLInventoryObject::setFavorite(bool favorite) +{ + mFavorite = favorite; +} + void LLInventoryObject::setType(LLAssetType::EType type) { mType = type; @@ -247,6 +261,14 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) + { + setFavorite(metadata["favorite"].asBoolean()); + } + else + { + setFavorite(false); + } } else if(0 == strcmp("name", keyword)) { @@ -735,6 +757,14 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) + { + setFavorite(metadata["favorite"].asBoolean()); + } + else + { + setFavorite(false); + } } else if(0 == strcmp("inv_type", keyword)) { @@ -895,6 +925,11 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID); } + if (mFavorite) + { + sd[INV_FAVORITE_LABEL] = mFavorite; + } + U32 mask = mPermissions.getMaskBase(); if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) || (mAssetUUID.isNull())) @@ -974,7 +1009,7 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) <integer> 1 </key> */ continue; - } + } if (i->first == INV_THUMBNAIL_ID_LABEL) { @@ -982,6 +1017,12 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) continue; } + if (i->first == INV_FAVORITE_LABEL) + { + mFavorite = i->second.asBoolean(); + continue; + } + if (i->first == INV_PERMISSIONS_LABEL) { mPermissions = ll_permissions_from_sd(i->second); @@ -1177,6 +1218,11 @@ LLSD LLInventoryCategory::asLLSD() const sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID); } + if (mFavorite) + { + sd[INV_FAVORITE_LABEL] = mFavorite; + } + return sd; } @@ -1192,6 +1238,10 @@ LLSD LLInventoryCategory::asAISCreateCatLLSD() const { sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID); } + if (mFavorite) + { + sd[INV_FAVORITE_LABEL] = mFavorite; + } return sd; } @@ -1240,6 +1290,11 @@ bool LLInventoryCategory::fromLLSD(const LLSD& sd) mThumbnailUUID = sd[w]; } } + w = INV_FAVORITE_LABEL; + if (sd.has(w)) + { + mFavorite = sd[w].asBoolean(); + } w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) { @@ -1362,6 +1417,14 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) { setThumbnailUUID(LLUUID::null); } + if (metadata.has("favorite")) + { + setFavorite(metadata["favorite"].asBoolean()); + } + else + { + setFavorite(false); + } } else { @@ -1409,6 +1472,10 @@ LLSD LLInventoryCategory::exportLLSD() const { cat_data[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID); } + if (mFavorite) + { + cat_data[INV_FAVORITE_LABEL] = mFavorite; + } return cat_data; } @@ -1441,6 +1508,10 @@ bool LLInventoryCategory::importLLSD(const LLSD& cat_data) } setThumbnailUUID(thumbnail_uuid); } + if (cat_data.has(INV_FAVORITE_LABEL)) + { + setFavorite(cat_data[INV_FAVORITE_LABEL].asBoolean()); + } if (cat_data.has(INV_NAME_LABEL)) { mName = cat_data[INV_NAME_LABEL].asString(); |