diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-23 23:28:58 +0300 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-27 00:39:49 +0300 | 
| commit | 384d694aba523218490ec48c22d97b63acbffd6f (patch) | |
| tree | 927ba7855b75ff603bfa312da4365ce102963457 /indra/llinventory | |
| parent | a0b0f207779d1c8c3354af0a41d05dc6b188a033 (diff) | |
viewer#1300 Inventory favorites context menu
Diffstat (limited to 'indra/llinventory')
| -rw-r--r-- | indra/llinventory/llinventory.cpp | 68 | 
1 files changed, 58 insertions, 10 deletions
| diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index cef469e11e..2f701f12a0 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -60,6 +60,7 @@ static const std::string INV_LINKED_ID_LABEL("linked_id");  static const std::string INV_SALE_INFO_LABEL("sale_info");  static const std::string INV_FLAGS_LABEL("flags");  static const std::string INV_CREATION_DATE_LABEL("created_at"); +static const std::string INV_TOGGLED_LABEL("toggled");  // key used by agent-inventory-service  static const std::string INV_ASSET_TYPE_LABEL_WS("type_default"); @@ -261,9 +262,18 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream)              {                  setThumbnailUUID(LLUUID::null);              } +              if (metadata.has("favorite"))              { -                setFavorite(metadata["favorite"].asBoolean()); +                const LLSD& favorite = metadata["favorite"]; +                if (favorite.has("toggled")) +                { +                    setFavorite(favorite["toggled"].asBoolean()); +                } +                else +                { +                    setFavorite(false); +                }              }              else              { @@ -757,9 +767,18 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)              {                  setThumbnailUUID(LLUUID::null);              } +              if (metadata.has("favorite"))              { -                setFavorite(metadata["favorite"].asBoolean()); +                const LLSD& favorite = metadata["favorite"]; +                if (favorite.has("toggled")) +                { +                    setFavorite(favorite["toggled"].asBoolean()); +                } +                else +                { +                    setFavorite(false); +                }              }              else              { @@ -927,7 +946,7 @@ void LLInventoryItem::asLLSD( LLSD& sd ) const      if (mFavorite)      { -        sd[INV_FAVORITE_LABEL] = mFavorite; +        sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);      }  	U32 mask = mPermissions.getMaskBase(); @@ -972,6 +991,7 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)      // TODO - figure out if this should be moved into the noclobber fields above      mThumbnailUUID.setNull(); +    mFavorite = false;      // iterate as map to avoid making unnecessary temp copies of everything      LLSD::map_const_iterator i, end; @@ -1019,7 +1039,12 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new)          if (i->first == INV_FAVORITE_LABEL)          { -            mFavorite = i->second.asBoolean(); +            const LLSD& favorite_map = i->second; +            const std::string w = INV_TOGGLED_LABEL; +            if (favorite_map.has(w)) +            { +                mFavorite = favorite_map[w].asBoolean(); +            }              continue;          } @@ -1220,7 +1245,7 @@ LLSD LLInventoryCategory::asLLSD() const      if (mFavorite)      { -        sd[INV_FAVORITE_LABEL] = mFavorite; +        sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);      }      return sd; @@ -1234,13 +1259,15 @@ LLSD LLInventoryCategory::asAISCreateCatLLSD() const      S8 type                 = static_cast<S8>(mPreferredType);      sd[INV_ASSET_TYPE_LABEL_WS] = type;      sd[INV_NAME_LABEL] = mName; +      if (mThumbnailUUID.notNull())      {          sd[INV_THUMBNAIL_LABEL] = LLSD().with(INV_ASSET_ID_LABEL, mThumbnailUUID);      } +      if (mFavorite)      { -        sd[INV_FAVORITE_LABEL] = mFavorite; +        sd[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);      }      return sd; @@ -1290,10 +1317,16 @@ bool LLInventoryCategory::fromLLSD(const LLSD& sd)              mThumbnailUUID = sd[w];          }      } +    mFavorite = false;      w = INV_FAVORITE_LABEL;      if (sd.has(w))      { -        mFavorite = sd[w].asBoolean(); +        const LLSD& favorite_map = sd[w]; +        w = INV_TOGGLED_LABEL; +        if (favorite_map.has(w)) +        { +            mFavorite = favorite_map[w].asBoolean(); +        }      }      w = INV_ASSET_TYPE_LABEL;      if (sd.has(w)) @@ -1417,9 +1450,18 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream)              {                  setThumbnailUUID(LLUUID::null);              } +              if (metadata.has("favorite"))              { -                setFavorite(metadata["favorite"].asBoolean()); +                const LLSD& favorite = metadata["favorite"]; +                if (favorite.has("toggled")) +                { +                    setFavorite(favorite["toggled"].asBoolean()); +                } +                else +                { +                    setFavorite(false); +                }              }              else              { @@ -1474,7 +1516,7 @@ LLSD LLInventoryCategory::exportLLSD() const      }      if (mFavorite)      { -        cat_data[INV_FAVORITE_LABEL] = mFavorite; +        cat_data[INV_FAVORITE_LABEL] = LLSD().with(INV_TOGGLED_LABEL, mFavorite);      }  	return cat_data; @@ -1510,7 +1552,13 @@ bool LLInventoryCategory::importLLSD(const LLSD& cat_data)      }      if (cat_data.has(INV_FAVORITE_LABEL))      { -        setFavorite(cat_data[INV_FAVORITE_LABEL].asBoolean()); +        bool favorite = false; +        const LLSD& favorite_data = cat_data[INV_FAVORITE_LABEL]; +        if (favorite_data.has(INV_TOGGLED_LABEL)) +        { +            favorite = favorite_data[INV_ASSET_ID_LABEL].asBoolean(); +        } +        setFavorite(favorite);      }  	if (cat_data.has(INV_NAME_LABEL))  	{ | 
