diff options
-rw-r--r-- | indra/llui/llfolderviewitem.cpp | 118 | ||||
-rw-r--r-- | indra/llui/llfolderviewitem.h | 7 | ||||
-rw-r--r-- | indra/llui/llfolderviewmodel.h | 3 | ||||
-rw-r--r-- | indra/newview/llconversationmodel.h | 2 | ||||
-rw-r--r-- | indra/newview/llfolderviewmodelinventory.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.h | 6 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llpanelobjectinventory.cpp | 2 |
9 files changed, 97 insertions, 61 deletions
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index be703a1e9a..2accec7a68 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -199,7 +199,6 @@ BOOL LLFolderViewItem::postBuild() // it also sets search strings so it requires a filter reset mLabel = vmi->getDisplayName(); mIsFavorite = vmi->isFavorite(); - mHasFavorites = vmi->hasFavorites(); setToolTip(vmi->getName()); // Dirty the filter flag of the model from the view (CHUI-849) @@ -314,7 +313,6 @@ void LLFolderViewItem::refresh() mLabel = vmi.getDisplayName(); mIsFavorite = vmi.isFavorite(); - mHasFavorites = vmi.hasFavorites(); setToolTip(vmi.getName()); // icons are slightly expensive to get, can be optimized // see LLInventoryIcon::getIcon() @@ -348,7 +346,6 @@ void LLFolderViewItem::refreshSuffix() mIconOverlay = vmi->getIconOverlay(); mIsFavorite = vmi->isFavorite(); - mHasFavorites = vmi->hasFavorites(); if (mRoot->useLabelSuffix()) { @@ -1116,7 +1113,8 @@ LLFolderViewFolder::LLFolderViewFolder( const LLFolderViewItem::Params& p ): mIsFolderComplete(false), // folder might have children that are not loaded yet. mAreChildrenInited(false), // folder might have children that are not built yet. mLastArrangeGeneration( -1 ), - mLastCalculatedWidth(0) + mLastCalculatedWidth(0), + mFavoritesDirtyFlags(0) { } @@ -1142,6 +1140,11 @@ LLFolderViewFolder::~LLFolderViewFolder( void ) // The LLView base class takes care of object destruction. make sure that we // don't have mouse or keyboard focus gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() + + if (mFavoritesDirtyFlags) + { + gIdleCallbacks.deleteFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } } // addToFolder() returns TRUE if it succeeds. FALSE otherwise @@ -1785,60 +1788,109 @@ BOOL LLFolderViewFolder::isMovable() void LLFolderViewFolder::updateHasFavorites(bool new_childs_value) { - if (mHasFavorites != new_childs_value) + if (mFavoritesDirtyFlags == 0) + { + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, this); + } + if (new_childs_value) + { + mFavoritesDirtyFlags |= FAVORITE_ADDED; + } + else + { + mFavoritesDirtyFlags |= FAVORITE_REMOVED; + } +} + +void LLFolderViewFolder::onIdleUpdateFavorites(void* data) +{ + LLFolderViewFolder* self = reinterpret_cast<LLFolderViewFolder*>(data); + if (self->mFavoritesDirtyFlags == 0) { - if (new_childs_value) + LL_WARNS() << "Called onIdleUpdateFavorites without dirty flags set" << LL_ENDL; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + if (self->getViewModelItem()->isItemInTrash()) + { + // do not display favorite-stars in trash + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); + return; + } + + LLFolderViewFolder* root_folder = self->getRoot(); + if (self->mFavoritesDirtyFlags == FAVORITE_ADDED) + { + if (!self->mHasFavorites) { - mHasFavorites = new_childs_value; - // propagate up to root - LLFolderViewFolder* parent = getParentFolder(); - while (parent && !parent->hasFavorites()) + // propagate up, exclude root + LLFolderViewFolder* parent = self; + while (parent && !parent->hasFavorites() && root_folder != parent) { parent->setHasFavorites(true); parent = parent->getParentFolder(); } } - else + } + else if (self->mFavoritesDirtyFlags > FAVORITE_ADDED) + { + // full check + LLFolderViewFolder* parent = self; + while (parent && root_folder != parent) { - LLFolderViewFolder* parent = this; - while (parent) + bool has_favorites = false; + for (items_t::iterator iter = parent->mItems.begin(); + iter != parent->mItems.end();) { - bool has_favorites = false; - for (items_t::iterator iter = parent->mItems.begin(); - iter != parent->mItems.end();) + items_t::iterator iit = iter++; + if ((*iit)->isFavorite()) { - items_t::iterator iit = iter++; - if ((*iit)->isFavorite()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - for (folders_t::iterator iter = parent->mFolders.begin(); - iter != parent->mFolders.end() && !has_favorites;) + for (folders_t::iterator iter = parent->mFolders.begin(); + iter != parent->mFolders.end() && !has_favorites;) + { + folders_t::iterator fit = iter++; + if ((*fit)->isFavorite() || (*fit)->hasFavorites()) { - folders_t::iterator fit = iter++; - if ((*fit)->isFavorite() || (*fit)->hasFavorites()) - { - has_favorites = true; - break; - } + has_favorites = true; + break; } + } - if (!has_favorites) + if (!has_favorites) + { + if (parent->hasFavorites()) { - parent->mHasFavorites = false; parent->setHasFavorites(false); } else { + // Nothing changed break; } - parent = parent->getParentFolder(); } + else + { + // propagate up, exclude root + while (parent && !parent->hasFavorites() && root_folder != parent) + { + parent->setHasFavorites(true); + parent = parent->getParentFolder(); + } + break; + } + parent = parent->getParentFolder(); } } + + self->mFavoritesDirtyFlags = 0; + gIdleCallbacks.addFunction(&LLFolderViewFolder::onIdleUpdateFavorites, self); } diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h index 5905516023..fc19514615 100644 --- a/indra/llui/llfolderviewitem.h +++ b/indra/llui/llfolderviewitem.h @@ -402,6 +402,13 @@ public: bool hasFavorites() const { return mHasFavorites; } void setHasFavorites(bool val) { mHasFavorites = val; } void updateHasFavorites(bool new_childs_value); +private: + static void onIdleUpdateFavorites(void* data); + + constexpr static S32 FAVORITE_ADDED = 1; + constexpr static S32 FAVORITE_REMOVED = 2; + S32 mFavoritesDirtyFlags { 0 }; +public: // destroys this folder, and all children virtual void destroyView(); diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 9d46334fc4..152801ec69 100644 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -163,8 +163,6 @@ public: virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0; virtual bool isFavorite() const = 0; - virtual bool hasFavorites() const = 0; - virtual void setHasFavorites(bool val) = 0; virtual BOOL isItemWearable() const { return FALSE; } virtual BOOL isItemRenameable() const = 0; @@ -174,6 +172,7 @@ public: virtual void move( LLFolderViewModelItem* parent_listener ) = 0; virtual BOOL isItemRemovable( void ) const = 0; // Can be destroyed + virtual BOOL isItemInTrash(void) const = 0; virtual BOOL removeItem() = 0; virtual void removeBatch(std::vector<LLFolderViewModelItem*>& batch) = 0; diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index e2eaff12e5..3b70b9a568 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -80,8 +80,6 @@ public: virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual std::string getLabelSuffix() const { return LLStringUtil::null; } virtual bool isFavorite() const { return false; } - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {} virtual BOOL isItemRenameable() const { return TRUE; } virtual BOOL renameItem(const std::string& new_name) { mName = new_name; mNeedsRefresh = true; return TRUE; } virtual BOOL isItemMovable( void ) const { return FALSE; } diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index bc5a07abf2..6bf539fc48 100644 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -111,8 +111,10 @@ void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder ) LLFolderViewItem* child_itemp = *it; has_favorites |= child_itemp->isFavorite(); } - folder->setHasFavorites(has_favorites); - sort_modelp->setHasFavorites(has_favorites); + if (has_favorites) + { + folder->updateHasFavorites(true); + } base_t::sort(folder); } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 560a2f265a..5620523f24 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2434,16 +2434,6 @@ bool LLFolderBridge::isFavorite() const return false; } -bool LLFolderBridge::hasFavorites() const -{ - return mHasFavorites; -} - -void LLFolderBridge::setHasFavorites(bool val) -{ - mHasFavorites = val; -} - void LLFolderBridge::update() { // we know we have children but haven't fetched them (doesn't obey filter) diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 8bb4e188e6..39cd393fdd 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -258,8 +258,6 @@ public: LLViewerInventoryItem* getItem() const; virtual const LLUUID& getThumbnailUUID() const; virtual bool isFavorite() const; - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {} protected: BOOL confirmRemoveItem(const LLSD& notification, const LLSD& response); @@ -281,7 +279,6 @@ public: mCallingCards(FALSE), mWearables(FALSE), mIsLoading(false), - mHasFavorites(false), mShowDescendantsCount(false) {} @@ -308,8 +305,6 @@ public: virtual LLFontGL::StyleFlags getLabelStyle() const; virtual const LLUUID& getThumbnailUUID() const; virtual bool isFavorite() const; - virtual bool hasFavorites() const; - virtual void setHasFavorites(bool val); void setShowDescendantsCount(bool show_count) {mShowDescendantsCount = show_count;} @@ -397,7 +392,6 @@ protected: bool mWearables; bool mIsLoading; bool mShowDescendantsCount; - bool mHasFavorites; LLTimer mTimeSinceRequestStart; std::string mMessage; LLRootHandle<LLFolderBridge> mHandle; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 4aace2f96e..6a5cd59acb 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -624,7 +624,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve { if (view_item) { - // TODO:: move to idle LLFolderViewFolder* parent = view_item->getParentFolder(); if (parent) { @@ -663,7 +662,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve updateFolderLabel(model_item->getParentUUID()); if (model_item->getIsFavorite()) { - // TODO:: move to idle LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID()); if (new_parent) { @@ -720,7 +718,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve if (view_item->isFavorite()) { - // TODO:: move to idle old_parent->updateHasFavorites(false); // favorite was removed new_parent->updateHasFavorites(true); // favorite was added } @@ -747,7 +744,6 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve } if (view_item->isFavorite()) { - // TODO:: move to idle parent->updateHasFavorites(false); // favorite was removed } } diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index e38e2622c9..3bd93b10ad 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -130,8 +130,6 @@ public: virtual BOOL isItemRenameable() const; virtual BOOL renameItem(const std::string& new_name); virtual bool isFavorite() const { return false; } - virtual bool hasFavorites() const { return false; } - virtual void setHasFavorites(bool val) {}; virtual BOOL isItemMovable() const; virtual BOOL isItemRemovable() const; virtual BOOL removeItem(); |