diff options
Diffstat (limited to 'indra/newview/llpaneloutfitsinventory.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitsinventory.cpp | 155 |
1 files changed, 140 insertions, 15 deletions
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 5ad9bf056e..4511bca23a 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -59,7 +59,7 @@ static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory"); LLPanelOutfitsInventory::LLPanelOutfitsInventory() : - mInventoryPanel(NULL), + mActivePanel(NULL), mParent(NULL) { mSavedFolderState = new LLSaveFolderState(); @@ -74,12 +74,8 @@ LLPanelOutfitsInventory::~LLPanelOutfitsInventory() // virtual BOOL LLPanelOutfitsInventory::postBuild() { - mInventoryPanel = getChild<LLInventoryPanel>("outfits_list"); - mInventoryPanel->setFilterTypes(1LL << LLFolderType::FT_OUTFIT, TRUE); - mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - mInventoryPanel->openDefaultFolderForType(LLFolderType::FT_MY_OUTFITS); - mInventoryPanel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onSelectionChange, this, _1, _2)); + initAccordionPanels(); initListCommandsHandlers(); return TRUE; } @@ -102,7 +98,7 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string) { if (string == "") { - mInventoryPanel->setFilterSubString(LLStringUtil::null); + mActivePanel->setFilterSubString(LLStringUtil::null); // re-open folders that were initially open mSavedFolderState->setApply(TRUE); @@ -114,7 +110,7 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string) gInventory.startBackgroundFetch(); - if (mInventoryPanel->getFilterSubString().empty() && string.empty()) + if (mActivePanel->getFilterSubString().empty() && string.empty()) { // current filter and new filter empty, do nothing return; @@ -128,7 +124,7 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string) } // set new filter string - mInventoryPanel->setFilterSubString(string); + mActivePanel->setFilterSubString(string); } void LLPanelOutfitsInventory::onWear() @@ -140,6 +136,24 @@ void LLPanelOutfitsInventory::onWear() } } +void LLPanelOutfitsInventory::onAdd() +{ + LLFolderViewEventListener* listenerp = getCorrectListenerForAction(); + if (listenerp) + { + listenerp->performAction(NULL, NULL,"addtooutfit"); + } +} + +void LLPanelOutfitsInventory::onRemove() +{ + LLFolderViewEventListener* listenerp = getCorrectListenerForAction(); + if (listenerp) + { + listenerp->performAction(NULL, NULL,"removefromoutfit"); + } +} + void LLPanelOutfitsInventory::onEdit() { } @@ -148,13 +162,17 @@ void LLPanelOutfitsInventory::onNew() { const std::string& outfit_name = LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_OUTFIT); LLUUID outfit_folder = gAgentWearables.makeNewOutfitLinks(outfit_name); - getRootFolder()->setSelectionByID(outfit_folder, TRUE); - getRootFolder()->setNeedsAutoRename(TRUE); } void LLPanelOutfitsInventory::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action) { + updateListCommands(); updateParent(); + if (getRootFolder()->needsAutoRename() && items.size()) + { + getRootFolder()->startRenamingSelectedItem(); + getRootFolder()->setNeedsAutoRename(FALSE); + } } void LLPanelOutfitsInventory::onSelectorButtonClicked() @@ -203,7 +221,7 @@ bool LLPanelOutfitsInventory::getIsCorrectType(const LLFolderViewEventListener * LLFolderView *LLPanelOutfitsInventory::getRootFolder() { - return mInventoryPanel->getRootFolder(); + return mActivePanel->getRootFolder(); } ////////////////////////////////////////////////////////////////////////////////// @@ -224,8 +242,10 @@ void LLPanelOutfitsInventory::initListCommandsHandlers() , _7 // EAcceptance* accept )); - mCommitCallbackRegistrar.add("panel_outfits_inventory_gear_default.Custom.Action", boost::bind(&LLPanelOutfitsInventory::onCustomAction, this, _2)); - mEnableCallbackRegistrar.add("panel_outfits_inventory_gear_default.Enable", boost::bind(&LLPanelOutfitsInventory::isActionEnabled, this, _2)); + mCommitCallbackRegistrar.add("panel_outfits_inventory_gear_default.Custom.Action", + boost::bind(&LLPanelOutfitsInventory::onCustomAction, this, _2)); + mEnableCallbackRegistrar.add("panel_outfits_inventory_gear_default.Enable", + boost::bind(&LLPanelOutfitsInventory::isActionEnabled, this, _2)); mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("panel_outfits_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); } @@ -290,6 +310,22 @@ void LLPanelOutfitsInventory::onCustomAction(const LLSD& userdata) { onWear(); } + if (command_name == "add") + { + onAdd(); + } + if (command_name == "remove") + { + onRemove(); + } + if (command_name == "rename") + { + onClipboardAction("rename"); + } + if (command_name == "remove_link") + { + onClipboardAction("delete"); + } if (command_name == "delete") { onClipboardAction("delete"); @@ -320,8 +356,33 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) } return FALSE; } + if (command_name == "remove_link") + { + BOOL can_delete = FALSE; + LLFolderView *folder = getActivePanel()->getRootFolder(); + if (folder) + { + can_delete = TRUE; + std::set<LLUUID> selection_set; + folder->getSelectionList(selection_set); + for (std::set<LLUUID>::iterator iter = selection_set.begin(); + iter != selection_set.end(); + ++iter) + { + const LLUUID &item_id = (*iter); + LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (!item || !item->getIsLinkType()) + return FALSE; + } + return can_delete; + } + return FALSE; + } if (command_name == "edit" || - command_name == "wear") + command_name == "wear" || + command_name == "add" || + command_name == "remove" + ) { return (getCorrectListenerForAction() != NULL); } @@ -345,3 +406,67 @@ bool LLPanelOutfitsInventory::handleDragAndDropToTrash(BOOL drop, EDragAndDropTy // List Commands // //////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +// Accordion // + +void LLPanelOutfitsInventory::initAccordionPanels() +{ + mAccordionPanels.resize(2); + + LLInventoryPanel *myoutfits_panel = getChild<LLInventoryPanel>("outfitslist_accordionpanel"); + myoutfits_panel->setFilterTypes(1LL << LLFolderType::FT_OUTFIT, LLInventoryFilter::FILTERTYPE_CATEGORY); + myoutfits_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + mAccordionPanels[0] = myoutfits_panel; + mActivePanel = myoutfits_panel; + + LLInventoryPanel *cof_panel = getChild<LLInventoryPanel>("cof_accordionpanel"); + cof_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + mAccordionPanels[1] = cof_panel; + + for (accordionpanels_vec_t::iterator iter = mAccordionPanels.begin(); + iter != mAccordionPanels.end(); + ++iter) + { + LLInventoryPanel *panel = (*iter); + panel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onAccordionSelectionChange, this, panel, _1, _2)); + } +} + +void LLPanelOutfitsInventory::onAccordionSelectionChange(LLInventoryPanel* accordion_panel, const std::deque<LLFolderViewItem*> &items, BOOL user_action) +{ + if (user_action && items.size() > 0) + { + for (accordionpanels_vec_t::iterator iter = mAccordionPanels.begin(); + iter != mAccordionPanels.end(); + ++iter) + { + LLInventoryPanel *panel = (*iter); + if (panel == accordion_panel) + { + mActivePanel = panel; + } + else + { + panel->getRootFolder()->clearSelection(); + } + } + } + onSelectionChange(items, user_action); +} + +LLInventoryPanel* LLPanelOutfitsInventory::getActivePanel() +{ + return mActivePanel; +} + +bool LLPanelOutfitsInventory::isAccordionPanel(LLInventoryPanel *panel) +{ + for(accordionpanels_vec_t::iterator it = mAccordionPanels.begin(); + it != mAccordionPanels.end(); + ++it) + { + if (*it == panel) + return true; + } + return false; +} |