summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneloutfitsinventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpaneloutfitsinventory.cpp')
-rw-r--r--indra/newview/llpaneloutfitsinventory.cpp214
1 files changed, 130 insertions, 84 deletions
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index b78268da7b..660615df5a 100644
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -49,6 +49,7 @@
#include "lllineeditor.h"
#include "llmodaldialog.h"
#include "llnotificationsutil.h"
+#include "lloutfitslist.h"
#include "llsidepanelappearance.h"
#include "llsidetray.h"
#include "lltabcontainer.h"
@@ -67,15 +68,16 @@ static const std::string OUTFITS_TAB_NAME = "outfitslist_tab";
static const std::string COF_TAB_NAME = "cof_tab";
static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
-bool LLPanelOutfitsInventory::sShowDebugEditor = false;
LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
- mActivePanel(NULL),
+ mMyOutfitsPanel(NULL),
+ mCurrentOutfitPanel(NULL),
mParent(NULL)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
+ gAgentWearables.addLoadedCallback(boost::bind(&LLPanelOutfitsInventory::onWearablesLoaded, this));
}
LLPanelOutfitsInventory::~LLPanelOutfitsInventory()
@@ -86,10 +88,18 @@ LLPanelOutfitsInventory::~LLPanelOutfitsInventory()
// virtual
BOOL LLPanelOutfitsInventory::postBuild()
{
- sShowDebugEditor = gSavedSettings.getBOOL("ShowDebugAppearanceEditor");
initTabPanels();
initListCommandsHandlers();
+ // Fetch your outfits folder so that the links are in memory.
+ // ( This is only necessary if we want to show a warning if a user deletes an item that has a
+ // a link in an outfit, see "ConfirmItemDeleteHasLinks". )
+ const LLUUID &outfits_cat = gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTFIT, false);
+ if (outfits_cat.notNull())
+ {
+ LLInventoryModelBackgroundFetch::instance().start(outfits_cat);
+ }
+
return TRUE;
}
@@ -131,7 +141,6 @@ void LLPanelOutfitsInventory::updateVerbs()
if (mListCommands)
{
- mListCommands->childSetVisible("edit_current_outfit_btn",sShowDebugEditor);
updateListCommands();
}
}
@@ -145,9 +154,17 @@ void LLPanelOutfitsInventory::setParent(LLSidepanelAppearance* parent)
void LLPanelOutfitsInventory::onSearchEdit(const std::string& string)
{
mFilterSubString = string;
+
+ // TODO: add handling "My Outfits" tab.
+ if (!isCOFPanelActive())
+ {
+ mMyOutfitsPanel->setFilterSubString(string);
+ return;
+ }
+
if (string == "")
{
- mActivePanel->setFilterSubString(LLStringUtil::null);
+ getActivePanel()->setFilterSubString(LLStringUtil::null);
// re-open folders that were initially open
mSavedFolderState->setApply(TRUE);
@@ -159,7 +176,7 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string)
LLInventoryModelBackgroundFetch::instance().start();
- if (mActivePanel->getFilterSubString().empty() && string.empty())
+ if (getActivePanel()->getFilterSubString().empty() && string.empty())
{
// current filter and new filter empty, do nothing
return;
@@ -173,24 +190,43 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string)
}
// set new filter string
- mActivePanel->setFilterSubString(string);
+ getActivePanel()->setFilterSubString(string);
}
void LLPanelOutfitsInventory::onWearButtonClick()
{
- LLFolderViewEventListener* listenerp = getCorrectListenerForAction();
- if (listenerp)
+ // TODO: Remove if/else, add common interface
+ // for "My Outfits" and "Wearing" tabs.
+ if (!isCOFPanelActive())
{
- listenerp->performAction(NULL, "replaceoutfit");
+ mMyOutfitsPanel->performAction("replaceoutfit");
+ setWearablesLoading(true);
+ }
+ else
+ {
+ LLFolderViewEventListener* listenerp = getCorrectListenerForAction();
+ if (listenerp)
+ {
+ listenerp->performAction(NULL, "replaceoutfit");
+ }
}
}
void LLPanelOutfitsInventory::onAdd()
{
- LLFolderViewEventListener* listenerp = getCorrectListenerForAction();
- if (listenerp)
+ // TODO: Remove if/else, add common interface
+ // for "My Outfits" and "Wearing" tabs.
+ if (!isCOFPanelActive())
{
- listenerp->performAction(NULL, "addtooutfit");
+ mMyOutfitsPanel->performAction("addtooutfit");
+ }
+ else
+ {
+ LLFolderViewEventListener* listenerp = getCorrectListenerForAction();
+ if (listenerp)
+ {
+ listenerp->performAction(NULL, "addtooutfit");
+ }
}
}
@@ -216,7 +252,7 @@ bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD&
LLStringUtil::trim(outfit_name);
if( !outfit_name.empty() )
{
- LLUUID outfit_folder = gAgentWearables.makeNewOutfitLinks(outfit_name);
+ LLUUID outfit_folder = LLAppearanceMgr::getInstance()->makeNewOutfitLinks(outfit_name);
LLSidepanelAppearance* panel_appearance =
dynamic_cast<LLSidepanelAppearance *>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
@@ -267,6 +303,11 @@ void LLPanelOutfitsInventory::onSave()
void LLPanelOutfitsInventory::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action)
{
updateVerbs();
+
+ // TODO: add handling "My Outfits" tab.
+ if (!isCOFPanelActive())
+ return;
+
if (getRootFolder()->needsAutoRename() && items.size())
{
getRootFolder()->startRenamingSelectedItem();
@@ -274,16 +315,12 @@ void LLPanelOutfitsInventory::onSelectionChange(const std::deque<LLFolderViewIte
}
}
-void LLPanelOutfitsInventory::showEditOutfitPanel()
-{
- LLSD key;
- key["type"] = "edit_outfit";
-
- LLSideTray::getInstance()->showPanel("sidepanel_appearance", key);
-}
-
LLFolderViewEventListener *LLPanelOutfitsInventory::getCorrectListenerForAction()
{
+ // TODO: add handling "My Outfits" tab.
+ if (!isCOFPanelActive())
+ return NULL;
+
LLFolderViewItem* current_item = getRootFolder()->getCurSelectedItem();
if (!current_item)
return NULL;
@@ -311,7 +348,7 @@ bool LLPanelOutfitsInventory::getIsCorrectType(const LLFolderViewEventListener *
LLFolderView *LLPanelOutfitsInventory::getRootFolder()
{
- return mActivePanel->getRootFolder();
+ return getActivePanel()->getRootFolder();
}
//static
@@ -332,8 +369,6 @@ void LLPanelOutfitsInventory::initListCommandsHandlers()
mListCommands->childSetAction("make_outfit_btn", boost::bind(&LLPanelOutfitsInventory::onAddButtonClick, this));
mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this));
- mListCommands->childSetAction("edit_current_outfit_btn", boost::bind(&LLPanelOutfitsInventory::showEditOutfitPanel, this));
-
LLDragAndDropButton* trash_btn = mListCommands->getChild<LLDragAndDropButton>("trash_btn");
trash_btn->setDragAndDropHandler(boost::bind(&LLPanelOutfitsInventory::handleDragAndDropToTrash, this
, _4 // BOOL drop
@@ -393,7 +428,11 @@ void LLPanelOutfitsInventory::onTrashButtonClick()
void LLPanelOutfitsInventory::onClipboardAction(const LLSD& userdata)
{
std::string command_name = userdata.asString();
- getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name);
+ // TODO: add handling "My Outfits" tab.
+ if (isCOFPanelActive())
+ {
+ getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name);
+ }
updateListCommands();
updateVerbs();
}
@@ -447,21 +486,25 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
if (command_name == "delete" || command_name == "remove")
{
BOOL can_delete = FALSE;
- LLFolderView* root = getActivePanel()->getRootFolder();
- if (root)
+
+ // TODO: add handling "My Outfits" tab.
+ if (isCOFPanelActive())
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
- can_delete = (selection_set.size() > 0);
- for (std::set<LLUUID>::iterator iter = selection_set.begin();
- iter != selection_set.end();
- ++iter)
+ LLFolderView* root = getActivePanel()->getRootFolder();
+ if (root)
{
- const LLUUID &item_id = (*iter);
- LLFolderViewItem *item = root->getItemByID(item_id);
- can_delete &= item->getListener()->isItemRemovable();
+ std::set<LLUUID> selection_set = root->getSelectionList();
+ can_delete = (selection_set.size() > 0);
+ for (std::set<LLUUID>::iterator iter = selection_set.begin();
+ iter != selection_set.end();
+ ++iter)
+ {
+ const LLUUID &item_id = (*iter);
+ LLFolderViewItem *item = root->getItemByID(item_id);
+ can_delete &= item->getListener()->isItemRemovable();
+ }
+ return can_delete;
}
- return can_delete;
}
return FALSE;
}
@@ -471,8 +514,7 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
LLFolderView* root = getActivePanel()->getRootFolder();
if (root)
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
+ std::set<LLUUID> selection_set = root->getSelectionList();
can_delete = (selection_set.size() > 0);
for (std::set<LLUUID>::iterator iter = selection_set.begin();
iter != selection_set.end();
@@ -517,12 +559,16 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
bool LLPanelOutfitsInventory::hasItemsSelected()
{
bool has_items_selected = false;
- LLFolderView* root = getActivePanel()->getRootFolder();
- if (root)
+
+ // TODO: add handling "My Outfits" tab.
+ if (isCOFPanelActive())
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
- has_items_selected = (selection_set.size() > 0);
+ LLFolderView* root = getActivePanel()->getRootFolder();
+ if (root)
+ {
+ std::set<LLUUID> selection_set = root->getSelectionList();
+ has_items_selected = (selection_set.size() > 0);
+ }
}
return has_items_selected;
}
@@ -549,74 +595,74 @@ bool LLPanelOutfitsInventory::handleDragAndDropToTrash(BOOL drop, EDragAndDropTy
void LLPanelOutfitsInventory::initTabPanels()
{
- LLInventoryPanel *cof_panel = getChild<LLInventoryPanel>(COF_TAB_NAME);
- cof_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
- mTabPanels.push_back(cof_panel);
+ mCurrentOutfitPanel = getChild<LLInventoryPanel>(COF_TAB_NAME);
+ mCurrentOutfitPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
+ mCurrentOutfitPanel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onTabSelectionChange, this, mCurrentOutfitPanel, _1, _2));
- LLInventoryPanel *myoutfits_panel = getChild<LLInventoryPanel>(OUTFITS_TAB_NAME);
- myoutfits_panel->setFilterTypes(1LL << LLFolderType::FT_OUTFIT, LLInventoryFilter::FILTERTYPE_CATEGORY);
- myoutfits_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
- mTabPanels.push_back(myoutfits_panel);
-
- for (tabpanels_vec_t::iterator iter = mTabPanels.begin();
- iter != mTabPanels.end();
- ++iter)
- {
- LLInventoryPanel *panel = (*iter);
- panel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onTabSelectionChange, this, panel, _1, _2));
- }
+ mMyOutfitsPanel = getChild<LLOutfitsList>(OUTFITS_TAB_NAME);
mAppearanceTabs = getChild<LLTabContainer>("appearance_tabs");
mAppearanceTabs->setCommitCallback(boost::bind(&LLPanelOutfitsInventory::onTabChange, this));
- mActivePanel = (LLInventoryPanel*)mAppearanceTabs->getCurrentPanel();
}
void LLPanelOutfitsInventory::onTabSelectionChange(LLInventoryPanel* tab_panel, const std::deque<LLFolderViewItem*> &items, BOOL user_action)
{
if (user_action && items.size() > 0)
{
- for (tabpanels_vec_t::iterator iter = mTabPanels.begin();
- iter != mTabPanels.end();
- ++iter)
+ // TODO: add handling "My Outfits" tab.
+ if (isCOFPanelActive())
{
- LLInventoryPanel *panel = (*iter);
- if (panel == tab_panel)
- {
- mActivePanel = panel;
- }
- else
- {
- panel->getRootFolder()->clearSelection();
- }
+ onSelectionChange(items, user_action);
+ }
+ else
+ {
+ mCurrentOutfitPanel->getRootFolder()->clearSelection();
}
}
- onSelectionChange(items, user_action);
}
void LLPanelOutfitsInventory::onTabChange()
{
- mActivePanel = (LLInventoryPanel*)childGetVisibleTab("appearance_tabs");
- if (!mActivePanel)
+ // TODO: add handling "My Outfits" tab.
+ if (isCOFPanelActive())
{
- return;
+ mCurrentOutfitPanel->setFilterSubString(mFilterSubString);
}
- mActivePanel->setFilterSubString(mFilterSubString);
+ else
+ {
+ mMyOutfitsPanel->setFilterSubString(mFilterSubString);
+ }
+
updateVerbs();
}
BOOL LLPanelOutfitsInventory::isTabPanel(LLInventoryPanel *panel) const
{
- for(tabpanels_vec_t::const_iterator it = mTabPanels.begin();
- it != mTabPanels.end();
- ++it)
+ // TODO: add handling "My Outfits" tab.
+ if (mCurrentOutfitPanel == panel)
{
- if (*it == panel)
- return TRUE;
+ return TRUE;
}
return FALSE;
}
BOOL LLPanelOutfitsInventory::isCOFPanelActive() const
{
- return (getActivePanel()->getName() == COF_TAB_NAME);
+ return (childGetVisibleTab("appearance_tabs")->getName() == COF_TAB_NAME);
+}
+
+void LLPanelOutfitsInventory::setWearablesLoading(bool val)
+{
+ mListCommands->childSetEnabled("wear_btn", !val);
+
+ llassert(mParent);
+ if (mParent)
+ {
+ mParent->setWearablesLoading(val);
+ }
+}
+
+void LLPanelOutfitsInventory::onWearablesLoaded()
+{
+ setWearablesLoading(false);
}