llpaneldirbrowser.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /**
  2. * @file llpaneldirbrowser.h
  3. * @brief LLPanelDirBrowser class definition
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. // Base class for the various search panels/results browsers in the Search
  33. // floater. For example, Search > Places is derived from this.
  34. #ifndef LL_LLPANELDIRBROWSER_H
  35. #define LL_LLPANELDIRBROWSER_H
  36. #include "llframetimer.h"
  37. #include "llpanel.h"
  38. class LLButton;
  39. class LLCheckBoxCtrl;
  40. class HBFloaterSearch;
  41. class LLMessageSystem;
  42. class LLScrollListCtrl;
  43. class LLPanelDirBrowser: public LLPanel
  44. {
  45. protected:
  46. LOG_CLASS(LLPanelDirBrowser);
  47. public:
  48. LLPanelDirBrowser(const std::string& name, HBFloaterSearch* floater);
  49. virtual ~LLPanelDirBrowser();
  50. virtual bool postBuild();
  51. // Use to get periodic updates.
  52. virtual void draw();
  53. virtual void onVisibilityChange(bool curVisibilityIn);
  54. // Redo your search for the prev/next page of results
  55. virtual void prevPage();
  56. virtual void nextPage();
  57. void resetSearchStart();
  58. // Do the current query (used by prevPage/nextPage)
  59. virtual void performQuery() {}
  60. LL_INLINE const LLUUID& getSearchID() const { return mSearchID; }
  61. // Select the line in the scroll list control with this ID, either now or
  62. // when data arrives from the server.
  63. void selectByUUID(const LLUUID& id);
  64. void selectEventByID(S32 event_id);
  65. U32 getSelectedEventID() const;
  66. void getSelectedInfo(LLUUID* id, S32* type);
  67. // 'type' is EVENT_CODE, PLACE_CODE, etc. from below. 'item_id' is integer
  68. // for events, UUID for all others.
  69. void showDetailPanel(S32 type, LLSD item_id);
  70. // From llpaneldirbase
  71. void setupNewSearch();
  72. // Default handler for clicking the search button resets the next/previous
  73. // state and performs the query. Expects a pointer to an LLPanelDirBrowser
  74. // object.
  75. static void onClickSearchCore(void* userdata);
  76. // 'query_start' indicates the first result row to return, usually 0 or 100
  77. // or 200 because the searches return a max of 100 rows
  78. static void sendDirFindQuery(LLMessageSystem* msg, const LLUUID& query_id,
  79. const std::string& text, U32 flags,
  80. S32 query_start);
  81. void newClassified();
  82. // Prev/Next page buttons
  83. static void onClickNext(void* data);
  84. static void onClickPrev(void* data);
  85. static void onCommitList(LLUICtrl* ctrl, void* data);
  86. static void processDirPeopleReply(LLMessageSystem* msg, void**);
  87. static void processDirPlacesReply(LLMessageSystem* msg, void**);
  88. static void processDirEventsReply(LLMessageSystem* msg, void**);
  89. static void processDirGroupsReply(LLMessageSystem* msg, void**);
  90. static void processDirClassifiedReply(LLMessageSystem* msg, void**);
  91. static void processDirLandReply(LLMessageSystem* msg, void**);
  92. std::string filterShortWords(const std::string source_str,
  93. S32 shortest_word_length, bool& was_filtered);
  94. // Logic to control maturity checkboxes in Classified/Events/Places/
  95. // "Land for Sale" tabs.
  96. void updateMaturityCheckbox(bool force = false);
  97. protected:
  98. void updateResultCount();
  99. void addClassified(LLScrollListCtrl* listp, const LLUUID& classified_id,
  100. const std::string& name, U32 creation_date,
  101. S32 price_for_listing);
  102. LLSD createLandSale(const LLUUID& parcel_id, bool is_auction,
  103. bool is_for_sale, const std::string& name, S32* type);
  104. static void onSearchEdit(const std::string& text, void* data);
  105. // If this is a search for a panel like "people_panel" (and not the "all"
  106. // panel) optionally show the "Next" button. Return the actual number of
  107. // rows to display.
  108. S32 showNextButton(S32 rows);
  109. protected:
  110. HBFloaterSearch* mFloaterSearch;
  111. LLCheckBoxCtrl* mIncAdultCheck;
  112. LLCheckBoxCtrl* mIncMatureCheck;
  113. LLCheckBoxCtrl* mIncPGCheck;
  114. LLButton* mPrevButton;
  115. LLButton* mNextButton;
  116. LLScrollListCtrl* mResultsList;
  117. LLUUID mSearchID; // Unique ID for a pending search
  118. LLUUID mWantSelectID; // scroll item to select on arrival
  119. std::string mCurrentSortColumn;
  120. // Some searches return a max of 100 items per page, so we can start the
  121. // search from the 100th item rather than the 0th, etc.
  122. S32 mSearchStart;
  123. // Places is 100 per page, events is 200 per page
  124. S32 mResultsPerPage;
  125. S32 mResultsReceived;
  126. U32 mMinSearchChars;
  127. LLFrameTimer mLastResultTimer;
  128. bool mCurrentSortAscending;
  129. bool mHaveSearchResults;
  130. bool mDidAutoSelect;
  131. bool mLastWantPGOnly;
  132. bool mLastCanAccessMature;
  133. bool mLastCanAccessAdult;
  134. LLSD mResultsContents;
  135. std::string mControlNameAdult;
  136. std::string mControlNameMature;
  137. std::string mControlNamePG;
  138. typedef fast_hmap<LLUUID, LLPanelDirBrowser*> instances_map_t;
  139. static instances_map_t sInstances;
  140. };
  141. // Codes used for sorting by type.
  142. constexpr S32 INVALID_CODE = -1;
  143. constexpr S32 EVENT_CODE = 0;
  144. constexpr S32 PLACE_CODE = 1;
  145. #if 0 // We no longer show online vs. offline in search result icons.
  146. constexpr S32 ONLINE_CODE = 2;
  147. constexpr S32 OFFLINE_CODE = 3;
  148. #endif
  149. constexpr S32 AVATAR_CODE = 3;
  150. constexpr S32 GROUP_CODE = 4;
  151. constexpr S32 CLASSIFIED_CODE = 5;
  152. constexpr S32 FOR_SALE_CODE = 6; // For sale place
  153. constexpr S32 AUCTION_CODE = 7; // For auction place
  154. constexpr S32 POPULAR_CODE = 8; // Popular by dwell
  155. // Mask values for search flags
  156. // Should try not to send this to the search engine:
  157. constexpr S32 SEARCH_NONE = 0;
  158. constexpr S32 SEARCH_PG = 1;
  159. constexpr S32 SEARCH_MATURE = 2;
  160. constexpr S32 SEARCH_ADULT = 4;
  161. #endif // LL_LLPANELDIRBROWSER_H