PageRenderTime 59ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpanelmaininventory.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1262 lines | 1008 code | 164 blank | 90 comment | 182 complexity | 816455192ab657fc94eebb138044f847 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpanelmaininventory.cpp
  3. * @brief Implementation of llpanelmaininventory.
  4. *
  5. * $LicenseInfo:firstyear=2001&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 "llpanelmaininventory.h"
  28. #include "llagent.h"
  29. #include "llagentcamera.h"
  30. #include "llavataractions.h"
  31. #include "lldndbutton.h"
  32. #include "lleconomy.h"
  33. #include "llfilepicker.h"
  34. #include "llfloaterinventory.h"
  35. #include "llinventorybridge.h"
  36. #include "llinventoryfunctions.h"
  37. #include "llinventorymodelbackgroundfetch.h"
  38. #include "llinventorypanel.h"
  39. #include "llfiltereditor.h"
  40. #include "llfloatersidepanelcontainer.h"
  41. #include "llfloaterreg.h"
  42. #include "llmenubutton.h"
  43. #include "lloutfitobserver.h"
  44. #include "llpreviewtexture.h"
  45. #include "llresmgr.h"
  46. #include "llscrollcontainer.h"
  47. #include "llsdserialize.h"
  48. #include "llspinctrl.h"
  49. #include "lltoggleablemenu.h"
  50. #include "lltooldraganddrop.h"
  51. #include "llviewermenu.h"
  52. #include "llviewertexturelist.h"
  53. #include "llsidepanelinventory.h"
  54. const std::string FILTERS_FILENAME("filters.xml");
  55. static LLRegisterPanelClassWrapper<LLPanelMainInventory> t_inventory("panel_main_inventory");
  56. void on_file_loaded_for_save(BOOL success,
  57. LLViewerFetchedTexture *src_vi,
  58. LLImageRaw* src,
  59. LLImageRaw* aux_src,
  60. S32 discard_level,
  61. BOOL final,
  62. void* userdata);
  63. ///----------------------------------------------------------------------------
  64. /// LLFloaterInventoryFinder
  65. ///----------------------------------------------------------------------------
  66. class LLFloaterInventoryFinder : public LLFloater
  67. {
  68. public:
  69. LLFloaterInventoryFinder( LLPanelMainInventory* inventory_view);
  70. virtual void draw();
  71. /*virtual*/ BOOL postBuild();
  72. void changeFilter(LLInventoryFilter* filter);
  73. void updateElementsFromFilter();
  74. BOOL getCheckShowEmpty();
  75. BOOL getCheckSinceLogoff();
  76. static void onTimeAgo(LLUICtrl*, void *);
  77. static void onCloseBtn(void* user_data);
  78. static void selectAllTypes(void* user_data);
  79. static void selectNoTypes(void* user_data);
  80. private:
  81. LLPanelMainInventory* mPanelMainInventory;
  82. LLSpinCtrl* mSpinSinceDays;
  83. LLSpinCtrl* mSpinSinceHours;
  84. LLInventoryFilter* mFilter;
  85. };
  86. ///----------------------------------------------------------------------------
  87. /// LLPanelMainInventory
  88. ///----------------------------------------------------------------------------
  89. LLPanelMainInventory::LLPanelMainInventory(const LLPanel::Params& p)
  90. : LLPanel(p),
  91. mActivePanel(NULL),
  92. mSavedFolderState(NULL),
  93. mFilterText(""),
  94. mMenuGearDefault(NULL),
  95. mMenuAdd(NULL),
  96. mNeedUploadCost(true)
  97. {
  98. LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_INIT);
  99. // Menu Callbacks (non contex menus)
  100. mCommitCallbackRegistrar.add("Inventory.DoToSelected", boost::bind(&LLPanelMainInventory::doToSelected, this, _2));
  101. mCommitCallbackRegistrar.add("Inventory.CloseAllFolders", boost::bind(&LLPanelMainInventory::closeAllFolders, this));
  102. mCommitCallbackRegistrar.add("Inventory.EmptyTrash", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyTrash", LLFolderType::FT_TRASH));
  103. mCommitCallbackRegistrar.add("Inventory.EmptyLostAndFound", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyLostAndFound", LLFolderType::FT_LOST_AND_FOUND));
  104. mCommitCallbackRegistrar.add("Inventory.DoCreate", boost::bind(&LLPanelMainInventory::doCreate, this, _2));
  105. //mCommitCallbackRegistrar.add("Inventory.NewWindow", boost::bind(&LLPanelMainInventory::newWindow, this));
  106. mCommitCallbackRegistrar.add("Inventory.ShowFilters", boost::bind(&LLPanelMainInventory::toggleFindOptions, this));
  107. mCommitCallbackRegistrar.add("Inventory.ResetFilters", boost::bind(&LLPanelMainInventory::resetFilters, this));
  108. mCommitCallbackRegistrar.add("Inventory.SetSortBy", boost::bind(&LLPanelMainInventory::setSortBy, this, _2));
  109. mCommitCallbackRegistrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars));
  110. mSavedFolderState = new LLSaveFolderState();
  111. mSavedFolderState->setApply(FALSE);
  112. }
  113. BOOL LLPanelMainInventory::postBuild()
  114. {
  115. gInventory.addObserver(this);
  116. mFilterTabs = getChild<LLTabContainer>("inventory filter tabs");
  117. mFilterTabs->setCommitCallback(boost::bind(&LLPanelMainInventory::onFilterSelected, this));
  118. //panel->getFilter()->markDefault();
  119. // Set up the default inv. panel/filter settings.
  120. mActivePanel = getChild<LLInventoryPanel>("All Items");
  121. if (mActivePanel)
  122. {
  123. // "All Items" is the previous only view, so it gets the InventorySortOrder
  124. mActivePanel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER));
  125. mActivePanel->getFilter()->markDefault();
  126. mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
  127. mActivePanel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, mActivePanel, _1, _2));
  128. mResortActivePanel = true;
  129. }
  130. LLInventoryPanel* recent_items_panel = getChild<LLInventoryPanel>("Recent Items");
  131. if (recent_items_panel)
  132. {
  133. recent_items_panel->setSinceLogoff(TRUE);
  134. recent_items_panel->setSortOrder(LLInventoryFilter::SO_DATE);
  135. recent_items_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
  136. recent_items_panel->getFilter()->markDefault();
  137. recent_items_panel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, recent_items_panel, _1, _2));
  138. }
  139. // Now load the stored settings from disk, if available.
  140. std::ostringstream filterSaveName;
  141. filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME);
  142. llinfos << "LLPanelMainInventory::init: reading from " << filterSaveName.str() << llendl;
  143. llifstream file(filterSaveName.str());
  144. LLSD savedFilterState;
  145. if (file.is_open())
  146. {
  147. LLSDSerialize::fromXML(savedFilterState, file);
  148. file.close();
  149. // Load the persistent "Recent Items" settings.
  150. // Note that the "All Items" settings do not persist.
  151. if(recent_items_panel)
  152. {
  153. if(savedFilterState.has(recent_items_panel->getFilter()->getName()))
  154. {
  155. LLSD recent_items = savedFilterState.get(
  156. recent_items_panel->getFilter()->getName());
  157. recent_items_panel->getFilter()->fromLLSD(recent_items);
  158. }
  159. }
  160. }
  161. mFilterEditor = getChild<LLFilterEditor>("inventory search editor");
  162. if (mFilterEditor)
  163. {
  164. mFilterEditor->setCommitCallback(boost::bind(&LLPanelMainInventory::onFilterEdit, this, _2));
  165. }
  166. mGearMenuButton = getChild<LLMenuButton>("options_gear_btn");
  167. initListCommandsHandlers();
  168. // *TODO:Get the cost info from the server
  169. const std::string upload_cost("10");
  170. mMenuAdd->getChild<LLMenuItemGL>("Upload Image")->setLabelArg("[COST]", upload_cost);
  171. mMenuAdd->getChild<LLMenuItemGL>("Upload Sound")->setLabelArg("[COST]", upload_cost);
  172. mMenuAdd->getChild<LLMenuItemGL>("Upload Animation")->setLabelArg("[COST]", upload_cost);
  173. mMenuAdd->getChild<LLMenuItemGL>("Bulk Upload")->setLabelArg("[COST]", upload_cost);
  174. // Trigger callback for focus received so we can deselect items in inbox/outbox
  175. LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMainInventory::onFocusReceived, this));
  176. return TRUE;
  177. }
  178. // Destroys the object
  179. LLPanelMainInventory::~LLPanelMainInventory( void )
  180. {
  181. // Save the filters state.
  182. LLSD filterRoot;
  183. LLInventoryPanel* all_items_panel = getChild<LLInventoryPanel>("All Items");
  184. if (all_items_panel)
  185. {
  186. LLInventoryFilter* filter = all_items_panel->getFilter();
  187. if (filter)
  188. {
  189. LLSD filterState;
  190. filter->toLLSD(filterState);
  191. filterRoot[filter->getName()] = filterState;
  192. }
  193. }
  194. LLInventoryPanel* recent_items_panel = getChild<LLInventoryPanel>("Recent Items");
  195. if (recent_items_panel)
  196. {
  197. LLInventoryFilter* filter = recent_items_panel->getFilter();
  198. if (filter)
  199. {
  200. LLSD filterState;
  201. filter->toLLSD(filterState);
  202. filterRoot[filter->getName()] = filterState;
  203. }
  204. }
  205. std::ostringstream filterSaveName;
  206. filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME);
  207. llofstream filtersFile(filterSaveName.str());
  208. if(!LLSDSerialize::toPrettyXML(filterRoot, filtersFile))
  209. {
  210. llwarns << "Could not write to filters save file " << filterSaveName << llendl;
  211. }
  212. else
  213. filtersFile.close();
  214. gInventory.removeObserver(this);
  215. delete mSavedFolderState;
  216. }
  217. void LLPanelMainInventory::startSearch()
  218. {
  219. // this forces focus to line editor portion of search editor
  220. if (mFilterEditor)
  221. {
  222. mFilterEditor->focusFirstItem(TRUE);
  223. }
  224. }
  225. BOOL LLPanelMainInventory::handleKeyHere(KEY key, MASK mask)
  226. {
  227. LLFolderView* root_folder = mActivePanel ? mActivePanel->getRootFolder() : NULL;
  228. if (root_folder)
  229. {
  230. // first check for user accepting current search results
  231. if (mFilterEditor
  232. && mFilterEditor->hasFocus()
  233. && (key == KEY_RETURN
  234. || key == KEY_DOWN)
  235. && mask == MASK_NONE)
  236. {
  237. // move focus to inventory proper
  238. mActivePanel->setFocus(TRUE);
  239. root_folder->scrollToShowSelection();
  240. return TRUE;
  241. }
  242. if (mActivePanel->hasFocus() && key == KEY_UP)
  243. {
  244. startSearch();
  245. }
  246. }
  247. return LLPanel::handleKeyHere(key, mask);
  248. }
  249. //----------------------------------------------------------------------------
  250. // menu callbacks
  251. void LLPanelMainInventory::doToSelected(const LLSD& userdata)
  252. {
  253. getPanel()->getRootFolder()->doToSelected(&gInventory, userdata);
  254. }
  255. void LLPanelMainInventory::closeAllFolders()
  256. {
  257. getPanel()->getRootFolder()->closeAllFolders();
  258. }
  259. void LLPanelMainInventory::newWindow()
  260. {
  261. static S32 instance_num = 0;
  262. instance_num = (instance_num + 1) % S32_MAX;
  263. if (!gAgentCamera.cameraMouselook())
  264. {
  265. LLFloaterReg::showTypedInstance<LLFloaterSidePanelContainer>("inventory", LLSD(instance_num));
  266. }
  267. }
  268. void LLPanelMainInventory::doCreate(const LLSD& userdata)
  269. {
  270. menu_create_inventory_item(getPanel()->getRootFolder(), NULL, userdata);
  271. }
  272. void LLPanelMainInventory::resetFilters()
  273. {
  274. LLFloaterInventoryFinder *finder = getFinder();
  275. getActivePanel()->getFilter()->resetDefault();
  276. if (finder)
  277. {
  278. finder->updateElementsFromFilter();
  279. }
  280. setFilterTextFromFilter();
  281. }
  282. void LLPanelMainInventory::setSortBy(const LLSD& userdata)
  283. {
  284. U32 sort_order_mask = getActivePanel()->getSortOrder();
  285. std::string sort_type = userdata.asString();
  286. if (sort_type == "name")
  287. {
  288. sort_order_mask &= ~LLInventoryFilter::SO_DATE;
  289. }
  290. else if (sort_type == "date")
  291. {
  292. sort_order_mask |= LLInventoryFilter::SO_DATE;
  293. }
  294. else if (sort_type == "foldersalwaysbyname")
  295. {
  296. if ( sort_order_mask & LLInventoryFilter::SO_FOLDERS_BY_NAME )
  297. {
  298. sort_order_mask &= ~LLInventoryFilter::SO_FOLDERS_BY_NAME;
  299. }
  300. else
  301. {
  302. sort_order_mask |= LLInventoryFilter::SO_FOLDERS_BY_NAME;
  303. }
  304. }
  305. else if (sort_type == "systemfolderstotop")
  306. {
  307. if ( sort_order_mask & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP )
  308. {
  309. sort_order_mask &= ~LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP;
  310. }
  311. else
  312. {
  313. sort_order_mask |= LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP;
  314. }
  315. }
  316. getActivePanel()->setSortOrder(sort_order_mask);
  317. gSavedSettings.setU32("InventorySortOrder", sort_order_mask);
  318. }
  319. // static
  320. BOOL LLPanelMainInventory::filtersVisible(void* user_data)
  321. {
  322. LLPanelMainInventory* self = (LLPanelMainInventory*)user_data;
  323. if(!self) return FALSE;
  324. return self->getFinder() != NULL;
  325. }
  326. void LLPanelMainInventory::onClearSearch()
  327. {
  328. LLFloater *finder = getFinder();
  329. if (mActivePanel)
  330. {
  331. mActivePanel->setFilterSubString(LLStringUtil::null);
  332. mActivePanel->setFilterTypes(0xffffffff);
  333. mActivePanel->setFilterLinks(LLInventoryFilter::FILTERLINK_INCLUDE_LINKS);
  334. }
  335. if (finder)
  336. {
  337. LLFloaterInventoryFinder::selectAllTypes(finder);
  338. }
  339. // re-open folders that were initially open
  340. if (mActivePanel)
  341. {
  342. mSavedFolderState->setApply(TRUE);
  343. mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
  344. LLOpenFoldersWithSelection opener;
  345. mActivePanel->getRootFolder()->applyFunctorRecursively(opener);
  346. mActivePanel->getRootFolder()->scrollToShowSelection();
  347. }
  348. mFilterSubString = "";
  349. }
  350. void LLPanelMainInventory::onFilterEdit(const std::string& search_string )
  351. {
  352. if (search_string == "")
  353. {
  354. onClearSearch();
  355. }
  356. if (!mActivePanel)
  357. {
  358. return;
  359. }
  360. LLInventoryModelBackgroundFetch::instance().start();
  361. mFilterSubString = search_string;
  362. if (mActivePanel->getFilterSubString().empty() && mFilterSubString.empty())
  363. {
  364. // current filter and new filter empty, do nothing
  365. return;
  366. }
  367. // save current folder open state if no filter currently applied
  368. if (!mActivePanel->getRootFolder()->isFilterModified())
  369. {
  370. mSavedFolderState->setApply(FALSE);
  371. mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
  372. }
  373. // set new filter string
  374. setFilterSubString(mFilterSubString);
  375. }
  376. //static
  377. BOOL LLPanelMainInventory::incrementalFind(LLFolderViewItem* first_item, const char *find_text, BOOL backward)
  378. {
  379. LLPanelMainInventory* active_view = NULL;
  380. LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("inventory");
  381. for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter)
  382. {
  383. LLPanelMainInventory* iv = dynamic_cast<LLPanelMainInventory*>(*iter);
  384. if (iv)
  385. {
  386. if (gFocusMgr.childHasKeyboardFocus(iv))
  387. {
  388. active_view = iv;
  389. break;
  390. }
  391. }
  392. }
  393. if (!active_view)
  394. {
  395. return FALSE;
  396. }
  397. std::string search_string(find_text);
  398. if (search_string.empty())
  399. {
  400. return FALSE;
  401. }
  402. if (active_view->getPanel() &&
  403. active_view->getPanel()->getRootFolder()->search(first_item, search_string, backward))
  404. {
  405. return TRUE;
  406. }
  407. return FALSE;
  408. }
  409. void LLPanelMainInventory::onFilterSelected()
  410. {
  411. // Find my index
  412. mActivePanel = (LLInventoryPanel*)getChild<LLTabContainer>("inventory filter tabs")->getCurrentPanel();
  413. if (!mActivePanel)
  414. {
  415. return;
  416. }
  417. setFilterSubString(mFilterSubString);
  418. LLInventoryFilter* filter = mActivePanel->getFilter();
  419. LLFloaterInventoryFinder *finder = getFinder();
  420. if (finder)
  421. {
  422. finder->changeFilter(filter);
  423. }
  424. if (filter->isActive())
  425. {
  426. // If our filter is active we may be the first thing requiring a fetch so we better start it here.
  427. LLInventoryModelBackgroundFetch::instance().start();
  428. }
  429. setFilterTextFromFilter();
  430. }
  431. const std::string LLPanelMainInventory::getFilterSubString()
  432. {
  433. return mActivePanel->getFilterSubString();
  434. }
  435. void LLPanelMainInventory::setFilterSubString(const std::string& string)
  436. {
  437. mActivePanel->setFilterSubString(string);
  438. }
  439. BOOL LLPanelMainInventory::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  440. EDragAndDropType cargo_type,
  441. void* cargo_data,
  442. EAcceptance* accept,
  443. std::string& tooltip_msg)
  444. {
  445. // Check to see if we are auto scrolling from the last frame
  446. LLInventoryPanel* panel = (LLInventoryPanel*)this->getActivePanel();
  447. BOOL needsToScroll = panel->getScrollableContainer()->autoScroll(x, y);
  448. if(mFilterTabs)
  449. {
  450. if(needsToScroll)
  451. {
  452. mFilterTabs->startDragAndDropDelayTimer();
  453. }
  454. }
  455. BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
  456. return handled;
  457. }
  458. // virtual
  459. void LLPanelMainInventory::changed(U32)
  460. {
  461. updateItemcountText();
  462. }
  463. // virtual
  464. void LLPanelMainInventory::draw()
  465. {
  466. if (mActivePanel && mFilterEditor)
  467. {
  468. mFilterEditor->setText(mFilterSubString);
  469. }
  470. if (mActivePanel && mResortActivePanel)
  471. {
  472. // EXP-756: Force resorting of the list the first time we draw the list:
  473. // In the case of date sorting, we don't have enough information at initialization time
  474. // to correctly sort the folders. Later manual resort doesn't do anything as the order value is
  475. // set correctly. The workaround is to reset the order to alphabetical (or anything) then to the correct order.
  476. U32 order = mActivePanel->getSortOrder();
  477. mActivePanel->setSortOrder(LLInventoryFilter::SO_NAME);
  478. mActivePanel->setSortOrder(order);
  479. mResortActivePanel = false;
  480. }
  481. LLPanel::draw();
  482. updateItemcountText();
  483. }
  484. void LLPanelMainInventory::updateItemcountText()
  485. {
  486. // *TODO: Calling setlocale() on each frame may be inefficient.
  487. LLLocale locale(LLStringUtil::getLocale());
  488. std::string item_count_string;
  489. LLResMgr::getInstance()->getIntegerString(item_count_string, gInventory.getItemCount());
  490. LLStringUtil::format_map_t string_args;
  491. string_args["[ITEM_COUNT]"] = item_count_string;
  492. string_args["[FILTER]"] = getFilterText();
  493. std::string text = "";
  494. if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive())
  495. {
  496. text = getString("ItemcountFetching", string_args);
  497. }
  498. else if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched())
  499. {
  500. text = getString("ItemcountCompleted", string_args);
  501. }
  502. else
  503. {
  504. text = getString("ItemcountUnknown");
  505. }
  506. // *TODO: Cache the LLUICtrl* for the ItemcountText control
  507. getChild<LLUICtrl>("ItemcountText")->setValue(text);
  508. }
  509. void LLPanelMainInventory::onFocusReceived()
  510. {
  511. LLSidepanelInventory *sidepanel_inventory = LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
  512. if (!sidepanel_inventory)
  513. {
  514. llwarns << "Could not find Inventory Panel in My Inventory floater" << llendl;
  515. return;
  516. }
  517. sidepanel_inventory->clearSelections(false, true);
  518. }
  519. void LLPanelMainInventory::setFilterTextFromFilter()
  520. {
  521. mFilterText = mActivePanel->getFilter()->getFilterText();
  522. }
  523. void LLPanelMainInventory::toggleFindOptions()
  524. {
  525. LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE);
  526. LLFloater *floater = getFinder();
  527. if (!floater)
  528. {
  529. LLFloaterInventoryFinder * finder = new LLFloaterInventoryFinder(this);
  530. mFinderHandle = finder->getHandle();
  531. finder->openFloater();
  532. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  533. if (parent_floater)
  534. parent_floater->addDependentFloater(mFinderHandle);
  535. // start background fetch of folders
  536. LLInventoryModelBackgroundFetch::instance().start();
  537. }
  538. else
  539. {
  540. floater->closeFloater();
  541. }
  542. }
  543. void LLPanelMainInventory::setSelectCallback(const LLFolderView::signal_t::slot_type& cb)
  544. {
  545. getChild<LLInventoryPanel>("All Items")->setSelectCallback(cb);
  546. getChild<LLInventoryPanel>("Recent Items")->setSelectCallback(cb);
  547. }
  548. void LLPanelMainInventory::onSelectionChange(LLInventoryPanel *panel, const std::deque<LLFolderViewItem*>& items, BOOL user_action)
  549. {
  550. updateListCommands();
  551. panel->onSelectionChange(items, user_action);
  552. }
  553. ///----------------------------------------------------------------------------
  554. /// LLFloaterInventoryFinder
  555. ///----------------------------------------------------------------------------
  556. LLFloaterInventoryFinder* LLPanelMainInventory::getFinder()
  557. {
  558. return (LLFloaterInventoryFinder*)mFinderHandle.get();
  559. }
  560. LLFloaterInventoryFinder::LLFloaterInventoryFinder(LLPanelMainInventory* inventory_view) :
  561. LLFloater(LLSD()),
  562. mPanelMainInventory(inventory_view),
  563. mFilter(inventory_view->getPanel()->getFilter())
  564. {
  565. buildFromFile("floater_inventory_view_finder.xml");
  566. updateElementsFromFilter();
  567. }
  568. BOOL LLFloaterInventoryFinder::postBuild()
  569. {
  570. const LLRect& viewrect = mPanelMainInventory->getRect();
  571. setRect(LLRect(viewrect.mLeft - getRect().getWidth(), viewrect.mTop, viewrect.mLeft, viewrect.mTop - getRect().getHeight()));
  572. childSetAction("All", selectAllTypes, this);
  573. childSetAction("None", selectNoTypes, this);
  574. mSpinSinceHours = getChild<LLSpinCtrl>("spin_hours_ago");
  575. childSetCommitCallback("spin_hours_ago", onTimeAgo, this);
  576. mSpinSinceDays = getChild<LLSpinCtrl>("spin_days_ago");
  577. childSetCommitCallback("spin_days_ago", onTimeAgo, this);
  578. childSetAction("Close", onCloseBtn, this);
  579. updateElementsFromFilter();
  580. return TRUE;
  581. }
  582. void LLFloaterInventoryFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data)
  583. {
  584. LLFloaterInventoryFinder *self = (LLFloaterInventoryFinder *)user_data;
  585. if (!self) return;
  586. if ( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() )
  587. {
  588. self->getChild<LLUICtrl>("check_since_logoff")->setValue(false);
  589. }
  590. }
  591. void LLFloaterInventoryFinder::changeFilter(LLInventoryFilter* filter)
  592. {
  593. mFilter = filter;
  594. updateElementsFromFilter();
  595. }
  596. void LLFloaterInventoryFinder::updateElementsFromFilter()
  597. {
  598. if (!mFilter)
  599. return;
  600. // Get data needed for filter display
  601. U32 filter_types = mFilter->getFilterObjectTypes();
  602. std::string filter_string = mFilter->getFilterSubString();
  603. LLInventoryFilter::EFolderShow show_folders = mFilter->getShowFolderState();
  604. U32 hours = mFilter->getHoursAgo();
  605. // update the ui elements
  606. setTitle(mFilter->getName());
  607. getChild<LLUICtrl>("check_animation")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION));
  608. getChild<LLUICtrl>("check_calling_card")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD));
  609. getChild<LLUICtrl>("check_clothing")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE));
  610. getChild<LLUICtrl>("check_gesture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE));
  611. getChild<LLUICtrl>("check_landmark")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK));
  612. getChild<LLUICtrl>("check_mesh")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_MESH));
  613. getChild<LLUICtrl>("check_notecard")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD));
  614. getChild<LLUICtrl>("check_object")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT));
  615. getChild<LLUICtrl>("check_script")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_LSL));
  616. getChild<LLUICtrl>("check_sound")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND));
  617. getChild<LLUICtrl>("check_texture")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE));
  618. getChild<LLUICtrl>("check_snapshot")->setValue((S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT));
  619. getChild<LLUICtrl>("check_show_empty")->setValue(show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS);
  620. getChild<LLUICtrl>("check_since_logoff")->setValue(mFilter->isSinceLogoff());
  621. mSpinSinceHours->set((F32)(hours % 24));
  622. mSpinSinceDays->set((F32)(hours / 24));
  623. }
  624. void LLFloaterInventoryFinder::draw()
  625. {
  626. LLMemType mt(LLMemType::MTYPE_INVENTORY_DRAW);
  627. U32 filter = 0xffffffff;
  628. BOOL filtered_by_all_types = TRUE;
  629. if (!getChild<LLUICtrl>("check_animation")->getValue())
  630. {
  631. filter &= ~(0x1 << LLInventoryType::IT_ANIMATION);
  632. filtered_by_all_types = FALSE;
  633. }
  634. if (!getChild<LLUICtrl>("check_calling_card")->getValue())
  635. {
  636. filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD);
  637. filtered_by_all_types = FALSE;
  638. }
  639. if (!getChild<LLUICtrl>("check_clothing")->getValue())
  640. {
  641. filter &= ~(0x1 << LLInventoryType::IT_WEARABLE);
  642. filtered_by_all_types = FALSE;
  643. }
  644. if (!getChild<LLUICtrl>("check_gesture")->getValue())
  645. {
  646. filter &= ~(0x1 << LLInventoryType::IT_GESTURE);
  647. filtered_by_all_types = FALSE;
  648. }
  649. if (!getChild<LLUICtrl>("check_landmark")->getValue())
  650. {
  651. filter &= ~(0x1 << LLInventoryType::IT_LANDMARK);
  652. filtered_by_all_types = FALSE;
  653. }
  654. if (!getChild<LLUICtrl>("check_mesh")->getValue())
  655. {
  656. filter &= ~(0x1 << LLInventoryType::IT_MESH);
  657. filtered_by_all_types = FALSE;
  658. }
  659. if (!getChild<LLUICtrl>("check_notecard")->getValue())
  660. {
  661. filter &= ~(0x1 << LLInventoryType::IT_NOTECARD);
  662. filtered_by_all_types = FALSE;
  663. }
  664. if (!getChild<LLUICtrl>("check_object")->getValue())
  665. {
  666. filter &= ~(0x1 << LLInventoryType::IT_OBJECT);
  667. filter &= ~(0x1 << LLInventoryType::IT_ATTACHMENT);
  668. filtered_by_all_types = FALSE;
  669. }
  670. if (!getChild<LLUICtrl>("check_script")->getValue())
  671. {
  672. filter &= ~(0x1 << LLInventoryType::IT_LSL);
  673. filtered_by_all_types = FALSE;
  674. }
  675. if (!getChild<LLUICtrl>("check_sound")->getValue())
  676. {
  677. filter &= ~(0x1 << LLInventoryType::IT_SOUND);
  678. filtered_by_all_types = FALSE;
  679. }
  680. if (!getChild<LLUICtrl>("check_texture")->getValue())
  681. {
  682. filter &= ~(0x1 << LLInventoryType::IT_TEXTURE);
  683. filtered_by_all_types = FALSE;
  684. }
  685. if (!getChild<LLUICtrl>("check_snapshot")->getValue())
  686. {
  687. filter &= ~(0x1 << LLInventoryType::IT_SNAPSHOT);
  688. filtered_by_all_types = FALSE;
  689. }
  690. if (!filtered_by_all_types)
  691. {
  692. // don't include folders in filter, unless I've selected everything
  693. filter &= ~(0x1 << LLInventoryType::IT_CATEGORY);
  694. }
  695. // update the panel, panel will update the filter
  696. mPanelMainInventory->getPanel()->setShowFolderState(getCheckShowEmpty() ?
  697. LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
  698. mPanelMainInventory->getPanel()->setFilterTypes(filter);
  699. if (getCheckSinceLogoff())
  700. {
  701. mSpinSinceDays->set(0);
  702. mSpinSinceHours->set(0);
  703. }
  704. U32 days = (U32)mSpinSinceDays->get();
  705. U32 hours = (U32)mSpinSinceHours->get();
  706. if (hours > 24)
  707. {
  708. days += hours / 24;
  709. hours = (U32)hours % 24;
  710. mSpinSinceDays->set((F32)days);
  711. mSpinSinceHours->set((F32)hours);
  712. }
  713. hours += days * 24;
  714. mPanelMainInventory->getPanel()->setHoursAgo(hours);
  715. mPanelMainInventory->getPanel()->setSinceLogoff(getCheckSinceLogoff());
  716. mPanelMainInventory->setFilterTextFromFilter();
  717. LLPanel::draw();
  718. }
  719. BOOL LLFloaterInventoryFinder::getCheckShowEmpty()
  720. {
  721. return getChild<LLUICtrl>("check_show_empty")->getValue();
  722. }
  723. BOOL LLFloaterInventoryFinder::getCheckSinceLogoff()
  724. {
  725. return getChild<LLUICtrl>("check_since_logoff")->getValue();
  726. }
  727. void LLFloaterInventoryFinder::onCloseBtn(void* user_data)
  728. {
  729. LLFloaterInventoryFinder* finderp = (LLFloaterInventoryFinder*)user_data;
  730. finderp->closeFloater();
  731. }
  732. // static
  733. void LLFloaterInventoryFinder::selectAllTypes(void* user_data)
  734. {
  735. LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data;
  736. if(!self) return;
  737. self->getChild<LLUICtrl>("check_animation")->setValue(TRUE);
  738. self->getChild<LLUICtrl>("check_calling_card")->setValue(TRUE);
  739. self->getChild<LLUICtrl>("check_clothing")->setValue(TRUE);
  740. self->getChild<LLUICtrl>("check_gesture")->setValue(TRUE);
  741. self->getChild<LLUICtrl>("check_landmark")->setValue(TRUE);
  742. self->getChild<LLUICtrl>("check_mesh")->setValue(TRUE);
  743. self->getChild<LLUICtrl>("check_notecard")->setValue(TRUE);
  744. self->getChild<LLUICtrl>("check_object")->setValue(TRUE);
  745. self->getChild<LLUICtrl>("check_script")->setValue(TRUE);
  746. self->getChild<LLUICtrl>("check_sound")->setValue(TRUE);
  747. self->getChild<LLUICtrl>("check_texture")->setValue(TRUE);
  748. self->getChild<LLUICtrl>("check_snapshot")->setValue(TRUE);
  749. }
  750. //static
  751. void LLFloaterInventoryFinder::selectNoTypes(void* user_data)
  752. {
  753. LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data;
  754. if(!self) return;
  755. self->getChild<LLUICtrl>("check_animation")->setValue(FALSE);
  756. self->getChild<LLUICtrl>("check_calling_card")->setValue(FALSE);
  757. self->getChild<LLUICtrl>("check_clothing")->setValue(FALSE);
  758. self->getChild<LLUICtrl>("check_gesture")->setValue(FALSE);
  759. self->getChild<LLUICtrl>("check_landmark")->setValue(FALSE);
  760. self->getChild<LLUICtrl>("check_mesh")->setValue(FALSE);
  761. self->getChild<LLUICtrl>("check_notecard")->setValue(FALSE);
  762. self->getChild<LLUICtrl>("check_object")->setValue(FALSE);
  763. self->getChild<LLUICtrl>("check_script")->setValue(FALSE);
  764. self->getChild<LLUICtrl>("check_sound")->setValue(FALSE);
  765. self->getChild<LLUICtrl>("check_texture")->setValue(FALSE);
  766. self->getChild<LLUICtrl>("check_snapshot")->setValue(FALSE);
  767. }
  768. //////////////////////////////////////////////////////////////////////////////////
  769. // List Commands //
  770. void LLPanelMainInventory::initListCommandsHandlers()
  771. {
  772. childSetAction("trash_btn", boost::bind(&LLPanelMainInventory::onTrashButtonClick, this));
  773. childSetAction("add_btn", boost::bind(&LLPanelMainInventory::onAddButtonClick, this));
  774. mTrashButton = getChild<LLDragAndDropButton>("trash_btn");
  775. mTrashButton->setDragAndDropHandler(boost::bind(&LLPanelMainInventory::handleDragAndDropToTrash, this
  776. , _4 // BOOL drop
  777. , _5 // EDragAndDropType cargo_type
  778. , _7 // EAcceptance* accept
  779. ));
  780. mCommitCallbackRegistrar.add("Inventory.GearDefault.Custom.Action", boost::bind(&LLPanelMainInventory::onCustomAction, this, _2));
  781. mEnableCallbackRegistrar.add("Inventory.GearDefault.Check", boost::bind(&LLPanelMainInventory::isActionChecked, this, _2));
  782. mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2));
  783. mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
  784. mGearMenuButton->setMenu(mMenuGearDefault);
  785. mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
  786. // Update the trash button when selected item(s) get worn or taken off.
  787. LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLPanelMainInventory::updateListCommands, this));
  788. }
  789. void LLPanelMainInventory::updateListCommands()
  790. {
  791. bool trash_enabled = isActionEnabled("delete");
  792. mTrashButton->setEnabled(trash_enabled);
  793. }
  794. void LLPanelMainInventory::onAddButtonClick()
  795. {
  796. // Gray out the "New Folder" option when the Recent tab is active as new folders will not be displayed
  797. // unless "Always show folders" is checked in the filter options.
  798. bool recent_active = ("Recent Items" == mActivePanel->getName());
  799. mMenuAdd->getChild<LLMenuItemGL>("New Folder")->setEnabled(!recent_active);
  800. setUploadCostIfNeeded();
  801. showActionMenu(mMenuAdd,"add_btn");
  802. }
  803. void LLPanelMainInventory::showActionMenu(LLMenuGL* menu, std::string spawning_view_name)
  804. {
  805. if (menu)
  806. {
  807. menu->buildDrawLabels();
  808. menu->updateParent(LLMenuGL::sMenuContainer);
  809. LLView* spawning_view = getChild<LLView> (spawning_view_name);
  810. S32 menu_x, menu_y;
  811. //show menu in co-ordinates of panel
  812. spawning_view->localPointToOtherView(0, spawning_view->getRect().getHeight(), &menu_x, &menu_y, this);
  813. menu_y += menu->getRect().getHeight();
  814. LLMenuGL::showPopup(this, menu, menu_x, menu_y);
  815. }
  816. }
  817. void LLPanelMainInventory::onTrashButtonClick()
  818. {
  819. onClipboardAction("delete");
  820. }
  821. void LLPanelMainInventory::onClipboardAction(const LLSD& userdata)
  822. {
  823. std::string command_name = userdata.asString();
  824. getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name);
  825. }
  826. void LLPanelMainInventory::saveTexture(const LLSD& userdata)
  827. {
  828. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  829. if (!current_item)
  830. {
  831. return;
  832. }
  833. const LLUUID& item_id = current_item->getListener()->getUUID();
  834. LLPreviewTexture* preview_texture = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(item_id), TAKE_FOCUS_YES);
  835. if (preview_texture)
  836. {
  837. preview_texture->openToSave();
  838. }
  839. }
  840. void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
  841. {
  842. if (!isActionEnabled(userdata))
  843. return;
  844. const std::string command_name = userdata.asString();
  845. if (command_name == "new_window")
  846. {
  847. newWindow();
  848. }
  849. if (command_name == "sort_by_name")
  850. {
  851. const LLSD arg = "name";
  852. setSortBy(arg);
  853. }
  854. if (command_name == "sort_by_recent")
  855. {
  856. const LLSD arg = "date";
  857. setSortBy(arg);
  858. }
  859. if (command_name == "sort_folders_by_name")
  860. {
  861. const LLSD arg = "foldersalwaysbyname";
  862. setSortBy(arg);
  863. }
  864. if (command_name == "sort_system_folders_to_top")
  865. {
  866. const LLSD arg = "systemfolderstotop";
  867. setSortBy(arg);
  868. }
  869. if (command_name == "show_filters")
  870. {
  871. toggleFindOptions();
  872. }
  873. if (command_name == "reset_filters")
  874. {
  875. resetFilters();
  876. }
  877. if (command_name == "close_folders")
  878. {
  879. closeAllFolders();
  880. }
  881. if (command_name == "empty_trash")
  882. {
  883. const std::string notification = "ConfirmEmptyTrash";
  884. gInventory.emptyFolderType(notification, LLFolderType::FT_TRASH);
  885. }
  886. if (command_name == "empty_lostnfound")
  887. {
  888. const std::string notification = "ConfirmEmptyLostAndFound";
  889. gInventory.emptyFolderType(notification, LLFolderType::FT_LOST_AND_FOUND);
  890. }
  891. if (command_name == "save_texture")
  892. {
  893. saveTexture(userdata);
  894. }
  895. // This doesn't currently work, since the viewer can't change an assetID an item.
  896. if (command_name == "regenerate_link")
  897. {
  898. LLInventoryPanel *active_panel = getActivePanel();
  899. LLFolderViewItem* current_item = active_panel->getRootFolder()->getCurSelectedItem();
  900. if (!current_item)
  901. {
  902. return;
  903. }
  904. const LLUUID item_id = current_item->getListener()->getUUID();
  905. LLViewerInventoryItem *item = gInventory.getItem(item_id);
  906. if (item)
  907. {
  908. item->regenerateLink();
  909. }
  910. active_panel->setSelection(item_id, TAKE_FOCUS_NO);
  911. }
  912. if (command_name == "find_original")
  913. {
  914. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  915. if (!current_item)
  916. {
  917. return;
  918. }
  919. current_item->getListener()->performAction(getActivePanel()->getModel(), "goto");
  920. }
  921. if (command_name == "find_links")
  922. {
  923. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  924. if (!current_item)
  925. {
  926. return;
  927. }
  928. const LLUUID& item_id = current_item->getListener()->getUUID();
  929. const std::string &item_name = current_item->getListener()->getName();
  930. mFilterSubString = item_name;
  931. LLInventoryFilter *filter = mActivePanel->getFilter();
  932. filter->setFilterSubString(item_name);
  933. mFilterEditor->setText(item_name);
  934. mFilterEditor->setFocus(TRUE);
  935. filter->setFilterUUID(item_id);
  936. filter->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
  937. filter->setFilterLinks(LLInventoryFilter::FILTERLINK_ONLY_LINKS);
  938. }
  939. }
  940. bool LLPanelMainInventory::isSaveTextureEnabled(const LLSD& userdata)
  941. {
  942. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  943. if (current_item)
  944. {
  945. LLViewerInventoryItem *inv_item = current_item->getInventoryItem();
  946. if(inv_item)
  947. {
  948. bool can_save = inv_item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED);
  949. LLInventoryType::EType curr_type = current_item->getListener()->getInventoryType();
  950. return can_save && (curr_type == LLInventoryType::IT_TEXTURE || curr_type == LLInventoryType::IT_SNAPSHOT);
  951. }
  952. }
  953. return false;
  954. }
  955. BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
  956. {
  957. const std::string command_name = userdata.asString();
  958. if (command_name == "delete")
  959. {
  960. BOOL can_delete = FALSE;
  961. LLFolderView* root = getActivePanel()->getRootFolder();
  962. if (root)
  963. {
  964. can_delete = TRUE;
  965. std::set<LLUUID> selection_set = root->getSelectionList();
  966. if (selection_set.empty()) return FALSE;
  967. for (std::set<LLUUID>::iterator iter = selection_set.begin();
  968. iter != selection_set.end();
  969. ++iter)
  970. {
  971. const LLUUID &item_id = (*iter);
  972. LLFolderViewItem *item = root->getItemByID(item_id);
  973. const LLFolderViewEventListener *listener = item->getListener();
  974. llassert(listener);
  975. if (!listener) return FALSE;
  976. can_delete &= listener->isItemRemovable();
  977. can_delete &= !listener->isItemInTrash();
  978. }
  979. return can_delete;
  980. }
  981. return FALSE;
  982. }
  983. if (command_name == "save_texture")
  984. {
  985. return isSaveTextureEnabled(userdata);
  986. }
  987. if (command_name == "find_original")
  988. {
  989. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  990. if (!current_item) return FALSE;
  991. const LLUUID& item_id = current_item->getListener()->getUUID();
  992. const LLViewerInventoryItem *item = gInventory.getItem(item_id);
  993. if (item && item->getIsLinkType() && !item->getIsBrokenLink())
  994. {
  995. return TRUE;
  996. }
  997. return FALSE;
  998. }
  999. if (command_name == "find_links")
  1000. {
  1001. LLFolderView* root = getActivePanel()->getRootFolder();
  1002. std::set<LLUUID> selection_set = root->getSelectionList();
  1003. if (selection_set.size() != 1) return FALSE;
  1004. LLFolderViewItem* current_item = root->getCurSelectedItem();
  1005. if (!current_item) return FALSE;
  1006. const LLUUID& item_id = current_item->getListener()->getUUID();
  1007. const LLInventoryObject *obj = gInventory.getObject(item_id);
  1008. if (obj && !obj->getIsLinkType() && LLAssetType::lookupCanLink(obj->getType()))
  1009. {
  1010. return TRUE;
  1011. }
  1012. return FALSE;
  1013. }
  1014. // This doesn't currently work, since the viewer can't change an assetID an item.
  1015. if (command_name == "regenerate_link")
  1016. {
  1017. LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
  1018. if (!current_item) return FALSE;
  1019. const LLUUID& item_id = current_item->getListener()->getUUID();
  1020. const LLViewerInventoryItem *item = gInventory.getItem(item_id);
  1021. if (item && item->getIsBrokenLink())
  1022. {
  1023. return TRUE;
  1024. }
  1025. return FALSE;
  1026. }
  1027. if (command_name == "share")
  1028. {
  1029. LLSidepanelInventory* parent = LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
  1030. return parent ? parent->canShare() : FALSE;
  1031. }
  1032. return TRUE;
  1033. }
  1034. BOOL LLPanelMainInventory::isActionChecked(const LLSD& userdata)
  1035. {
  1036. U32 sort_order_mask = getActivePanel()->getSortOrder();
  1037. const std::string command_name = userdata.asString();
  1038. if (command_name == "sort_by_name")
  1039. {
  1040. return ~sort_order_mask & LLInventoryFilter::SO_DATE;
  1041. }
  1042. if (command_name == "sort_by_recent")
  1043. {
  1044. return sort_order_mask & LLInventoryFilter::SO_DATE;
  1045. }
  1046. if (command_name == "sort_folders_by_name")
  1047. {
  1048. return sort_order_mask & LLInventoryFilter::SO_FOLDERS_BY_NAME;
  1049. }
  1050. if (command_name == "sort_system_folders_to_top")
  1051. {
  1052. return sort_order_mask & LLInventoryFilter::SO_SYSTEM_FOLDERS_TO_TOP;
  1053. }
  1054. return FALSE;
  1055. }
  1056. bool LLPanelMainInventory::handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept)
  1057. {
  1058. *accept = ACCEPT_NO;
  1059. const bool is_enabled = isActionEnabled("delete");
  1060. if (is_enabled) *accept = ACCEPT_YES_MULTI;
  1061. if (is_enabled && drop)
  1062. {
  1063. onClipboardAction("delete");
  1064. }
  1065. return true;
  1066. }
  1067. void LLPanelMainInventory::setUploadCostIfNeeded()
  1068. {
  1069. // *NOTE dzaporozhan
  1070. // Upload cost is set in process_economy_data() (llviewermessage.cpp). But since we
  1071. // have two instances of Inventory panel at the moment(and two instances of context menu),
  1072. // call to gMenuHolder->childSetLabelArg() sets upload cost only for one of the instances.
  1073. if(mNeedUploadCost && mMenuAdd)
  1074. {
  1075. LLMenuItemBranchGL* upload_menu = mMenuAdd->findChild<LLMenuItemBranchGL>("upload");
  1076. if(upload_menu)
  1077. {
  1078. S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
  1079. std::string cost_str;
  1080. // getPriceUpload() returns -1 if no data available yet.
  1081. if(upload_cost >= 0)
  1082. {
  1083. mNeedUploadCost = false;
  1084. cost_str = llformat("%d", upload_cost);
  1085. }
  1086. else
  1087. {
  1088. cost_str = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
  1089. }
  1090. upload_menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", cost_str);
  1091. upload_menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", cost_str);
  1092. upload_menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", cost_str);
  1093. upload_menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", cost_str);
  1094. }
  1095. }
  1096. }
  1097. // List Commands //
  1098. ////////////////////////////////////////////////////////////////////////////////