PageRenderTime 30ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llinventorypanel.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 253 lines | 163 code | 33 blank | 57 comment | 0 complexity | ec243acf7fdb58fa6195e8b84def8b4d MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llinventorypanel.h
  3. * @brief LLInventoryPanel
  4. * class definition
  5. *
  6. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LL_LLINVENTORYPANEL_H
  28. #define LL_LLINVENTORYPANEL_H
  29. #include "llassetstorage.h"
  30. #include "lldarray.h"
  31. #include "llfloater.h"
  32. #include "llinventory.h"
  33. #include "llinventoryfilter.h"
  34. #include "llinventorymodel.h"
  35. #include "llscrollcontainer.h"
  36. #include "lluictrlfactory.h"
  37. #include <set>
  38. class LLFolderView;
  39. class LLFolderViewFolder;
  40. class LLFolderViewItem;
  41. class LLInventoryFilter;
  42. class LLInventoryModel;
  43. class LLInvFVBridge;
  44. class LLInventoryFVBridgeBuilder;
  45. class LLMenuBarGL;
  46. class LLCheckBoxCtrl;
  47. class LLSpinCtrl;
  48. class LLTextBox;
  49. class LLIconCtrl;
  50. class LLSaveFolderState;
  51. class LLFilterEditor;
  52. class LLTabContainer;
  53. class LLInvPanelComplObserver;
  54. class LLInventoryPanel : public LLPanel
  55. {
  56. //--------------------------------------------------------------------
  57. // Data
  58. //--------------------------------------------------------------------
  59. public:
  60. struct Filter : public LLInitParam::Block<Filter>
  61. {
  62. Optional<U32> sort_order;
  63. Optional<U32> types;
  64. Optional<std::string> search_string;
  65. Filter()
  66. : sort_order("sort_order"),
  67. types("types", 0xffffffff),
  68. search_string("search_string")
  69. {}
  70. };
  71. struct Params
  72. : public LLInitParam::Block<Params, LLPanel::Params>
  73. {
  74. Optional<std::string> sort_order_setting;
  75. Optional<LLInventoryModel*> inventory;
  76. Optional<bool> allow_multi_select;
  77. Optional<bool> show_item_link_overlays;
  78. Optional<Filter> filter;
  79. Optional<std::string> start_folder;
  80. Optional<bool> use_label_suffix;
  81. Optional<bool> show_empty_message;
  82. Optional<bool> show_load_status;
  83. Optional<LLScrollContainer::Params> scroll;
  84. Optional<bool> accepts_drag_and_drop;
  85. Params()
  86. : sort_order_setting("sort_order_setting"),
  87. inventory("", &gInventory),
  88. allow_multi_select("allow_multi_select", true),
  89. show_item_link_overlays("show_item_link_overlays", false),
  90. filter("filter"),
  91. start_folder("start_folder"),
  92. use_label_suffix("use_label_suffix", true),
  93. show_empty_message("show_empty_message", true),
  94. show_load_status("show_load_status"),
  95. scroll("scroll"),
  96. accepts_drag_and_drop("accepts_drag_and_drop")
  97. {}
  98. };
  99. //--------------------------------------------------------------------
  100. // Initialization
  101. //--------------------------------------------------------------------
  102. protected:
  103. LLInventoryPanel(const Params&);
  104. void initFromParams(const Params&);
  105. friend class LLUICtrlFactory;
  106. public:
  107. virtual ~LLInventoryPanel();
  108. public:
  109. LLInventoryModel* getModel() { return mInventory; }
  110. // LLView methods
  111. void draw();
  112. BOOL handleHover(S32 x, S32 y, MASK mask);
  113. BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  114. EDragAndDropType cargo_type,
  115. void* cargo_data,
  116. EAcceptance* accept,
  117. std::string& tooltip_msg);
  118. // LLUICtrl methods
  119. /*virtual*/ void onFocusLost();
  120. /*virtual*/ void onFocusReceived();
  121. // LLBadgeHolder methods
  122. bool addBadge(LLBadge * badge);
  123. // Call this method to set the selection.
  124. void openAllFolders();
  125. void setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus);
  126. void setSelectCallback(const boost::function<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)>& cb);
  127. void clearSelection();
  128. LLInventoryFilter* getFilter();
  129. const LLInventoryFilter* getFilter() const;
  130. void setFilterTypes(U64 filter, LLInventoryFilter::EFilterType = LLInventoryFilter::FILTERTYPE_OBJECT);
  131. U32 getFilterObjectTypes() const;
  132. void setFilterPermMask(PermissionMask filter_perm_mask);
  133. U32 getFilterPermMask() const;
  134. void setFilterWearableTypes(U64 filter);
  135. void setFilterSubString(const std::string& string);
  136. const std::string getFilterSubString();
  137. void setSinceLogoff(BOOL sl);
  138. void setHoursAgo(U32 hours);
  139. BOOL getSinceLogoff();
  140. void setFilterLinks(U64 filter_links);
  141. void setShowFolderState(LLInventoryFilter::EFolderShow show);
  142. LLInventoryFilter::EFolderShow getShowFolderState();
  143. // This method is called when something has changed about the inventory.
  144. void modelChanged(U32 mask);
  145. LLFolderView* getRootFolder();
  146. LLScrollContainer* getScrollableContainer() { return mScroller; }
  147. void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
  148. // Callbacks
  149. void doToSelected(const LLSD& userdata);
  150. void doCreate(const LLSD& userdata);
  151. bool beginIMSession();
  152. bool attachObject(const LLSD& userdata);
  153. // DEBUG ONLY:
  154. static void dumpSelectionInformation(void* user_data);
  155. void openSelected();
  156. void unSelectAll();
  157. static void onIdle(void* user_data);
  158. // Find whichever inventory panel is active / on top.
  159. // "Auto_open" determines if we open an inventory panel if none are open.
  160. static LLInventoryPanel *getActiveInventoryPanel(BOOL auto_open = TRUE);
  161. static void openInventoryPanelAndSetSelection(BOOL auto_open, const LLUUID& obj_id);
  162. protected:
  163. void openStartFolderOrMyInventory(); // open the first level of inventory
  164. void onItemsCompletion(); // called when selected items are complete
  165. LLInventoryModel* mInventory;
  166. LLInventoryObserver* mInventoryObserver;
  167. LLInvPanelComplObserver* mCompletionObserver;
  168. BOOL mAcceptsDragAndDrop;
  169. BOOL mAllowMultiSelect;
  170. BOOL mShowItemLinkOverlays; // Shows link graphic over inventory item icons
  171. BOOL mShowEmptyMessage;
  172. BOOL mShowLoadStatus;
  173. LLFolderView* mFolderRoot;
  174. LLScrollContainer* mScroller;
  175. /**
  176. * Pointer to LLInventoryFVBridgeBuilder.
  177. *
  178. * It is set in LLInventoryPanel's constructor and can be overridden in derived classes with
  179. * another implementation.
  180. * Take into account it will not be deleted by LLInventoryPanel itself.
  181. */
  182. const LLInventoryFVBridgeBuilder* mInvFVBridgeBuilder;
  183. //--------------------------------------------------------------------
  184. // Sorting
  185. //--------------------------------------------------------------------
  186. public:
  187. static const std::string DEFAULT_SORT_ORDER;
  188. static const std::string RECENTITEMS_SORT_ORDER;
  189. static const std::string INHERIT_SORT_ORDER;
  190. void setSortOrder(U32 order);
  191. U32 getSortOrder() const;
  192. void requestSort();
  193. private:
  194. std::string mSortOrderSetting;
  195. //--------------------------------------------------------------------
  196. // Hidden folders
  197. //--------------------------------------------------------------------
  198. public:
  199. void addHideFolderType(LLFolderType::EType folder_type);
  200. public:
  201. BOOL getIsViewsInitialized() const { return mViewsInitialized; }
  202. const LLUUID& getRootFolderID() const;
  203. protected:
  204. // Builds the UI. Call this once the inventory is usable.
  205. void initializeViews();
  206. LLFolderViewItem* rebuildViewsFor(const LLUUID& id); // Given the id and the parent, build all of the folder views.
  207. virtual void buildFolderView(const LLInventoryPanel::Params& params);
  208. LLFolderViewItem* buildNewViews(const LLUUID& id);
  209. BOOL getIsHiddenFolderType(LLFolderType::EType folder_type) const;
  210. virtual LLFolderView* createFolderView(LLInvFVBridge * bridge, bool useLabelSuffix);
  211. virtual LLFolderViewFolder* createFolderViewFolder(LLInvFVBridge * bridge);
  212. virtual LLFolderViewItem* createFolderViewItem(LLInvFVBridge * bridge);
  213. private:
  214. BOOL mBuildDefaultHierarchy; // default inventory hierarchy should be created in postBuild()
  215. BOOL mViewsInitialized; // Views have been generated
  216. // UUID of category from which hierarchy should be built. Set with the
  217. // "start_folder" xml property. Default is LLUUID::null that means total Inventory hierarchy.
  218. LLUUID mStartFolderID;
  219. };
  220. #endif // LL_LLINVENTORYPANEL_H