diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-27 05:01:36 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-04-27 05:01:36 +0300 |
| commit | a0c4d81080fbc4b5326e6b598e5df27e01631d48 (patch) | |
| tree | f45337506aa72b301280a89aaca031b6de0a2888 /indra/llui | |
| parent | cea6eeeede9f687ca195cc9b9e778fd6784afbe2 (diff) | |
viewer#1300 'Star' favorites in inventory #2
Diffstat (limited to 'indra/llui')
| -rw-r--r-- | indra/llui/llfolderviewitem.cpp | 58 | ||||
| -rw-r--r-- | indra/llui/llfolderviewitem.h | 1 |
2 files changed, 59 insertions, 0 deletions
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 84146e5829..be703a1e9a 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -1783,6 +1783,64 @@ BOOL LLFolderViewFolder::isMovable() return TRUE; } +void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) +{ + if (mHasFavorites != new_childs_value) + { + if (new_childs_value) + { + mHasFavorites = new_childs_value; + // propagate up to root + LLFolderViewFolder* parent = getParentFolder(); + while (parent && !parent->hasFavorites()) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + } + else + { + LLFolderViewFolder* parent = this; + while (parent) + { + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) + { + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) + { + has_favorites = true; + break; + } + } + + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) + { + has_favorites = true; + break; + } + } + + if (!has_favorites) + { + parent->mHasFavorites = false; + parent->setHasFavorites(false); + } + else + { + break; + } + parent = parent->getParentFolder(); + } + } + } +} + BOOL LLFolderViewFolder::isRemovable() { diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index eba3cf4f83..5905516023 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -401,6 +401,7 @@ public: bool isFavorite() const { return mIsFavorite; } bool hasFavorites() const { return mHasFavorites; } void setHasFavorites(bool val) { mHasFavorites = val; } + void updateHasFavorites(bool new_childs_value); // destroys this folder, and all children virtual void destroyView(); |
