diff options
author | Loren Shih <seraph@lindenlab.com> | 2009-12-02 16:12:39 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2009-12-02 16:12:39 -0500 |
commit | 4b5849b6c07939abd4840ebf327279da6651dd78 (patch) | |
tree | 27109a0dd16a73880454a9c256522823b8e1a904 /indra | |
parent | 99b6b14ea1ea6cf61ff06e8806a1d1a08b4a1420 (diff) |
EXT-3060 : Turn links into broken links immediately when baseobj is purged
EXT-3067 : INFRASTRUCTURE : LLInventoryPanel::modelChanged cleanup
This first set of checkins is just llinventorypanel infrastructure cleanup, including comments and improved use of iterators.
--HG--
branch : avatar-pipeline
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorymodel.h | 5 | ||||
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 154 |
2 files changed, 76 insertions, 83 deletions
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 50f54cb842..d47614e403 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -82,6 +82,8 @@ public: // These are used a lot... typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t; typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t; + typedef std::set<LLUUID> changed_items_t; + // construction & destruction LLInventoryModel(); ~LLInventoryModel(); @@ -269,7 +271,7 @@ public: // that the next notify will include that notification. void addChangedMask(U32 mask, const LLUUID& referent); - const std::set<LLUUID>& getChangedIDs() { return mChangedItemIDs; } + const changed_items_t& getChangedIDs() const { return mChangedItemIDs; } // This method to prepares a set of mock inventory which provides // minimal functionality before the actual arrival of inventory. @@ -451,7 +453,6 @@ protected: private: // Variables used to track what has changed since the last notify. U32 mModifyMask; - typedef std::set<LLUUID> changed_items_t; changed_items_t mChangedItemIDs; std::map<LLUUID, bool> mCategoryLock; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 9945bb4404..02d0217321 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -260,109 +260,101 @@ void LLInventoryPanel::modelChanged(U32 mask) bool handled = false; - if (!mViewsInitialized) - { - return; - } + if (!mViewsInitialized) return; - if (mask & LLInventoryObserver::LABEL) - { - handled = true; - // Label change - empty out the display name for each object in this change set. - const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); - std::set<LLUUID>::const_iterator id_it = changed_items.begin(); - std::set<LLUUID>::const_iterator id_end = changed_items.end(); - LLFolderViewItem* view = NULL; - LLInvFVBridge* bridge = NULL; - for (;id_it != id_end; ++id_it) + const LLInventoryModel* model = getModel(); + if (!model) return; + + const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); + if (changed_items.empty()) return; + + for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); + items_iter != changed_items.end(); + ++items_iter) + { + const LLUUID& item_id = (*items_iter); + const LLInventoryObject* model_item = model->getObject(item_id); + LLFolderViewItem* view_item = mFolders->getItemByID(item_id); + + ////////////////////////////// + // LABEL Operation + // Empty out the display name for relabel. + if (mask & LLInventoryObserver::LABEL) { - view = mFolders->getItemByID(*id_it); - if(view) + handled = true; + if (view_item) { // Request refresh on this item (also flags for filtering) - bridge = (LLInvFVBridge*)view->getListener(); + LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener(); if(bridge) { // Clear the display name first, so it gets properly re-built during refresh() bridge->clearDisplayName(); } - view->refresh(); + view_item->refresh(); } } - } - - // We don't really 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 - // panel). What's relevant is that the item and UI are probably out of sync and thus need to be - // resynchronized. - if (mask & (LLInventoryObserver::STRUCTURE | - LLInventoryObserver::ADD | - LLInventoryObserver::REMOVE)) - { - handled = true; - LLInventoryModel* model = getModel(); - if (model) + + // 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 + // panel). What's relevant is that the item and UI are probably out of sync and thus need to be + // resynchronized. + if (mask & (LLInventoryObserver::STRUCTURE | + LLInventoryObserver::ADD | + LLInventoryObserver::REMOVE)) { - const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); + handled = true; - std::set<LLUUID>::const_iterator id_it = changed_items.begin(); - std::set<LLUUID>::const_iterator id_end = changed_items.end(); - for (;id_it != id_end; ++id_it) + ////////////////////////////// + // ADD Operation + // Item exists in memory but a UI element hasn't been created for it. + if (model_item && !view_item) { - LLInventoryObject* model_item = model->getObject(*id_it); - LLFolderViewItem* view_item = mFolders->getItemByID(*id_it); - - ////////////////////////////// - // ADD Operation - // Item exists in memory but a UI element hasn't been created for it. - if (model_item && !view_item) + // Add the UI element for this item. + buildNewViews(item_id); + // Select any newly created object that has the auto rename at top of folder root set. + if(mFolders->getRoot()->needsAutoRename()) { - // Add the UI element for this item. - buildNewViews(*id_it); - // Select any newly created object that has the auto rename at top of folder root set. - if(mFolders->getRoot()->needsAutoRename()) - { - setSelection(*id_it, FALSE); - } + setSelection(item_id, FALSE); } + } - ////////////////////////////// - // STRUCTURE Operation - // This item already exists in both memory and UI. It was probably reparented. - if (model_item && view_item) + ////////////////////////////// + // STRUCTURE Operation + // This item already exists in both memory and UI. It was probably reparented. + if (model_item && view_item) + { + // Don't process the item if it's hanging from the root, since its + // model_item's parent will be NULL. + if (view_item->getRoot() != view_item->getParent()) { - // Don't process the item if it's hanging from the root, since its - // model_item's parent will be NULL. - if (view_item->getRoot() != view_item->getParent()) + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID()); + // Item has been moved. + if (view_item->getParentFolder() != new_parent) { - LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID()); - // Item has been moved. - if (view_item->getParentFolder() != new_parent) + if (new_parent != NULL) { - if (new_parent != NULL) - { - // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. - view_item->getParentFolder()->extractItem(view_item); - view_item->addToFolder(new_parent, mFolders); - } - else - { - // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that - // doesn't include trash). Just remove the item's UI. - view_item->destroyView(); - } + // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. + view_item->getParentFolder()->extractItem(view_item); + view_item->addToFolder(new_parent, mFolders); + } + else + { + // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that + // doesn't include trash). Just remove the item's UI. + view_item->destroyView(); } } } - - ////////////////////////////// - // REMOVE Operation - // This item has been removed from memory, but its associated UI element still exists. - if (!model_item && view_item) - { - // Remove the item's UI. - view_item->destroyView(); - } + } + + ////////////////////////////// + // REMOVE Operation + // This item has been removed from memory, but its associated UI element still exists. + if (!model_item && view_item) + { + // Remove the item's UI. + view_item->destroyView(); } } } |