/indra/newview/llfilteredwearablelist.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 96 lines · 53 code · 14 blank · 29 comment · 8 complexity · d7b07f2847f2ada4ba590c28b0d3bb5a MD5 · raw file

  1. /**
  2. * @file llfilteredwearablelist.cpp
  3. * @brief Functionality for showing filtered wearable flat list
  4. *
  5. * $LicenseInfo:firstyear=2010&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 "llfilteredwearablelist.h"
  28. // newview
  29. #include "llinventoryfunctions.h"
  30. #include "llinventoryitemslist.h"
  31. #include "llinventorymodel.h"
  32. #include "llviewerinventory.h"
  33. LLFilteredWearableListManager::LLFilteredWearableListManager(LLInventoryItemsList* list, LLInventoryCollectFunctor* collector)
  34. : mWearableList(list)
  35. , mCollector(collector)
  36. {
  37. llassert(mWearableList);
  38. gInventory.addObserver(this);
  39. gInventory.fetchDescendentsOf(gInventory.getRootFolderID());
  40. }
  41. LLFilteredWearableListManager::~LLFilteredWearableListManager()
  42. {
  43. gInventory.removeObserver(this);
  44. }
  45. void LLFilteredWearableListManager::changed(U32 mask)
  46. {
  47. if (LLInventoryObserver::CALLING_CARD == mask
  48. || LLInventoryObserver::GESTURE == mask
  49. || LLInventoryObserver::SORT == mask
  50. )
  51. {
  52. // skip non-related changes
  53. return;
  54. }
  55. if(!gInventory.isInventoryUsable())
  56. {
  57. return;
  58. }
  59. populateList();
  60. }
  61. void LLFilteredWearableListManager::setFilterCollector(LLInventoryCollectFunctor* collector)
  62. {
  63. mCollector = collector;
  64. populateList();
  65. }
  66. void LLFilteredWearableListManager::populateList()
  67. {
  68. LLInventoryModel::cat_array_t cat_array;
  69. LLInventoryModel::item_array_t item_array;
  70. if(mCollector)
  71. {
  72. gInventory.collectDescendentsIf(
  73. gInventory.getRootFolderID(),
  74. cat_array,
  75. item_array,
  76. LLInventoryModel::EXCLUDE_TRASH,
  77. *mCollector);
  78. }
  79. // Probably will also need to get items from Library (waiting for reply in EXT-6724).
  80. mWearableList->refreshList(item_array);
  81. }
  82. // EOF