PageRenderTime 42ms CodeModel.GetById 1ms app.highlight 36ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llinventoryfilter.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 221 lines | 136 code | 34 blank | 51 comment | 0 complexity | a1de81646a1e7511e79b03336d60ff36 MD5 | raw file
  1/** 
  2* @file llinventoryfilter.h
  3* @brief Support for filtering your inventory to only display a subset of the
  4* available items.
  5*
  6* $LicenseInfo:firstyear=2005&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 LLINVENTORYFILTER_H
 28#define LLINVENTORYFILTER_H
 29
 30#include "llinventorytype.h"
 31#include "llpermissionsflags.h"
 32
 33class LLFolderViewItem;
 34class LLFolderViewFolder;
 35
 36class LLInventoryFilter
 37{
 38public:
 39	enum EFolderShow
 40	{
 41		SHOW_ALL_FOLDERS,
 42		SHOW_NON_EMPTY_FOLDERS,
 43		SHOW_NO_FOLDERS
 44	};
 45
 46	enum EFilterBehavior
 47	{
 48		FILTER_NONE,				// nothing to do, already filtered
 49		FILTER_RESTART,				// restart filtering from scratch
 50		FILTER_LESS_RESTRICTIVE,	// existing filtered items will certainly pass this filter
 51		FILTER_MORE_RESTRICTIVE		// if you didn't pass the previous filter, you definitely won't pass this one
 52	};
 53
 54	enum EFilterType	{
 55		FILTERTYPE_NONE = 0,
 56		FILTERTYPE_OBJECT = 0x1 << 0,	// normal default search-by-object-type
 57		FILTERTYPE_CATEGORY = 0x1 << 1,	// search by folder type
 58		FILTERTYPE_UUID	= 0x1 << 2,		// find the object with UUID and any links to it
 59		FILTERTYPE_DATE = 0x1 << 3,		// search by date range
 60		FILTERTYPE_WEARABLE = 0x1 << 4,	// search by wearable type
 61		FILTERTYPE_EMPTYFOLDERS = 0x1 << 5	// pass if folder is not a system folder to be hidden if empty
 62	};
 63
 64	enum EFilterLink
 65	{
 66		FILTERLINK_INCLUDE_LINKS,	// show links too
 67		FILTERLINK_EXCLUDE_LINKS,	// don't show links
 68		FILTERLINK_ONLY_LINKS		// only show links
 69	};
 70
 71	enum ESortOrderType
 72	{
 73		SO_NAME = 0,						// Sort inventory by name
 74		SO_DATE = 0x1,						// Sort inventory by date
 75		SO_FOLDERS_BY_NAME = 0x1 << 1,		// Force folder sort by name
 76		SO_SYSTEM_FOLDERS_TO_TOP = 0x1 << 2	// Force system folders to be on top
 77	};
 78
 79	LLInventoryFilter(const std::string& name);
 80	virtual ~LLInventoryFilter();
 81
 82	// +-------------------------------------------------------------------+
 83	// + Parameters
 84	// +-------------------------------------------------------------------+
 85	void 				setFilterObjectTypes(U64 types);
 86	U64 				getFilterObjectTypes() const;
 87	U64					getFilterCategoryTypes() const;
 88	BOOL 				isFilterObjectTypesWith(LLInventoryType::EType t) const;
 89	void 				setFilterCategoryTypes(U64 types);
 90	void 				setFilterUUID(const LLUUID &object_id);
 91	void				setFilterWearableTypes(U64 types);
 92	void				setFilterEmptySystemFolders();
 93	void				updateFilterTypes(U64 types, U64& current_types);
 94
 95	void 				setFilterSubString(const std::string& string);
 96	const std::string& 	getFilterSubString(BOOL trim = FALSE) const;
 97	const std::string& 	getFilterSubStringOrig() const { return mFilterSubStringOrig; } 
 98	BOOL 				hasFilterString() const;
 99
100	void 				setFilterPermissions(PermissionMask perms);
101	PermissionMask 		getFilterPermissions() const;
102
103	void 				setDateRange(time_t min_date, time_t max_date);
104	void 				setDateRangeLastLogoff(BOOL sl);
105	time_t 				getMinDate() const;
106	time_t 				getMaxDate() const;
107
108	void 				setHoursAgo(U32 hours);
109	U32 				getHoursAgo() const;
110
111	void 				setFilterLinks(U64 filter_link);
112	U64					getFilterLinks() const;
113
114	// +-------------------------------------------------------------------+
115	// + Execution And Results
116	// +-------------------------------------------------------------------+
117	BOOL 				check(const LLFolderViewItem* item);
118	bool				checkFolder(const LLFolderViewFolder* folder);
119	BOOL 				checkAgainstFilterType(const LLFolderViewItem* item) const;
120	BOOL 				checkAgainstPermissions(const LLFolderViewItem* item) const;
121	BOOL 				checkAgainstFilterLinks(const LLFolderViewItem* item) const;
122
123	std::string::size_type getStringMatchOffset() const;
124
125	// +-------------------------------------------------------------------+
126	// + Presentation
127	// +-------------------------------------------------------------------+
128	void 				setShowFolderState( EFolderShow state);
129	EFolderShow 		getShowFolderState() const;
130
131	void 				setSortOrder(U32 order);
132	U32 				getSortOrder() const;
133
134	void 				setEmptyLookupMessage(const std::string& message);
135	const std::string&	getEmptyLookupMessage() const;
136
137	// +-------------------------------------------------------------------+
138	// + Status
139	// +-------------------------------------------------------------------+
140	BOOL 				isActive() const;
141	BOOL 				isModified() const;
142	BOOL 				isModifiedAndClear();
143	BOOL 				isSinceLogoff() const;
144	void 				clearModified();
145	const std::string& 	getName() const;
146	const std::string& 	getFilterText();
147	//RN: this is public to allow system to externally force a global refilter
148	void 				setModified(EFilterBehavior behavior = FILTER_RESTART);
149
150	// +-------------------------------------------------------------------+
151	// + Count
152	// +-------------------------------------------------------------------+
153	void 				setFilterCount(S32 count);
154	S32 				getFilterCount() const;
155	void 				decrementFilterCount();
156
157	// +-------------------------------------------------------------------+
158	// + Default
159	// +-------------------------------------------------------------------+
160	BOOL 				isNotDefault() const;
161	void 				markDefault();
162	void 				resetDefault();
163
164	// +-------------------------------------------------------------------+
165	// + Generation
166	// +-------------------------------------------------------------------+
167	S32 				getCurrentGeneration() const;
168	S32 				getMinRequiredGeneration() const;
169	S32 				getMustPassGeneration() const;
170
171	// +-------------------------------------------------------------------+
172	// + Conversion
173	// +-------------------------------------------------------------------+
174	void 				toLLSD(LLSD& data) const;
175	void 				fromLLSD(LLSD& data);
176
177private:
178	struct FilterOps
179	{
180		FilterOps();
181		U32 			mFilterTypes;
182
183		U64				mFilterObjectTypes; // For _OBJECT
184		U64				mFilterWearableTypes;
185		U64				mFilterCategoryTypes; // For _CATEGORY
186		LLUUID      	mFilterUUID; // for UUID
187
188		time_t			mMinDate;
189		time_t			mMaxDate;
190		U32				mHoursAgo;
191		EFolderShow		mShowFolderState;
192		PermissionMask	mPermissions;
193		U64				mFilterLinks;
194	};
195
196	U32						mOrder;
197	U32 					mLastLogoff;
198
199	FilterOps				mFilterOps;
200	FilterOps				mDefaultFilterOps;
201
202	std::string::size_type	mSubStringMatchOffset;
203	std::string				mFilterSubString;
204	std::string				mFilterSubStringOrig;
205	const std::string		mName;
206
207	S32						mFilterGeneration;
208	S32						mMustPassGeneration;
209	S32						mMinRequiredGeneration;
210	S32						mNextFilterGeneration;
211
212	S32						mFilterCount;
213	EFilterBehavior 		mFilterBehavior;
214
215	BOOL 					mModified;
216	BOOL 					mNeedTextRebuild;
217	std::string 			mFilterText;
218	std::string 			mEmptyLookupMessage;
219};
220
221#endif