PageRenderTime 405ms CodeModel.GetById 122ms app.highlight 96ms RepoModel.GetById 182ms app.codeStats 1ms

/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
  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
 28#ifndef LL_LLINVENTORYPANEL_H
 29#define LL_LLINVENTORYPANEL_H
 30
 31#include "llassetstorage.h"
 32#include "lldarray.h"
 33#include "llfloater.h"
 34#include "llinventory.h"
 35#include "llinventoryfilter.h"
 36#include "llinventorymodel.h"
 37#include "llscrollcontainer.h"
 38#include "lluictrlfactory.h"
 39#include <set>
 40
 41class LLFolderView;
 42class LLFolderViewFolder;
 43class LLFolderViewItem;
 44class LLInventoryFilter;
 45class LLInventoryModel;
 46class LLInvFVBridge;
 47class LLInventoryFVBridgeBuilder;
 48class LLMenuBarGL;
 49class LLCheckBoxCtrl;
 50class LLSpinCtrl;
 51class LLTextBox;
 52class LLIconCtrl;
 53class LLSaveFolderState;
 54class LLFilterEditor;
 55class LLTabContainer;
 56class LLInvPanelComplObserver;
 57
 58class LLInventoryPanel : public LLPanel
 59{
 60	//--------------------------------------------------------------------
 61	// Data
 62	//--------------------------------------------------------------------
 63public:
 64	struct Filter : public LLInitParam::Block<Filter>
 65	{
 66		Optional<U32>			sort_order;
 67		Optional<U32>			types;
 68		Optional<std::string>	search_string;
 69
 70		Filter()
 71		:	sort_order("sort_order"),
 72			types("types", 0xffffffff),
 73			search_string("search_string")
 74		{}
 75	};
 76
 77	struct Params 
 78	:	public LLInitParam::Block<Params, LLPanel::Params>
 79	{
 80		Optional<std::string>				sort_order_setting;
 81		Optional<LLInventoryModel*>			inventory;
 82		Optional<bool>						allow_multi_select;
 83		Optional<bool>						show_item_link_overlays;
 84		Optional<Filter>					filter;
 85		Optional<std::string>               start_folder;
 86		Optional<bool>						use_label_suffix;
 87		Optional<bool>						show_empty_message;
 88		Optional<bool>						show_load_status;
 89		Optional<LLScrollContainer::Params>	scroll;
 90		Optional<bool>						accepts_drag_and_drop;
 91
 92		Params()
 93		:	sort_order_setting("sort_order_setting"),
 94			inventory("", &gInventory),
 95			allow_multi_select("allow_multi_select", true),
 96			show_item_link_overlays("show_item_link_overlays", false),
 97			filter("filter"),
 98			start_folder("start_folder"),
 99			use_label_suffix("use_label_suffix", true),
100			show_empty_message("show_empty_message", true),
101			show_load_status("show_load_status"),
102			scroll("scroll"),
103			accepts_drag_and_drop("accepts_drag_and_drop")
104		{}
105	};
106
107	//--------------------------------------------------------------------
108	// Initialization
109	//--------------------------------------------------------------------
110protected:
111	LLInventoryPanel(const Params&);
112	void initFromParams(const Params&);
113	friend class LLUICtrlFactory;
114public:
115	virtual ~LLInventoryPanel();
116
117public:
118	LLInventoryModel* getModel() { return mInventory; }
119
120	// LLView methods
121	void draw();
122	BOOL handleHover(S32 x, S32 y, MASK mask);
123	BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
124								   EDragAndDropType cargo_type,
125								   void* cargo_data,
126								   EAcceptance* accept,
127								   std::string& tooltip_msg);
128	// LLUICtrl methods
129	 /*virtual*/ void onFocusLost();
130	 /*virtual*/ void onFocusReceived();
131
132	// LLBadgeHolder methods
133	bool addBadge(LLBadge * badge);
134
135	// Call this method to set the selection.
136	void openAllFolders();
137	void setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus);
138	void setSelectCallback(const boost::function<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)>& cb);
139	void clearSelection();
140	LLInventoryFilter* getFilter();
141	const LLInventoryFilter* getFilter() const;
142	void setFilterTypes(U64 filter, LLInventoryFilter::EFilterType = LLInventoryFilter::FILTERTYPE_OBJECT);
143	U32 getFilterObjectTypes() const;
144	void setFilterPermMask(PermissionMask filter_perm_mask);
145	U32 getFilterPermMask() const;
146	void setFilterWearableTypes(U64 filter);
147	void setFilterSubString(const std::string& string);
148	const std::string getFilterSubString();
149	void setSinceLogoff(BOOL sl);
150	void setHoursAgo(U32 hours);
151	BOOL getSinceLogoff();
152	void setFilterLinks(U64 filter_links);
153
154	void setShowFolderState(LLInventoryFilter::EFolderShow show);
155	LLInventoryFilter::EFolderShow getShowFolderState();
156	// This method is called when something has changed about the inventory.
157	void modelChanged(U32 mask);
158	LLFolderView* getRootFolder();
159	LLScrollContainer* getScrollableContainer() { return mScroller; }
160	
161	void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
162	
163	// Callbacks
164	void doToSelected(const LLSD& userdata);
165	void doCreate(const LLSD& userdata);
166	bool beginIMSession();
167	bool attachObject(const LLSD& userdata);
168	
169	// DEBUG ONLY:
170	static void dumpSelectionInformation(void* user_data);
171
172	void openSelected();
173	void unSelectAll();
174	
175	static void onIdle(void* user_data);
176
177	// Find whichever inventory panel is active / on top.
178	// "Auto_open" determines if we open an inventory panel if none are open.
179	static LLInventoryPanel *getActiveInventoryPanel(BOOL auto_open = TRUE);
180	
181	static void openInventoryPanelAndSetSelection(BOOL auto_open, const LLUUID& obj_id);
182
183protected:
184	void openStartFolderOrMyInventory(); // open the first level of inventory
185	void onItemsCompletion();			// called when selected items are complete
186
187	LLInventoryModel*			mInventory;
188	LLInventoryObserver*		mInventoryObserver;
189	LLInvPanelComplObserver*	mCompletionObserver;
190	BOOL						mAcceptsDragAndDrop;
191	BOOL 						mAllowMultiSelect;
192	BOOL 						mShowItemLinkOverlays; // Shows link graphic over inventory item icons
193	BOOL						mShowEmptyMessage;
194	BOOL						mShowLoadStatus;
195
196	LLFolderView*				mFolderRoot;
197	LLScrollContainer*			mScroller;
198
199	/**
200	 * Pointer to LLInventoryFVBridgeBuilder.
201	 *
202	 * It is set in LLInventoryPanel's constructor and can be overridden in derived classes with 
203	 * another implementation.
204	 * Take into account it will not be deleted by LLInventoryPanel itself.
205	 */
206	const LLInventoryFVBridgeBuilder* mInvFVBridgeBuilder;
207
208
209	//--------------------------------------------------------------------
210	// Sorting
211	//--------------------------------------------------------------------
212public:
213	static const std::string DEFAULT_SORT_ORDER;
214	static const std::string RECENTITEMS_SORT_ORDER;
215	static const std::string INHERIT_SORT_ORDER;
216	
217	void setSortOrder(U32 order);
218	U32 getSortOrder() const;
219	void requestSort();
220
221private:
222	std::string					mSortOrderSetting;
223
224	//--------------------------------------------------------------------
225	// Hidden folders
226	//--------------------------------------------------------------------
227public:
228	void addHideFolderType(LLFolderType::EType folder_type);
229
230public:
231	BOOL 				getIsViewsInitialized() const { return mViewsInitialized; }
232	const LLUUID&		getRootFolderID() const;
233protected:
234	// Builds the UI.  Call this once the inventory is usable.
235	void 				initializeViews();
236	LLFolderViewItem*	rebuildViewsFor(const LLUUID& id); // Given the id and the parent, build all of the folder views.
237
238	virtual void		buildFolderView(const LLInventoryPanel::Params& params);
239	LLFolderViewItem*	buildNewViews(const LLUUID& id);
240	BOOL				getIsHiddenFolderType(LLFolderType::EType folder_type) const;
241	
242	virtual LLFolderView*		createFolderView(LLInvFVBridge * bridge, bool useLabelSuffix);
243	virtual LLFolderViewFolder*	createFolderViewFolder(LLInvFVBridge * bridge);
244	virtual LLFolderViewItem*	createFolderViewItem(LLInvFVBridge * bridge);
245private:
246	BOOL				mBuildDefaultHierarchy; // default inventory hierarchy should be created in postBuild()
247	BOOL				mViewsInitialized; // Views have been generated
248	// UUID of category from which hierarchy should be built.  Set with the 
249	// "start_folder" xml property.  Default is LLUUID::null that means total Inventory hierarchy. 
250	LLUUID				mStartFolderID;
251};
252
253#endif // LL_LLINVENTORYPANEL_H