PageRenderTime 186ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llsidepanelinventory.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 715 lines | 506 code | 127 blank | 82 comment | 73 complexity | 4adb86ac2f23d98c3460d661bfc1b4de MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file LLSidepanelInventory.cpp
  3. * @brief Side Bar "Inventory" panel
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llsidepanelinventory.h"
  28. #include "llagent.h"
  29. #include "llappearancemgr.h"
  30. #include "llappviewer.h"
  31. #include "llavataractions.h"
  32. #include "llbutton.h"
  33. #include "lldate.h"
  34. #include "llfirstuse.h"
  35. #include "llfloatersidepanelcontainer.h"
  36. #include "llfoldertype.h"
  37. #include "llhttpclient.h"
  38. #include "llinventorybridge.h"
  39. #include "llinventoryfunctions.h"
  40. #include "llinventorymodel.h"
  41. #include "llinventorymodelbackgroundfetch.h"
  42. #include "llinventoryobserver.h"
  43. #include "llinventorypanel.h"
  44. #include "lllayoutstack.h"
  45. #include "lloutfitobserver.h"
  46. #include "llpanelmaininventory.h"
  47. #include "llpanelmarketplaceinbox.h"
  48. #include "llselectmgr.h"
  49. #include "llsidepaneliteminfo.h"
  50. #include "llsidepaneltaskinfo.h"
  51. #include "llstring.h"
  52. #include "lltabcontainer.h"
  53. #include "lltextbox.h"
  54. #include "lltrans.h"
  55. #include "llviewermedia.h"
  56. #include "llviewernetwork.h"
  57. #include "llweb.h"
  58. static LLRegisterPanelClassWrapper<LLSidepanelInventory> t_inventory("sidepanel_inventory");
  59. //
  60. // Constants
  61. //
  62. // No longer want the inbox panel to auto-expand since it creates issues with the "new" tag time stamp
  63. #define AUTO_EXPAND_INBOX 0
  64. static const char * const INBOX_BUTTON_NAME = "inbox_btn";
  65. static const char * const INBOX_LAYOUT_PANEL_NAME = "inbox_layout_panel";
  66. static const char * const MAIN_INVENTORY_LAYOUT_PANEL_NAME = "main_inventory_layout_panel";
  67. static const char * const INVENTORY_LAYOUT_STACK_NAME = "inventory_layout_stack";
  68. static const char * const MARKETPLACE_INBOX_PANEL = "marketplace_inbox";
  69. //
  70. // Helpers
  71. //
  72. class LLInboxAddedObserver : public LLInventoryCategoryAddedObserver
  73. {
  74. public:
  75. LLInboxAddedObserver(LLSidepanelInventory * sidepanelInventory)
  76. : LLInventoryCategoryAddedObserver()
  77. , mSidepanelInventory(sidepanelInventory)
  78. {
  79. }
  80. void done()
  81. {
  82. for (cat_vec_t::iterator it = mAddedCategories.begin(); it != mAddedCategories.end(); ++it)
  83. {
  84. LLViewerInventoryCategory* added_category = *it;
  85. LLFolderType::EType added_category_type = added_category->getPreferredType();
  86. switch (added_category_type)
  87. {
  88. case LLFolderType::FT_INBOX:
  89. mSidepanelInventory->enableInbox(true);
  90. mSidepanelInventory->observeInboxModifications(added_category->getUUID());
  91. break;
  92. default:
  93. break;
  94. }
  95. }
  96. }
  97. private:
  98. LLSidepanelInventory * mSidepanelInventory;
  99. };
  100. //
  101. // Implementation
  102. //
  103. LLSidepanelInventory::LLSidepanelInventory()
  104. : LLPanel()
  105. , mItemPanel(NULL)
  106. , mInventoryPanelInbox(NULL)
  107. , mPanelMainInventory(NULL)
  108. , mInboxEnabled(false)
  109. , mCategoriesObserver(NULL)
  110. , mInboxAddedObserver(NULL)
  111. {
  112. //buildFromFile( "panel_inventory.xml"); // Called from LLRegisterPanelClass::defaultPanelClassBuilder()
  113. }
  114. LLSidepanelInventory::~LLSidepanelInventory()
  115. {
  116. if (mCategoriesObserver && gInventory.containsObserver(mCategoriesObserver))
  117. {
  118. gInventory.removeObserver(mCategoriesObserver);
  119. }
  120. delete mCategoriesObserver;
  121. if (mInboxAddedObserver && gInventory.containsObserver(mInboxAddedObserver))
  122. {
  123. gInventory.removeObserver(mInboxAddedObserver);
  124. }
  125. delete mInboxAddedObserver;
  126. }
  127. void handleInventoryDisplayInboxChanged()
  128. {
  129. LLSidepanelInventory* sidepanel_inventory = LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
  130. if (sidepanel_inventory)
  131. {
  132. sidepanel_inventory->enableInbox(gSavedSettings.getBOOL("InventoryDisplayInbox"));
  133. }
  134. }
  135. BOOL LLSidepanelInventory::postBuild()
  136. {
  137. // UI elements from inventory panel
  138. {
  139. mInventoryPanel = getChild<LLPanel>("sidepanel__inventory_panel");
  140. mInfoBtn = mInventoryPanel->getChild<LLButton>("info_btn");
  141. mInfoBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onInfoButtonClicked, this));
  142. mShareBtn = mInventoryPanel->getChild<LLButton>("share_btn");
  143. mShareBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onShareButtonClicked, this));
  144. mShopBtn = mInventoryPanel->getChild<LLButton>("shop_btn");
  145. mShopBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onShopButtonClicked, this));
  146. mWearBtn = mInventoryPanel->getChild<LLButton>("wear_btn");
  147. mWearBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onWearButtonClicked, this));
  148. mPlayBtn = mInventoryPanel->getChild<LLButton>("play_btn");
  149. mPlayBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onPlayButtonClicked, this));
  150. mTeleportBtn = mInventoryPanel->getChild<LLButton>("teleport_btn");
  151. mTeleportBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onTeleportButtonClicked, this));
  152. mOverflowBtn = mInventoryPanel->getChild<LLButton>("overflow_btn");
  153. mOverflowBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onOverflowButtonClicked, this));
  154. mPanelMainInventory = mInventoryPanel->getChild<LLPanelMainInventory>("panel_main_inventory");
  155. mPanelMainInventory->setSelectCallback(boost::bind(&LLSidepanelInventory::onSelectionChange, this, _1, _2));
  156. LLTabContainer* tabs = mPanelMainInventory->getChild<LLTabContainer>("inventory filter tabs");
  157. tabs->setCommitCallback(boost::bind(&LLSidepanelInventory::updateVerbs, this));
  158. /*
  159. EXT-4846 : "Can we suppress the "Landmarks" and "My Favorites" folder since they have their own Task Panel?"
  160. Deferring this until 2.1.
  161. LLInventoryPanel *my_inventory_panel = mPanelMainInventory->getChild<LLInventoryPanel>("All Items");
  162. my_inventory_panel->addHideFolderType(LLFolderType::FT_LANDMARK);
  163. my_inventory_panel->addHideFolderType(LLFolderType::FT_FAVORITE);
  164. */
  165. LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLSidepanelInventory::updateVerbs, this));
  166. }
  167. // UI elements from item panel
  168. {
  169. mItemPanel = getChild<LLSidepanelItemInfo>("sidepanel__item_panel");
  170. LLButton* back_btn = mItemPanel->getChild<LLButton>("back_btn");
  171. back_btn->setClickedCallback(boost::bind(&LLSidepanelInventory::onBackButtonClicked, this));
  172. }
  173. // UI elements from task panel
  174. {
  175. mTaskPanel = findChild<LLSidepanelTaskInfo>("sidepanel__task_panel");
  176. if (mTaskPanel)
  177. {
  178. LLButton* back_btn = mTaskPanel->getChild<LLButton>("back_btn");
  179. back_btn->setClickedCallback(boost::bind(&LLSidepanelInventory::onBackButtonClicked, this));
  180. }
  181. }
  182. // Received items inbox setup
  183. {
  184. LLLayoutStack* inv_stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME);
  185. // Collapse inbox panel
  186. inv_stack->collapsePanel(getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME), true);
  187. // Set up button states and callbacks
  188. LLButton * inbox_button = getChild<LLButton>(INBOX_BUTTON_NAME);
  189. inbox_button->setToggleState(false);
  190. inbox_button->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleInboxBtn, this));
  191. // Set the inbox visible based on debug settings (final setting comes from http request below)
  192. enableInbox(gSavedSettings.getBOOL("InventoryDisplayInbox"));
  193. // Trigger callback for after login so we can setup to track inbox changes after initial inventory load
  194. LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLSidepanelInventory::updateInbox, this));
  195. }
  196. gSavedSettings.getControl("InventoryDisplayInbox")->getCommitSignal()->connect(boost::bind(&handleInventoryDisplayInboxChanged));
  197. // Update the verbs buttons state.
  198. updateVerbs();
  199. return TRUE;
  200. }
  201. void LLSidepanelInventory::updateInbox()
  202. {
  203. //
  204. // Track inbox folder changes
  205. //
  206. const bool do_not_create_folder = false;
  207. const bool do_not_find_in_library = false;
  208. const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX, do_not_create_folder, do_not_find_in_library);
  209. // Set up observer to listen for creation of inbox if at least one of them doesn't exist
  210. if (inbox_id.isNull())
  211. {
  212. observeInboxCreation();
  213. }
  214. // Set up observer for inbox changes, if we have an inbox already
  215. else
  216. {
  217. // Enable the display of the inbox if it exists
  218. enableInbox(true);
  219. observeInboxModifications(inbox_id);
  220. }
  221. }
  222. void LLSidepanelInventory::observeInboxCreation()
  223. {
  224. //
  225. // Set up observer to track inbox folder creation
  226. //
  227. if (mInboxAddedObserver == NULL)
  228. {
  229. mInboxAddedObserver = new LLInboxAddedObserver(this);
  230. gInventory.addObserver(mInboxAddedObserver);
  231. }
  232. }
  233. void LLSidepanelInventory::observeInboxModifications(const LLUUID& inboxID)
  234. {
  235. //
  236. // Silently do nothing if we already have an inbox inventory panel set up
  237. // (this can happen multiple times on the initial session that creates the inbox)
  238. //
  239. if (mInventoryPanelInbox != NULL)
  240. {
  241. return;
  242. }
  243. //
  244. // Track inbox folder changes
  245. //
  246. if (inboxID.isNull())
  247. {
  248. llwarns << "Attempting to track modifications to non-existent inbox" << llendl;
  249. return;
  250. }
  251. if (mCategoriesObserver == NULL)
  252. {
  253. mCategoriesObserver = new LLInventoryCategoriesObserver();
  254. gInventory.addObserver(mCategoriesObserver);
  255. }
  256. mCategoriesObserver->addCategory(inboxID, boost::bind(&LLSidepanelInventory::onInboxChanged, this, inboxID));
  257. //
  258. // Trigger a load for the entire contents of the Inbox
  259. //
  260. LLInventoryModelBackgroundFetch::instance().start(inboxID);
  261. //
  262. // Set up the inbox inventory view
  263. //
  264. LLPanelMarketplaceInbox * inbox = getChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL);
  265. mInventoryPanelInbox = inbox->setupInventoryPanel();
  266. }
  267. void LLSidepanelInventory::enableInbox(bool enabled)
  268. {
  269. mInboxEnabled = enabled;
  270. LLLayoutPanel * inbox_layout_panel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME);
  271. inbox_layout_panel->setVisible(enabled);
  272. }
  273. void LLSidepanelInventory::openInbox()
  274. {
  275. if (mInboxEnabled)
  276. {
  277. getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true);
  278. onToggleInboxBtn();
  279. }
  280. }
  281. void LLSidepanelInventory::onInboxChanged(const LLUUID& inbox_id)
  282. {
  283. // Trigger a load of the entire inbox so we always know the contents and their creation dates for sorting
  284. LLInventoryModelBackgroundFetch::instance().start(inbox_id);
  285. #if AUTO_EXPAND_INBOX
  286. // Expand the inbox since we have fresh items
  287. if (mInboxEnabled)
  288. {
  289. getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true);
  290. onToggleInboxBtn();
  291. }
  292. #endif
  293. }
  294. void LLSidepanelInventory::onToggleInboxBtn()
  295. {
  296. LLButton* inboxButton = getChild<LLButton>(INBOX_BUTTON_NAME);
  297. LLLayoutPanel* inboxPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME);
  298. LLLayoutStack* inv_stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME);
  299. const bool inbox_expanded = inboxButton->getToggleState();
  300. // Expand/collapse the indicated panel
  301. inv_stack->collapsePanel(inboxPanel, !inbox_expanded);
  302. if (inbox_expanded && inboxPanel->isInVisibleChain())
  303. {
  304. gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected());
  305. }
  306. }
  307. void LLSidepanelInventory::onOpen(const LLSD& key)
  308. {
  309. LLFirstUse::newInventory(false);
  310. #if AUTO_EXPAND_INBOX
  311. // Expand the inbox if we have fresh items
  312. LLPanelMarketplaceInbox * inbox = findChild<LLPanelMarketplaceInbox>(MARKETPLACE_INBOX_PANEL);
  313. if (inbox && (inbox->getFreshItemCount() > 0))
  314. {
  315. getChild<LLButton>(INBOX_BUTTON_NAME)->setToggleState(true);
  316. onToggleInboxBtn();
  317. }
  318. #else
  319. if (mInboxEnabled && getChild<LLButton>(INBOX_BUTTON_NAME)->getToggleState())
  320. {
  321. gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected());
  322. }
  323. #endif
  324. if(key.size() == 0)
  325. return;
  326. mItemPanel->reset();
  327. if (key.has("id"))
  328. {
  329. mItemPanel->setItemID(key["id"].asUUID());
  330. if (key.has("object"))
  331. {
  332. mItemPanel->setObjectID(key["object"].asUUID());
  333. }
  334. showItemInfoPanel();
  335. }
  336. if (key.has("task"))
  337. {
  338. if (mTaskPanel)
  339. mTaskPanel->setObjectSelection(LLSelectMgr::getInstance()->getSelection());
  340. showTaskInfoPanel();
  341. }
  342. }
  343. void LLSidepanelInventory::onInfoButtonClicked()
  344. {
  345. LLInventoryItem *item = getSelectedItem();
  346. if (item)
  347. {
  348. mItemPanel->reset();
  349. mItemPanel->setItemID(item->getUUID());
  350. showItemInfoPanel();
  351. }
  352. }
  353. void LLSidepanelInventory::onShareButtonClicked()
  354. {
  355. LLAvatarActions::shareWithAvatars();
  356. }
  357. void LLSidepanelInventory::onShopButtonClicked()
  358. {
  359. LLWeb::loadURLExternal(gSavedSettings.getString("MarketplaceURL"));
  360. }
  361. void LLSidepanelInventory::performActionOnSelection(const std::string &action)
  362. {
  363. LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
  364. if (!current_item)
  365. {
  366. if (mInventoryPanelInbox)
  367. {
  368. current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem();
  369. }
  370. if (!current_item)
  371. {
  372. return;
  373. }
  374. }
  375. current_item->getListener()->performAction(mPanelMainInventory->getActivePanel()->getModel(), action);
  376. }
  377. void LLSidepanelInventory::onWearButtonClicked()
  378. {
  379. // Get selected items set.
  380. const std::set<LLUUID> selected_uuids_set = LLAvatarActions::getInventorySelectedUUIDs();
  381. if (selected_uuids_set.empty()) return; // nothing selected
  382. // Convert the set to a vector.
  383. uuid_vec_t selected_uuids_vec;
  384. for (std::set<LLUUID>::const_iterator it = selected_uuids_set.begin(); it != selected_uuids_set.end(); ++it)
  385. {
  386. selected_uuids_vec.push_back(*it);
  387. }
  388. // Wear all selected items.
  389. wear_multiple(selected_uuids_vec, true);
  390. }
  391. void LLSidepanelInventory::onPlayButtonClicked()
  392. {
  393. const LLInventoryItem *item = getSelectedItem();
  394. if (!item)
  395. {
  396. return;
  397. }
  398. switch(item->getInventoryType())
  399. {
  400. case LLInventoryType::IT_GESTURE:
  401. performActionOnSelection("play");
  402. break;
  403. default:
  404. performActionOnSelection("open");
  405. break;
  406. }
  407. }
  408. void LLSidepanelInventory::onTeleportButtonClicked()
  409. {
  410. performActionOnSelection("teleport");
  411. }
  412. void LLSidepanelInventory::onOverflowButtonClicked()
  413. {
  414. }
  415. void LLSidepanelInventory::onBackButtonClicked()
  416. {
  417. showInventoryPanel();
  418. }
  419. void LLSidepanelInventory::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action)
  420. {
  421. updateVerbs();
  422. }
  423. void LLSidepanelInventory::showItemInfoPanel()
  424. {
  425. mItemPanel->setVisible(TRUE);
  426. if (mTaskPanel)
  427. mTaskPanel->setVisible(FALSE);
  428. mInventoryPanel->setVisible(FALSE);
  429. mItemPanel->dirty();
  430. mItemPanel->setIsEditing(FALSE);
  431. }
  432. void LLSidepanelInventory::showTaskInfoPanel()
  433. {
  434. mItemPanel->setVisible(FALSE);
  435. mInventoryPanel->setVisible(FALSE);
  436. if (mTaskPanel)
  437. {
  438. mTaskPanel->setVisible(TRUE);
  439. mTaskPanel->dirty();
  440. mTaskPanel->setIsEditing(FALSE);
  441. }
  442. }
  443. void LLSidepanelInventory::showInventoryPanel()
  444. {
  445. mItemPanel->setVisible(FALSE);
  446. if (mTaskPanel)
  447. mTaskPanel->setVisible(FALSE);
  448. mInventoryPanel->setVisible(TRUE);
  449. updateVerbs();
  450. }
  451. void LLSidepanelInventory::updateVerbs()
  452. {
  453. mInfoBtn->setEnabled(FALSE);
  454. mShareBtn->setEnabled(FALSE);
  455. mWearBtn->setVisible(FALSE);
  456. mWearBtn->setEnabled(FALSE);
  457. mPlayBtn->setVisible(FALSE);
  458. mPlayBtn->setEnabled(FALSE);
  459. mTeleportBtn->setVisible(FALSE);
  460. mTeleportBtn->setEnabled(FALSE);
  461. mShopBtn->setVisible(TRUE);
  462. mShareBtn->setEnabled(canShare());
  463. const LLInventoryItem *item = getSelectedItem();
  464. if (!item)
  465. return;
  466. bool is_single_selection = getSelectedCount() == 1;
  467. mInfoBtn->setEnabled(is_single_selection);
  468. switch(item->getInventoryType())
  469. {
  470. case LLInventoryType::IT_WEARABLE:
  471. case LLInventoryType::IT_OBJECT:
  472. case LLInventoryType::IT_ATTACHMENT:
  473. mWearBtn->setVisible(TRUE);
  474. mWearBtn->setEnabled(canWearSelected());
  475. mShopBtn->setVisible(FALSE);
  476. break;
  477. case LLInventoryType::IT_SOUND:
  478. case LLInventoryType::IT_GESTURE:
  479. case LLInventoryType::IT_ANIMATION:
  480. mPlayBtn->setVisible(TRUE);
  481. mPlayBtn->setEnabled(TRUE);
  482. mShopBtn->setVisible(FALSE);
  483. break;
  484. case LLInventoryType::IT_LANDMARK:
  485. mTeleportBtn->setVisible(TRUE);
  486. mTeleportBtn->setEnabled(TRUE);
  487. mShopBtn->setVisible(FALSE);
  488. break;
  489. default:
  490. break;
  491. }
  492. }
  493. bool LLSidepanelInventory::canShare()
  494. {
  495. LLInventoryPanel* inbox = mInventoryPanelInbox;
  496. // Avoid flicker in the Recent tab while inventory is being loaded.
  497. if ( (!inbox || inbox->getRootFolder()->getSelectionList().empty())
  498. && (mPanelMainInventory && !mPanelMainInventory->getActivePanel()->getRootFolder()->hasVisibleChildren()) )
  499. {
  500. return false;
  501. }
  502. return ( (mPanelMainInventory ? LLAvatarActions::canShareSelectedItems(mPanelMainInventory->getActivePanel()) : false)
  503. || (inbox ? LLAvatarActions::canShareSelectedItems(inbox) : false) );
  504. }
  505. bool LLSidepanelInventory::canWearSelected()
  506. {
  507. std::set<LLUUID> selected_uuids = LLAvatarActions::getInventorySelectedUUIDs();
  508. if (selected_uuids.empty())
  509. return false;
  510. for (std::set<LLUUID>::const_iterator it = selected_uuids.begin();
  511. it != selected_uuids.end();
  512. ++it)
  513. {
  514. if (!get_can_item_be_worn(*it)) return false;
  515. }
  516. return true;
  517. }
  518. LLInventoryItem *LLSidepanelInventory::getSelectedItem()
  519. {
  520. LLFolderViewItem* current_item = mPanelMainInventory->getActivePanel()->getRootFolder()->getCurSelectedItem();
  521. if (!current_item)
  522. {
  523. if (mInventoryPanelInbox)
  524. {
  525. current_item = mInventoryPanelInbox->getRootFolder()->getCurSelectedItem();
  526. }
  527. if (!current_item)
  528. {
  529. return NULL;
  530. }
  531. }
  532. const LLUUID &item_id = current_item->getListener()->getUUID();
  533. LLInventoryItem *item = gInventory.getItem(item_id);
  534. return item;
  535. }
  536. U32 LLSidepanelInventory::getSelectedCount()
  537. {
  538. int count = 0;
  539. std::set<LLUUID> selection_list = mPanelMainInventory->getActivePanel()->getRootFolder()->getSelectionList();
  540. count += selection_list.size();
  541. if ((count == 0) && mInboxEnabled && (mInventoryPanelInbox != NULL))
  542. {
  543. selection_list = mInventoryPanelInbox->getRootFolder()->getSelectionList();
  544. count += selection_list.size();
  545. }
  546. return count;
  547. }
  548. LLInventoryPanel *LLSidepanelInventory::getActivePanel()
  549. {
  550. if (!getVisible())
  551. {
  552. return NULL;
  553. }
  554. if (mInventoryPanel->getVisible())
  555. {
  556. return mPanelMainInventory->getActivePanel();
  557. }
  558. return NULL;
  559. }
  560. BOOL LLSidepanelInventory::isMainInventoryPanelActive() const
  561. {
  562. return mInventoryPanel->getVisible();
  563. }
  564. void LLSidepanelInventory::clearSelections(bool clearMain, bool clearInbox)
  565. {
  566. if (clearMain)
  567. {
  568. LLInventoryPanel * inv_panel = getActivePanel();
  569. if (inv_panel)
  570. {
  571. inv_panel->clearSelection();
  572. }
  573. }
  574. if (clearInbox && mInboxEnabled && (mInventoryPanelInbox != NULL))
  575. {
  576. mInventoryPanelInbox->clearSelection();
  577. }
  578. updateVerbs();
  579. }
  580. std::set<LLUUID> LLSidepanelInventory::getInboxSelectionList()
  581. {
  582. std::set<LLUUID> inventory_selected_uuids;
  583. if (mInboxEnabled && (mInventoryPanelInbox != NULL))
  584. {
  585. inventory_selected_uuids = mInventoryPanelInbox->getRootFolder()->getSelectionList();
  586. }
  587. return inventory_selected_uuids;
  588. }