llpaneldirland.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /**
  2. * @file llpaneldirland.cpp
  3. * @brief Land For Sale and Auction in the Find directory.
  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. #include "llviewerprecompiledheaders.h"
  33. #include "llpaneldirland.h"
  34. #include "llcheckboxctrl.h"
  35. #include "lllineeditor.h"
  36. #include "llnotifications.h"
  37. #include "llparcel.h"
  38. #include "llqueryflags.h"
  39. #include "llscrolllistctrl.h"
  40. #include "llmessage.h"
  41. #include "llagent.h"
  42. #include "llstatusbar.h"
  43. #include "llviewercontrol.h"
  44. //-----------------------------------------------------------------------------
  45. // Constants
  46. //-----------------------------------------------------------------------------
  47. static const char FIND_AUCTION[] = "Auction";
  48. static const char FIND_MAINLANDSALES[] = "Mainland Sales";
  49. static const char FIND_ESTATESALES[] = "Estate Sales";
  50. LLPanelDirLand::LLPanelDirLand(const std::string& name,
  51. HBFloaterSearch* floater)
  52. : LLPanelDirBrowser(name, floater)
  53. {
  54. }
  55. bool LLPanelDirLand::postBuild()
  56. {
  57. LLPanelDirBrowser::postBuild();
  58. childSetValue("type", gSavedSettings.getString("FindLandType"));
  59. childSetCommitCallback("pricecheck", onCommitPrice, this);
  60. childSetCommitCallback("areacheck", onCommitArea, this);
  61. childSetValue("priceedit", gStatusBarp->getBalance());
  62. childSetEnabled("priceedit", gSavedSettings.getBool("FindLandPrice"));
  63. childSetPrevalidate("priceedit", LLLineEditor::prevalidateNonNegativeS32);
  64. childSetEnabled("areaedit", gSavedSettings.getBool("FindLandArea"));
  65. childSetPrevalidate("areaedit", LLLineEditor::prevalidateNonNegativeS32);
  66. childSetAction("search_btn", onClickSearchCore, this);
  67. setDefaultBtn("search_btn");
  68. mCurrentSortColumn = "per_meter";
  69. LLScrollListCtrl* results = getChild<LLScrollListCtrl>("results");
  70. if (results)
  71. {
  72. results->setSortChangedCallback(onClickSort);
  73. results->sortByColumn(mCurrentSortColumn,mCurrentSortAscending);
  74. }
  75. return true;
  76. }
  77. LLPanelDirLand::~LLPanelDirLand()
  78. {
  79. // Children all cleaned up by default view destructor.
  80. }
  81. // virtual
  82. void LLPanelDirLand::draw()
  83. {
  84. updateMaturityCheckbox();
  85. LLPanelDirBrowser::draw();
  86. }
  87. void LLPanelDirLand::onClickSort(void* data)
  88. {
  89. LLPanelDirLand* self = (LLPanelDirLand*)data;
  90. if (!self) return;
  91. self->performQuery();
  92. }
  93. // static
  94. void LLPanelDirLand::onCommitPrice(LLUICtrl* ctrl, void* data)
  95. {
  96. LLPanelDirLand* self = (LLPanelDirLand*)data;
  97. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  98. if (!self || !check) return;
  99. self->childSetEnabled("priceedit", check->get());
  100. }
  101. // static
  102. void LLPanelDirLand::onCommitArea(LLUICtrl* ctrl, void* data)
  103. {
  104. LLPanelDirLand* self = (LLPanelDirLand*)data;
  105. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  106. if (!self || !check) return;
  107. self->childSetEnabled("areaedit", check->get());
  108. }
  109. void LLPanelDirLand::performQuery()
  110. {
  111. bool inc_pg = !mIncPGCheck || mIncPGCheck->getValue().asBoolean();
  112. bool inc_mature = mIncMatureCheck && mIncMatureCheck->getValue().asBoolean();
  113. bool inc_adult = mIncAdultCheck && mIncAdultCheck->getValue().asBoolean();
  114. if (!(inc_pg || inc_mature || inc_adult))
  115. {
  116. gNotifications.add("NoContentToSearch");
  117. return;
  118. }
  119. setupNewSearch();
  120. // We could change the UI to allow arbitrary combinations of these options
  121. U32 search_type = ST_ALL;
  122. const std::string& type = childGetValue("type").asString();
  123. if(!type.empty())
  124. {
  125. if (FIND_AUCTION == type) search_type = ST_AUCTION;
  126. else if(FIND_MAINLANDSALES == type) search_type = ST_MAINLAND;
  127. else if(FIND_ESTATESALES == type) search_type = ST_ESTATE;
  128. }
  129. U32 query_flags = 0x0;
  130. if (gAgent.wantsPGOnly()) query_flags |= DFQ_PG_SIMS_ONLY;
  131. bool adult_enabled = gAgent.canAccessAdult();
  132. bool mature_enabled = gAgent.canAccessMature();
  133. if (inc_pg)
  134. {
  135. query_flags |= DFQ_INC_PG;
  136. }
  137. if (inc_mature && mature_enabled)
  138. {
  139. query_flags |= DFQ_INC_MATURE;
  140. }
  141. if (inc_adult && adult_enabled)
  142. {
  143. query_flags |= DFQ_INC_ADULT;
  144. }
  145. // Add old flags in case we are talking to an old dataserver
  146. if (inc_pg && !inc_mature)
  147. {
  148. query_flags |= DFQ_PG_SIMS_ONLY;
  149. }
  150. if (!inc_pg && inc_mature)
  151. {
  152. query_flags |= DFQ_MATURE_SIMS_ONLY;
  153. }
  154. LLScrollListCtrl* list = getChild<LLScrollListCtrl>("results");
  155. if (list)
  156. {
  157. std::string sort_name = list->getSortColumnName();
  158. if (sort_name == "name")
  159. {
  160. query_flags |= DFQ_NAME_SORT;
  161. }
  162. else if (sort_name == "price")
  163. {
  164. query_flags |= DFQ_PRICE_SORT;
  165. }
  166. else if (sort_name == "per_meter")
  167. {
  168. query_flags |= DFQ_PER_METER_SORT;
  169. }
  170. else if (sort_name == "area")
  171. {
  172. query_flags |= DFQ_AREA_SORT;
  173. }
  174. if (list->getSortAscending())
  175. {
  176. query_flags |= DFQ_SORT_ASC;
  177. }
  178. }
  179. if (childGetValue("pricecheck").asBoolean())
  180. {
  181. query_flags |= DFQ_LIMIT_BY_PRICE;
  182. }
  183. if (childGetValue("areacheck").asBoolean())
  184. {
  185. query_flags |= DFQ_LIMIT_BY_AREA;
  186. }
  187. LLMessageSystem* msg = gMessageSystemp;
  188. msg->newMessage("DirLandQuery");
  189. msg->nextBlock("AgentData");
  190. msg->addUUID("AgentID", gAgentID);
  191. msg->addUUID("SessionID", gAgentSessionID);
  192. msg->nextBlock("QueryData");
  193. msg->addUUID("QueryID", getSearchID());
  194. msg->addU32("QueryFlags", query_flags);
  195. msg->addU32("SearchType", search_type);
  196. msg->addS32("Price", childGetValue("priceedit").asInteger());
  197. msg->addS32("Area", childGetValue("areaedit").asInteger());
  198. msg->addS32Fast(_PREHASH_QueryStart, mSearchStart);
  199. gAgent.sendReliableMessage();
  200. }