summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llfolderviewitem.cpp58
-rw-r--r--indra/llui/llfolderviewitem.h1
-rw-r--r--indra/newview/llinventoryfunctions.cpp22
-rw-r--r--indra/newview/llinventoryobserver.h1
-rw-r--r--indra/newview/llinventorypanel.cpp35
5 files changed, 115 insertions, 2 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();
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index b95d75a782..135dfa3519 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -2344,6 +2344,21 @@ void ungroup_folder_items(const LLUUID& folder_id)
gInventory.notifyObservers();
}
+class LLUpdateFavorite : public LLInventoryCallback
+{
+public:
+ LLUpdateFavorite(const LLUUID& inv_item_id)
+ : mInvItemID(inv_item_id)
+ {}
+ /* virtual */ void fire(const LLUUID& inv_item_id) override
+ {
+ gInventory.addChangedMask(LLInventoryObserver::UPDATE_FAVORITE, mInvItemID);
+ gInventory.notifyObservers();
+ }
+private:
+ LLUUID mInvItemID;
+};
+
void set_favorite(const LLUUID& obj_id, bool favorite)
{
LLInventoryObject* obj = gInventory.getObject(obj_id);
@@ -2351,15 +2366,18 @@ void set_favorite(const LLUUID& obj_id, bool favorite)
{
LLSD updates;
updates["favorite"] = LLSD().with("toggled", favorite);
+
+ LLPointer<LLInventoryCallback> cb = new LLUpdateFavorite(obj_id);
+
LLViewerInventoryCategory* view_folder = dynamic_cast<LLViewerInventoryCategory*>(obj);
if (view_folder)
{
- update_inventory_category(obj_id, updates, NULL);
+ update_inventory_category(obj_id, updates, cb);
}
LLViewerInventoryItem* view_item = dynamic_cast<LLViewerInventoryItem*>(obj);
if (view_item)
{
- update_inventory_item(obj_id, updates, NULL);
+ update_inventory_item(obj_id, updates, cb);
}
}
}
diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h
index bec08d2cdf..6cd630bcd2 100644
--- a/indra/newview/llinventoryobserver.h
+++ b/indra/newview/llinventoryobserver.h
@@ -60,6 +60,7 @@ public:
CREATE = 512, // With ADD, item has just been created.
// unfortunately a particular message is still associated with some unique semantics.
UPDATE_CREATE = 1024, // With ADD, item added via UpdateCreateInventoryItem
+ UPDATE_FAVORITE = 2048, // With ADD, item added via UpdateCreateInventoryItem
ALL = 0xffffffff
};
LLInventoryObserver();
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index ab04a8589a..4aace2f96e 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -620,6 +620,19 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve
}
}
+ if (mask & LLInventoryObserver::UPDATE_FAVORITE)
+ {
+ if (view_item)
+ {
+ // TODO:: move to idle
+ LLFolderViewFolder* parent = view_item->getParentFolder();
+ if (parent)
+ {
+ parent->updateHasFavorites(view_item->isFavorite());
+ }
+ }
+ }
+
// We don't typically care which of these masks the item is actually flagged with, since the masks
// may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into
// Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks
@@ -648,6 +661,16 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve
setSelection(item_id, FALSE);
}
updateFolderLabel(model_item->getParentUUID());
+ if (model_item->getIsFavorite())
+ {
+ // TODO:: move to idle
+ LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getItemByID(model_item->getParentUUID());
+ if (new_parent)
+ {
+ new_parent->updateHasFavorites(true);
+ }
+ }
+
}
//////////////////////////////
@@ -694,6 +717,13 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve
updateFolderLabel(viewmodel_folder->getUUID());
}
old_parent->getViewModelItem()->dirtyDescendantsFilter();
+
+ if (view_item->isFavorite())
+ {
+ // TODO:: move to idle
+ old_parent->updateHasFavorites(false); // favorite was removed
+ new_parent->updateHasFavorites(true); // favorite was added
+ }
}
}
}
@@ -715,6 +745,11 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve
{
updateFolderLabel(viewmodel_folder->getUUID());
}
+ if (view_item->isFavorite())
+ {
+ // TODO:: move to idle
+ parent->updateHasFavorites(false); // favorite was removed
+ }
}
}
}