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