diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorygallery.cpp | 65 | ||||
-rw-r--r-- | indra/newview/llinventorygallery.h | 4 |
2 files changed, 66 insertions, 3 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index f97cb9dbf4..18a7068b66 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -200,6 +200,14 @@ void LLInventoryGallery::updateRootFolder() delete mCategoriesObserver; mCategoriesObserver = new LLInventoryCategoriesObserver(); + + if (gInventory.containsObserver(mThumbnailsObserver)) + { + gInventory.removeObserver(mThumbnailsObserver); + } + delete mThumbnailsObserver; + mThumbnailsObserver = new LLThumbnailsObserver(); + gInventory.addObserver(mThumbnailsObserver); } { mRootChangedSignal(); @@ -699,7 +707,11 @@ void LLInventoryGallery::updateAddedItem(LLUUID item_id) LL_WARNS("InventoryGallery") << "Failed to find item: " << item_id << LL_ENDL; return; } - + if(!mFilter->checkAgainstFilterThumbnails(item_id)) + { + mThumbnailsObserver->addSkippedItem(item_id, boost::bind(&LLInventoryGallery::onThumbnailAdded, this, item_id)); + return; + } std::string name = obj->getName(); LLUUID thumbnail_id = obj->getThumbnailUUID();; LLInventoryType::EType inventory_type(LLInventoryType::IT_CATEGORY); @@ -816,6 +828,15 @@ void LLInventoryGallery::updateItemThumbnail(LLUUID item_id) } } +void LLInventoryGallery::onThumbnailAdded(LLUUID item_id) +{ + if((mItemMap.count(item_id) == 0) && mFilter->checkAgainstFilterThumbnails(item_id)) + { + updateAddedItem(item_id); + reArrangeRows(); + } +} + void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id) { if (mInventoryGalleryMenu && item_id.notNull()) @@ -1525,9 +1546,33 @@ void LLInventoryGalleryItem::updateNameText() void LLThumbnailsObserver::changed(U32 mask) { - if (!mItemMap.size()) - return; std::vector<LLUUID> deleted_ids; + for (item_map_t::iterator iter = mSkippedItems.begin(); + iter != mSkippedItems.end(); + ++iter) + { + const LLUUID& obj_id = (*iter).first; + LLItemData& data = (*iter).second; + + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (!obj) + { + deleted_ids.push_back(obj_id); + continue; + } + + const LLUUID thumbnail_id = obj->getThumbnailUUID(); + if (data.mThumbnailID != thumbnail_id) + { + data.mThumbnailID = thumbnail_id; + data.mCallback(); + } + } + for (std::vector<LLUUID>::iterator deleted_id = deleted_ids.begin(); deleted_id != deleted_ids.end(); ++deleted_id) + { + removeSkippedItem(*deleted_id); + } + deleted_ids.clear(); for (item_map_t::iterator iter = mItemMap.begin(); iter != mItemMap.end(); @@ -1569,11 +1614,25 @@ bool LLThumbnailsObserver::addItem(const LLUUID& obj_id, callback_t cb) return false; } +void LLThumbnailsObserver::addSkippedItem(const LLUUID& obj_id, callback_t cb) +{ + LLInventoryObject* obj = gInventory.getObject(obj_id); + if (obj) + { + mSkippedItems.insert(item_map_value_t(obj_id, LLItemData(obj_id, obj->getThumbnailUUID(), cb))); + } +} + void LLThumbnailsObserver::removeItem(const LLUUID& obj_id) { mItemMap.erase(obj_id); } +void LLThumbnailsObserver::removeSkippedItem(const LLUUID& obj_id) +{ + mSkippedItems.erase(obj_id); +} + //----------------------------- // Helper drag&drop functions //----------------------------- diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index f7065afdae..473d1a1db4 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -89,6 +89,7 @@ public: void updateRemovedItem(LLUUID item_id); void updateChangedItemName(LLUUID item_id, std::string name); void updateItemThumbnail(LLUUID item_id); + void onThumbnailAdded(LLUUID item_id); void updateWornItem(LLUUID item_id, bool is_worn); void updateMessageVisibility(); @@ -308,7 +309,9 @@ public: virtual void changed(U32 mask); bool addItem(const LLUUID& obj_id, callback_t cb); + void addSkippedItem(const LLUUID& obj_id, callback_t cb); void removeItem(const LLUUID& obj_id); + void removeSkippedItem(const LLUUID& obj_id); protected: @@ -328,6 +331,7 @@ protected: typedef std::map<LLUUID, LLItemData> item_map_t; typedef item_map_t::value_type item_map_value_t; item_map_t mItemMap; + item_map_t mSkippedItems; }; class LLGalleryGestureObserver : public LLGestureManagerObserver |