diff options
Diffstat (limited to 'indra/newview/llsidepanelinventory.cpp')
-rw-r--r-- | indra/newview/llsidepanelinventory.cpp | 399 |
1 files changed, 306 insertions, 93 deletions
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 65655f82cd..9d069c3996 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -34,6 +34,7 @@ #include "llbutton.h" #include "lldate.h" #include "llfirstuse.h" +#include "llfloatersidepanelcontainer.h" #include "llfoldertype.h" #include "llhttpclient.h" #include "llinventorybridge.h" @@ -52,7 +53,10 @@ #include "llsidepaneltaskinfo.h" #include "llstring.h" #include "lltabcontainer.h" +#include "lltextbox.h" +#include "lltrans.h" #include "llviewermedia.h" +#include "llviewernetwork.h" #include "llweb.h" static LLRegisterPanelClassWrapper<LLSidepanelInventory> t_inventory("sidepanel_inventory"); @@ -61,18 +65,25 @@ static LLRegisterPanelClassWrapper<LLSidepanelInventory> t_inventory("sidepanel_ // Constants // -static const char * const INBOX_EXPAND_TIME_SETTING = "LastInventoryInboxExpand"; +// No longer want the inbox panel to auto-expand since it creates issues with the "new" tag time stamp +#define AUTO_EXPAND_INBOX 0 + +// Temporarily disabling the outbox until we straighten out the API +#define ENABLE_MERCHANT_OUTBOX_PANEL 0 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU static const char * const INBOX_BUTTON_NAME = "inbox_btn"; static const char * const OUTBOX_BUTTON_NAME = "outbox_btn"; static const char * const INBOX_LAYOUT_PANEL_NAME = "inbox_layout_panel"; static const char * const OUTBOX_LAYOUT_PANEL_NAME = "outbox_layout_panel"; + +static const char * const INBOX_OUTBOX_LAYOUT_PANEL_NAME = "inbox_outbox_layout_panel"; static const char * const MAIN_INVENTORY_LAYOUT_PANEL_NAME = "main_inventory_layout_panel"; static const char * const INBOX_INVENTORY_PANEL = "inventory_inbox"; static const char * const OUTBOX_INVENTORY_PANEL = "inventory_outbox"; +static const char * const INBOX_OUTBOX_LAYOUT_STACK_NAME = "inbox_outbox_layout_stack"; static const char * const INVENTORY_LAYOUT_STACK_NAME = "inventory_layout_stack"; static const char * const MARKETPLACE_INBOX_PANEL = "marketplace_inbox"; @@ -102,21 +113,13 @@ public: switch (added_category_type) { case LLFolderType::FT_INBOX: + mSidepanelInventory->enableInbox(true); mSidepanelInventory->observeInboxModifications(added_category->getUUID()); break; case LLFolderType::FT_OUTBOX: + mSidepanelInventory->enableOutbox(true); mSidepanelInventory->observeOutboxModifications(added_category->getUUID()); break; - case LLFolderType::FT_NONE: - // HACK until sim update to properly create folder with system type - if (added_category->getName() == "Received Items") - { - mSidepanelInventory->observeInboxModifications(added_category->getUUID()); - } - else if (added_category->getName() == "Merchant Outbox") - { - mSidepanelInventory->observeOutboxModifications(added_category->getUUID()); - } default: break; } @@ -134,6 +137,8 @@ private: LLSidepanelInventory::LLSidepanelInventory() : LLPanel() , mItemPanel(NULL) + , mInventoryPanelInbox(NULL) + , mInventoryPanelOutbox(NULL) , mPanelMainInventory(NULL) , mInboxEnabled(false) , mOutboxEnabled(false) @@ -160,16 +165,20 @@ LLSidepanelInventory::~LLSidepanelInventory() void handleInventoryDisplayInboxChanged() { - LLSidepanelInventory* sidepanel_inventory = dynamic_cast<LLSidepanelInventory*>(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); - - sidepanel_inventory->enableInbox(gSavedSettings.getBOOL("InventoryDisplayInbox")); + LLSidepanelInventory* sidepanel_inventory = LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory"); + if (sidepanel_inventory) + { + sidepanel_inventory->enableInbox(gSavedSettings.getBOOL("InventoryDisplayInbox")); + } } void handleInventoryDisplayOutboxChanged() { - LLSidepanelInventory* sidepanel_inventory = dynamic_cast<LLSidepanelInventory*>(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); - - sidepanel_inventory->enableOutbox(gSavedSettings.getBOOL("InventoryDisplayOutbox")); + LLSidepanelInventory* sidepanel_inventory = LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory"); + if (sidepanel_inventory) + { + sidepanel_inventory->enableOutbox(gSavedSettings.getBOOL("InventoryDisplayOutbox")); + } } BOOL LLSidepanelInventory::postBuild() @@ -235,16 +244,20 @@ BOOL LLSidepanelInventory::postBuild() // Marketplace inbox/outbox setup { - LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); + LLLayoutStack* inv_stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); // Disable user_resize on main inventory panel by default - stack->setPanelUserResize(MAIN_INVENTORY_LAYOUT_PANEL_NAME, false); - stack->setPanelUserResize(INBOX_LAYOUT_PANEL_NAME, false); - stack->setPanelUserResize(OUTBOX_LAYOUT_PANEL_NAME, false); + inv_stack->setPanelUserResize(MAIN_INVENTORY_LAYOUT_PANEL_NAME, false); + inv_stack->setPanelUserResize(INBOX_OUTBOX_LAYOUT_PANEL_NAME, false); + + // Collapse marketplace panel by default + inv_stack->collapsePanel(getChild<LLLayoutPanel>(INBOX_OUTBOX_LAYOUT_PANEL_NAME), true); + + LLLayoutStack* inout_stack = getChild<LLLayoutStack>(INBOX_OUTBOX_LAYOUT_STACK_NAME); // Collapse both inbox and outbox panels - stack->collapsePanel(getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME), true); - stack->collapsePanel(getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME), true); + inout_stack->collapsePanel(getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME), true); + inout_stack->collapsePanel(getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME), true); // Set up button states and callbacks LLButton * inbox_button = getChild<LLButton>(INBOX_BUTTON_NAME); @@ -261,16 +274,19 @@ BOOL LLSidepanelInventory::postBuild() enableOutbox(gSavedSettings.getBOOL("InventoryDisplayOutbox")); // Trigger callback for after login so we can setup to track inbox and outbox changes after initial inventory load - LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLSidepanelInventory::handleLoginComplete, this)); + LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLSidepanelInventory::updateInboxOutbox, this)); } gSavedSettings.getControl("InventoryDisplayInbox")->getCommitSignal()->connect(boost::bind(&handleInventoryDisplayInboxChanged)); gSavedSettings.getControl("InventoryDisplayOutbox")->getCommitSignal()->connect(boost::bind(&handleInventoryDisplayOutboxChanged)); + // Update the verbs buttons state. + updateVerbs(); + return TRUE; } -void LLSidepanelInventory::handleLoginComplete() +void LLSidepanelInventory::updateInboxOutbox() { // // Track inbox and outbox folder changes @@ -291,21 +307,22 @@ void LLSidepanelInventory::handleLoginComplete() // Set up observer for inbox changes, if we have an inbox already if (!inbox_id.isNull()) { - observeInboxModifications(inbox_id); - // Enable the display of the inbox if it exists enableInbox(true); + + observeInboxModifications(inbox_id); } +#if ENABLE_MERCHANT_OUTBOX_PANEL // Set up observer for outbox changes, if we have an outbox already if (!outbox_id.isNull()) { - observeOutboxModifications(outbox_id); - // Enable the display of the outbox if it exists - //enableOutbox(true); - // leslie NOTE: Disabling outbox until we support it officially. + enableOutbox(true); + + observeOutboxModifications(outbox_id); } +#endif } void LLSidepanelInventory::observeInboxOutboxCreation() @@ -353,7 +370,7 @@ void LLSidepanelInventory::observeInboxModifications(const LLUUID& inboxID) // LLPanelMarketplaceInbox * inbox = getChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL); - inbox->setupInventoryPanel(); + mInventoryPanelInbox = inbox->setupInventoryPanel(); } @@ -382,106 +399,183 @@ void LLSidepanelInventory::observeOutboxModifications(const LLUUID& outboxID) // LLPanelMarketplaceOutbox * outbox = getChild<LLPanelMarketplaceOutbox>(MARKETPLACE_OUTBOX_PANEL); - outbox->setupInventoryPanel(); + mInventoryPanelOutbox = outbox->setupInventoryPanel(); } void LLSidepanelInventory::enableInbox(bool enabled) { mInboxEnabled = enabled; - getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); + + LLLayoutPanel * inbox_layout_panel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + inbox_layout_panel->setVisible(enabled); + + if (mInboxEnabled) + { + LLLayoutPanel * inout_layout_panel = getChild<LLLayoutPanel>(INBOX_OUTBOX_LAYOUT_PANEL_NAME); + + inout_layout_panel->setVisible(TRUE); + + if (mOutboxEnabled) + { + S32 inbox_min_dim = inbox_layout_panel->getMinDim(); + S32 outbox_min_dim = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME)->getMinDim(); + + inout_layout_panel->setMinDim(inbox_min_dim + outbox_min_dim); + } + } } void LLSidepanelInventory::enableOutbox(bool enabled) { mOutboxEnabled = enabled; - getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); + + LLLayoutPanel * outbox_layout_panel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); + outbox_layout_panel->setVisible(enabled); + + if (mOutboxEnabled) + { + LLLayoutPanel * inout_layout_panel = getChild<LLLayoutPanel>(INBOX_OUTBOX_LAYOUT_PANEL_NAME); + + inout_layout_panel->setVisible(TRUE); + + if (mInboxEnabled) + { + S32 inbox_min_dim = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME)->getMinDim(); + S32 outbox_min_dim = outbox_layout_panel->getMinDim(); + + inout_layout_panel->setMinDim(inbox_min_dim + outbox_min_dim); + } + + updateOutboxUserStatus(); + } +} + +void LLSidepanelInventory::openInbox() +{ + if (mInboxEnabled) + { + getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true); + onToggleInboxBtn(); + } +} + +void LLSidepanelInventory::openOutbox() +{ + if (mOutboxEnabled) + { + getChild<LLButton>(OUTBOX_BUTTON_NAME)->setToggleState(true); + onToggleOutboxBtn(); + } } void LLSidepanelInventory::onInboxChanged(const LLUUID& inbox_id) { // Trigger a load of the entire inbox so we always know the contents and their creation dates for sorting LLInventoryModelBackgroundFetch::instance().start(inbox_id); - - // Expand the inbox since we have fresh items - LLPanelMarketplaceInbox * inbox = findChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL); - if (inbox && (inbox->getFreshItemCount() > 0)) + +#if AUTO_EXPAND_INBOX + // If the outbox is expanded, don't auto-expand the inbox + if (mOutboxEnabled) + { + if (getChild<LLButton>(OUTBOX_BUTTON_NAME)->getToggleState()) + { + return; + } + } + + // Expand the inbox since we have fresh items and the outbox is not expanded + if (mInboxEnabled) { getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true); onToggleInboxBtn(); - } + } +#endif } void LLSidepanelInventory::onOutboxChanged(const LLUUID& outbox_id) { - // Perhaps use this to track outbox changes? + // Expand the outbox since we have new items in it + if (mOutboxEnabled) + { + getChild<LLButton>(OUTBOX_BUTTON_NAME)->setToggleState(true); + onToggleOutboxBtn(); + } } -bool manageInboxOutboxPanels(LLLayoutStack * stack, - LLButton * pressedButton, LLLayoutPanel * pressedPanel, +bool LLSidepanelInventory::manageInboxOutboxPanels(LLButton * pressedButton, LLLayoutPanel * pressedPanel, LLButton * otherButton, LLLayoutPanel * otherPanel) { bool expand = pressedButton->getToggleState(); bool otherExpanded = otherButton->getToggleState(); - // - // NOTE: Ideally we could have two panel sizes stored for a collapsed and expanded minimum size. - // For now, leave this code disabled because it creates some bad artifacts when expanding - // and collapsing the inbox/outbox. - // - //S32 smallMinSize = (expand ? pressedPanel->getMinDim() : otherPanel->getMinDim()); - //S32 pressedMinSize = (expand ? 2 * smallMinSize : smallMinSize); - //otherPanel->setMinDim(smallMinSize); - //pressedPanel->setMinDim(pressedMinSize); + LLLayoutStack* inv_stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); + LLLayoutStack* inout_stack = getChild<LLLayoutStack>(INBOX_OUTBOX_LAYOUT_STACK_NAME); + LLLayoutPanel* inout_panel = getChild<LLLayoutPanel>(INBOX_OUTBOX_LAYOUT_PANEL_NAME); + + // Enable user_resize on main inventory panel only when a marketplace box is expanded + inv_stack->setPanelUserResize(MAIN_INVENTORY_LAYOUT_PANEL_NAME, expand); + inv_stack->collapsePanel(inout_panel, !expand); + // Collapse other marketplace panel if it is expanded if (expand && otherExpanded) { // Reshape pressedPanel to the otherPanel's height so we preserve the marketplace panel size pressedPanel->reshape(pressedPanel->getRect().getWidth(), otherPanel->getRect().getHeight()); - stack->collapsePanel(otherPanel, true); + inout_stack->collapsePanel(otherPanel, true); otherButton->setToggleState(false); } + else + { + // NOTE: This is an attempt to reshape the inventory panel to the proper size but it doesn't seem to propagate + // properly to the child panels. - stack->collapsePanel(pressedPanel, !expand); + S32 new_height = inout_panel->getRect().getHeight(); - // Enable user_resize on main inventory panel only when a marketplace box is expanded - stack->setPanelUserResize(MAIN_INVENTORY_LAYOUT_PANEL_NAME, expand); + if (otherPanel->getVisible()) + { + new_height -= otherPanel->getMinDim(); + } + + pressedPanel->reshape(pressedPanel->getRect().getWidth(), new_height); + } + + // Expand/collapse the indicated panel + inout_stack->collapsePanel(pressedPanel, !expand); return expand; } void LLSidepanelInventory::onToggleInboxBtn() { - LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); - LLButton* pressedButton = getChild<LLButton>(INBOX_BUTTON_NAME); - LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); - LLButton* otherButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); - LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); + LLButton* inboxButton = getChild<LLButton>(INBOX_BUTTON_NAME); + LLLayoutPanel* inboxPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + LLButton* outboxButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); + LLLayoutPanel* outboxPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); - bool inboxExpanded = manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel); + const bool inbox_expanded = manageInboxOutboxPanels(inboxButton, inboxPanel, outboxButton, outboxPanel); - if (inboxExpanded) + if (inbox_expanded && inboxPanel->isInVisibleChain()) { - // Save current time as a setting for future new-ness tests - gSavedSettings.setString(INBOX_EXPAND_TIME_SETTING, LLDate::now().asString()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); } } void LLSidepanelInventory::onToggleOutboxBtn() { - LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); - LLButton* pressedButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); - LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); - LLButton* otherButton = getChild<LLButton>(INBOX_BUTTON_NAME); - LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + LLButton* inboxButton = getChild<LLButton>(INBOX_BUTTON_NAME); + LLLayoutPanel* inboxPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + LLButton* outboxButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); + LLLayoutPanel* outboxPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); - manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel); + manageInboxOutboxPanels(outboxButton, outboxPanel, inboxButton, inboxPanel); } void LLSidepanelInventory::onOpen(const LLSD& key) { LLFirstUse::newInventory(false); +#if AUTO_EXPAND_INBOX // Expand the inbox if we have fresh items LLPanelMarketplaceInbox * inbox = findChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL); if (inbox && (inbox->getFreshItemCount() > 0)) @@ -489,6 +583,12 @@ void LLSidepanelInventory::onOpen(const LLSD& key) getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true); onToggleInboxBtn(); } +#else + if (mInboxEnabled && getChild<LLButton>(INBOX_BUTTON_NAME)->getToggleState()) + { + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + } +#endif if(key.size() == 0) return; @@ -535,14 +635,12 @@ void LLSidepanelInventory::onShopButtonClicked() void LLSidepanelInventory::performActionOnSelection(const std::string &action) { - LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory"); - LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); + LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); if (!current_item) { - LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox"); - if (inbox) + if (mInventoryPanelInbox) { - current_item = inbox->getRootFolder()->getCurSelectedItem(); + current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem(); } if (!current_item) @@ -551,7 +649,7 @@ void LLSidepanelInventory::performActionOnSelection(const std::string &action) } } - current_item->getListener()->performAction(panel_main_inventory->getActivePanel()->getModel(), action); + current_item->getListener()->performAction(mPanelMainInventory->getActivePanel()->getModel(), action); } void LLSidepanelInventory::onWearButtonClicked() @@ -642,6 +740,77 @@ void LLSidepanelInventory::showInventoryPanel() updateVerbs(); } +void LLSidepanelInventory::updateOutboxUserStatus() +{ + const bool isMerchant = (gSavedSettings.getString("InventoryMarketplaceUserStatus") == "merchant"); + const bool hasOutbox = !gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false, false).isNull(); + + LLView * outbox_placeholder = getChild<LLView>("outbox_inventory_placeholder_panel"); + LLView * outbox_placeholder_parent = outbox_placeholder->getParent(); + + LLTextBox * outbox_title_box = outbox_placeholder->getChild<LLTextBox>("outbox_inventory_placeholder_title"); + LLTextBox * outbox_text_box = outbox_placeholder->getChild<LLTextBox>("outbox_inventory_placeholder_text"); + + std::string outbox_text; + std::string outbox_title; + std::string outbox_tooltip; + + if (isMerchant) + { + if (hasOutbox) + { + outbox_text = LLTrans::getString("InventoryOutboxNoItems"); + outbox_title = LLTrans::getString("InventoryOutboxNoItemsTitle"); + outbox_tooltip = LLTrans::getString("InventoryOutboxNoItemsTooltip"); + } + else + { + outbox_text = LLTrans::getString("InventoryOutboxCreationError"); + outbox_title = LLTrans::getString("InventoryOutboxCreationErrorTitle"); + outbox_tooltip = LLTrans::getString("InventoryOutboxCreationErrorTooltip"); + } + } + else + { + // + // The string to become a merchant contains 3 URL's which need the domain name patched in. + // + + std::string domain = "secondlife.com"; + + if (!LLGridManager::getInstance()->isInProductionGrid()) + { + std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); + domain = llformat("%s.lindenlab.com", utf8str_tolower(gridLabel).c_str()); + } + + LLStringUtil::format_map_t domain_arg; + domain_arg["[DOMAIN_NAME]"] = domain; + + std::string marketplace_url = LLTrans::getString("MarketplaceURL", domain_arg); + std::string marketplace_url_create = LLTrans::getString("MarketplaceURL_CreateStore", domain_arg); + std::string marketplace_url_info = LLTrans::getString("MarketplaceURL_LearnMore", domain_arg); + + LLStringUtil::format_map_t args1, args2, args3; + args1["[MARKETPLACE_URL]"] = marketplace_url; + args2["[LEARN_MORE_URL]"] = marketplace_url_info; + args3["[CREATE_STORE_URL]"] = marketplace_url_create; + + // NOTE: This is dumb, ridiculous and very finicky. The order of these is very important + // to have these three string substitutions work properly. + outbox_text = LLTrans::getString("InventoryOutboxNotMerchant", args1); + LLStringUtil::format(outbox_text, args2); + LLStringUtil::format(outbox_text, args3); + + outbox_title = LLTrans::getString("InventoryOutboxNotMerchantTitle"); + outbox_tooltip = LLTrans::getString("InventoryOutboxNotMerchantTooltip"); + } + + outbox_text_box->setValue(outbox_text); + outbox_title_box->setValue(outbox_title); + outbox_placeholder_parent->setToolTip(outbox_tooltip); +} + void LLSidepanelInventory::updateVerbs() { mInfoBtn->setEnabled(FALSE); @@ -693,19 +862,16 @@ void LLSidepanelInventory::updateVerbs() bool LLSidepanelInventory::canShare() { - LLPanelMainInventory* panel_main_inventory = - mInventoryPanel->findChild<LLPanelMainInventory>("panel_main_inventory"); - - LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox"); + LLInventoryPanel* inbox = mInventoryPanelInbox; // Avoid flicker in the Recent tab while inventory is being loaded. if ( (!inbox || inbox->getRootFolder()->getSelectionList().empty()) - && (panel_main_inventory && !panel_main_inventory->getActivePanel()->getRootFolder()->hasVisibleChildren()) ) + && (mPanelMainInventory && !mPanelMainInventory->getActivePanel()->getRootFolder()->hasVisibleChildren()) ) { return false; } - return ( (panel_main_inventory ? LLAvatarActions::canShareSelectedItems(panel_main_inventory->getActivePanel()) : false) + return ( (mPanelMainInventory ? LLAvatarActions::canShareSelectedItems(mPanelMainInventory->getActivePanel()) : false) || (inbox ? LLAvatarActions::canShareSelectedItems(inbox) : false) ); } @@ -730,14 +896,13 @@ bool LLSidepanelInventory::canWearSelected() LLInventoryItem *LLSidepanelInventory::getSelectedItem() { - LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory"); - LLFolderViewItem* current_item = panel_main_inventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); + LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem(); + if (!current_item) { - LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox"); - if (inbox) + if (mInventoryPanelInbox) { - current_item = inbox->getRootFolder()->getCurSelectedItem(); + current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem(); } if (!current_item) @@ -754,14 +919,20 @@ U32 LLSidepanelInventory::getSelectedCount() { int count = 0; - LLPanelMainInventory *panel_main_inventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory"); - std::set<LLUUID> selection_list = panel_main_inventory->getActivePanel()->getRootFolder()->getSelectionList(); + std::set<LLUUID> selection_list = mPanelMainInventory->getActivePanel()->getRootFolder()->getSelectionList(); count += selection_list.size(); - LLInventoryPanel* inbox = findChild<LLInventoryPanel>("inventory_inbox"); - if (inbox) + if ((count == 0) && mInboxEnabled && (mInventoryPanelInbox != NULL)) { - selection_list = inbox->getRootFolder()->getSelectionList(); + selection_list = mInventoryPanelInbox->getRootFolder()->getSelectionList(); + + count += selection_list.size(); + } + + if ((count == 0) && mOutboxEnabled && (mInventoryPanelOutbox != NULL)) + { + selection_list = mInventoryPanelOutbox->getRootFolder()->getSelectionList(); + count += selection_list.size(); } @@ -785,3 +956,45 @@ BOOL LLSidepanelInventory::isMainInventoryPanelActive() const { return mInventoryPanel->getVisible(); } + +void LLSidepanelInventory::clearSelections(bool clearMain, bool clearInbox, bool clearOutbox) +{ + if (clearMain) + { + LLInventoryPanel * inv_panel = getActivePanel(); + + if (inv_panel) + { + inv_panel->clearSelection(); + } + } + + if (clearInbox && mInboxEnabled && (mInventoryPanelInbox != NULL)) + { + mInventoryPanelInbox->clearSelection(); + } + + if (clearOutbox && mOutboxEnabled && (mInventoryPanelOutbox != NULL)) + { + mInventoryPanelOutbox->clearSelection(); + } + + updateVerbs(); +} + +std::set<LLUUID> LLSidepanelInventory::getInboxOrOutboxSelectionList() +{ + std::set<LLUUID> inventory_selected_uuids; + + if (mInboxEnabled && (mInventoryPanelInbox != NULL)) + { + inventory_selected_uuids = mInventoryPanelInbox->getRootFolder()->getSelectionList(); + } + + if (inventory_selected_uuids.empty() && mOutboxEnabled && (mInventoryPanelOutbox != NULL)) + { + inventory_selected_uuids = mInventoryPanelOutbox->getRootFolder()->getSelectionList(); + } + + return inventory_selected_uuids; +} |