PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llinventoryitemslist.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 116 lines | 37 code | 25 blank | 54 comment | 0 complexity | cc1cc7528e155882cce7bf8973e9b0a3 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llinventoryitemslist.h
  3. * @brief A list of inventory items represented by LLFlatListView.
  4. *
  5. * Class LLInventoryItemsList implements a flat list of inventory items.
  6. *
  7. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #ifndef LL_LLINVENTORYITEMSLIST_H
  29. #define LL_LLINVENTORYITEMSLIST_H
  30. #include "lldarray.h"
  31. // newview
  32. #include "llflatlistview.h"
  33. class LLViewerInventoryItem;
  34. class LLInventoryItemsList : public LLFlatListViewEx
  35. {
  36. public:
  37. struct Params : public LLInitParam::Block<Params, LLFlatListViewEx::Params>
  38. {
  39. Params();
  40. };
  41. virtual ~LLInventoryItemsList();
  42. void refreshList(const LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array);
  43. boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb);
  44. /**
  45. * Let list know items need to be refreshed in next doIdle()
  46. */
  47. void setNeedsRefresh(bool needs_refresh){ mNeedsRefresh = needs_refresh; }
  48. bool getNeedsRefresh(){ return mNeedsRefresh; }
  49. /**
  50. * Sets the flag indicating that the list needs to be refreshed even if it is
  51. * not currently visible.
  52. */
  53. void setForceRefresh(bool force_refresh){ mForceRefresh = force_refresh; }
  54. virtual bool selectItemByValue(const LLSD& value, bool select = true);
  55. void updateSelection();
  56. /**
  57. * Idle routine used to refresh the list regardless of the current list
  58. * visibility, unlike draw() which is called only for the visible list.
  59. * This is needed for example to filter items of the list hidden by closed
  60. * accordion tab.
  61. */
  62. void doIdle(); // Real idle routine
  63. static void idle(void* user_data); // static glue to doIdle()
  64. protected:
  65. friend class LLUICtrlFactory;
  66. LLInventoryItemsList(const LLInventoryItemsList::Params& p);
  67. uuid_vec_t& getIDs() { return mIDs; }
  68. /**
  69. * Refreshes list items, adds new items and removes deleted items.
  70. * Called from doIdle() until all new items are added,
  71. * maximum 50 items can be added during single call.
  72. */
  73. void refresh();
  74. /**
  75. * Compute difference between new items and current items, fills 'vadded' with added items,
  76. * 'vremoved' with removed items. See LLCommonUtils::computeDifference
  77. */
  78. void computeDifference(const uuid_vec_t& vnew, uuid_vec_t& vadded, uuid_vec_t& vremoved);
  79. /**
  80. * Add an item to the list
  81. */
  82. virtual void addNewItem(LLViewerInventoryItem* item, bool rearrange = true);
  83. private:
  84. uuid_vec_t mIDs; // IDs of items that were added in refreshList().
  85. // Will be used in refresh() to determine added and removed ids
  86. uuid_vec_t mSelectTheseIDs; // IDs that will be selected if list is not loaded till now
  87. bool mNeedsRefresh;
  88. bool mForceRefresh;
  89. commit_signal_t mRefreshCompleteSignal;
  90. };
  91. #endif //LL_LLINVENTORYITEMSLIST_H