diff options
author | Loren Shih <seraph@lindenlab.com> | 2009-12-04 20:07:09 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2009-12-04 20:07:09 -0500 |
commit | add459cfd2245dd116392426f12ba04365b579de (patch) | |
tree | 5bc77dcdca65821a3984330a69f314264c4cb516 /indra/newview | |
parent | c9c9943098d35914f7b8591bf66ea1ae3985a94e (diff) |
EXT-3179 : Add ability to recover broken links
EXT-3168 : Add "Find Original" to InventoryPanel gear menu
Broken link recovery is still work in progress.
--HG--
branch : avatar-pipeline
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 90 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml | 24 |
4 files changed, 167 insertions, 2 deletions
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 2a56a6011e..92b4c8383e 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -966,6 +966,27 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata) preview_texture->openToSave(); } } + if (command_name == "regenerate_link") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + const LLUUID& item_id = current_item->getListener()->getUUID(); + LLViewerInventoryItem *item = gInventory.getItem(item_id); + item->regenerateLink(); + } + if (command_name == "find_original") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) + { + return; + } + current_item->getListener()->performAction(getActivePanel()->getRootFolder(), getActivePanel()->getModel(), "goto"); + } + if (command_name == "find_links") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); @@ -1017,18 +1038,45 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata) } return FALSE; } + if (command_name == "find_original") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) return FALSE; + const LLUUID& item_id = current_item->getListener()->getUUID(); + const LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item && item->getIsLinkType() && !item->getIsBrokenLink()) + { + return TRUE; + } + return FALSE; + } + if (command_name == "find_links") { LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) return FALSE; const LLUUID& item_id = current_item->getListener()->getUUID(); - LLInventoryObject *obj = gInventory.getObject(item_id); + const LLInventoryObject *obj = gInventory.getObject(item_id); if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType())) { return TRUE; } return FALSE; } + + if (command_name == "regenerate_link") + { + LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) return FALSE; + const LLUUID& item_id = current_item->getListener()->getUUID(); + const LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item && item->getIsBrokenLink()) + { + return TRUE; + } + return FALSE; + } + return TRUE; } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 5bdcbc79bd..bcb3a2e72d 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1435,3 +1435,93 @@ void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std: gInventory.notifyObservers(); } +class LLRegenerateLinkCollector : public LLInventoryCollectFunctor +{ +public: + LLRegenerateLinkCollector(const LLViewerInventoryItem *target_item) : mTargetItem(target_item) {} + virtual ~LLRegenerateLinkCollector() {} + virtual bool operator()(LLInventoryCategory* cat, + LLInventoryItem* item) + { + if (item) + { + if ((item->getName() == mTargetItem->getName()) && + (item->getInventoryType() == mTargetItem->getInventoryType()) && + (!item->getIsLinkType())) + { + return true; + } + } + return false; + } +protected: + const LLViewerInventoryItem* mTargetItem; +}; + +LLUUID find_possible_item_for_regeneration(const LLViewerInventoryItem *target_item) +{ + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + /* + LLAssetIDMatches asset_id_matches(target_item->getAssetUUID()); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + asset_id_matches); + for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items.begin(); + item_iter != items.end(); + item_iter++) + { + const LLViewerInventoryItem *item = (*item_iter); + if (!item->getIsBrokenLink()) + { + return item->getAssetUUID(); + } + } + */ + + items.clear(); + cats.clear(); + + LLRegenerateLinkCollector candidate_matches(target_item); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + candidate_matches); + for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items.begin(); + item_iter != items.end(); + ++item_iter) + { + const LLViewerInventoryItem *item = (*item_iter); + if (true) return item->getUUID(); + } + return LLUUID::null; +} + +BOOL LLViewerInventoryItem::regenerateLink() +{ + const LLUUID target_item_id = find_possible_item_for_regeneration(this); + if (target_item_id.isNull()) + return FALSE; + LLViewerInventoryCategory::cat_array_t cats; + LLViewerInventoryItem::item_array_t items; + LLAssetIDMatches asset_id_matches(getAssetUUID()); + gInventory.collectDescendentsIf(LLUUID::null, + cats, + items, + LLInventoryModel::EXCLUDE_TRASH, + asset_id_matches); + for (LLViewerInventoryItem::item_array_t::iterator item_iter = items.begin(); + item_iter != items.end(); + item_iter++) + { + LLViewerInventoryItem *item = (*item_iter); + item->setAssetUUID(target_item_id); + item->updateServer(FALSE); + gInventory.addChangedMask(LLInventoryObserver::REBUILD, item->getUUID()); + } + gInventory.notifyObservers(); + return TRUE; +} diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index d27faffdd9..0156e7dab1 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -161,7 +161,10 @@ public: // callback void onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name); - + + // If this is a broken link, try to fix it and any other identical link. + BOOL regenerateLink(); + public: BOOL mIsComplete; LLTransactionID mTransactionID; diff --git a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml index 7a3e91d5a1..e5592c3c57 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory_gear_default.xml @@ -76,6 +76,8 @@ function="Inventory.GearDefault.Custom.Action" parameter="empty_lostnfound" /> </menu_item_call> + <menu_item_separator + layout="topleft" /> <menu_item_call label="Save Texture As" layout="topleft" @@ -88,6 +90,17 @@ parameter="save_texture" /> </menu_item_call> <menu_item_call + label="Find Original" + layout="topleft" + name="Find Original"> + <on_click + function="Inventory.GearDefault.Custom.Action" + parameter="find_original" /> + <on_enable + function="Inventory.GearDefault.Enable" + parameter="find_original" /> + </menu_item_call> + <menu_item_call label="Find All Links" layout="topleft" name="Find All Links"> @@ -98,4 +111,15 @@ function="Inventory.GearDefault.Enable" parameter="find_links" /> </menu_item_call> + <menu_item_call + label="Regenerate Link" + layout="topleft" + name="Regenerate Link"> + <on_click + function="Inventory.GearDefault.Custom.Action" + parameter="regenerate_link" /> + <on_enable + function="Inventory.GearDefault.Enable" + parameter="regenerate_link" /> + </menu_item_call> </menu> |