llpaneldirplaces.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * @file llpaneldirplaces.cpp
  3. * @brief "Places" panel in the Search floater
  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 "llpaneldirplaces.h"
  34. #include "llcheckboxctrl.h"
  35. #include "llnotifications.h"
  36. #include "llparcel.h"
  37. #include "llqueryflags.h"
  38. #include "llregionflags.h"
  39. #include "llmessage.h"
  40. #include "llagent.h"
  41. #include "hbfloatersearch.h"
  42. #include "llpaneldirbrowser.h"
  43. #include "llviewercontrol.h"
  44. #include "llworldmap.h"
  45. LLPanelDirPlaces::LLPanelDirPlaces(const std::string& name,
  46. HBFloaterSearch* floater)
  47. : LLPanelDirBrowser(name, floater)
  48. {
  49. mMinSearchChars = 3;
  50. }
  51. bool LLPanelDirPlaces::postBuild()
  52. {
  53. LLPanelDirBrowser::postBuild();
  54. mSearchEditor = getChild<LLSearchEditor>("search_text");
  55. mSearchEditor->setSearchCallback(onSearchEdit, this);
  56. childSetAction("search_btn", onClickSearchCore, this);
  57. childDisable("search_btn");
  58. mCurrentSortColumn = "dwell";
  59. mCurrentSortAscending = false;
  60. // Don't prepopulate the places list, as it hurts the database as of
  61. // 2006-12-04. JC
  62. //initialQuery();
  63. return true;
  64. }
  65. //virtual
  66. void LLPanelDirPlaces::draw()
  67. {
  68. updateMaturityCheckbox();
  69. LLPanelDirBrowser::draw();
  70. }
  71. //virtual
  72. void LLPanelDirPlaces::performQuery()
  73. {
  74. std::string place_name = mSearchEditor->getText();
  75. if (place_name.length() < mMinSearchChars)
  76. {
  77. return;
  78. }
  79. // "hi " is three chars but not a long-enough search
  80. std::string query_string = place_name;
  81. LLStringUtil::trim(query_string);
  82. bool query_was_filtered = (query_string != place_name);
  83. // Possible we threw away all the short words in the query so check length
  84. if (query_string.length() < mMinSearchChars)
  85. {
  86. gNotifications.add("SeachFilteredOnShortWordsEmpty");
  87. return;
  88. }
  89. // If we filtered something out, display a popup
  90. if (query_was_filtered)
  91. {
  92. LLSD args;
  93. args["FINALQUERY"] = query_string;
  94. gNotifications.add("SeachFilteredOnShortWords", args);
  95. }
  96. std::string catstring = childGetValue("Category").asString();
  97. // Because LLParcel::C_ANY is -1, must do special check
  98. S32 category = 0;
  99. if (catstring == "any")
  100. {
  101. category = LLParcel::C_ANY;
  102. }
  103. else
  104. {
  105. category = LLParcel::getCategoryFromString(catstring);
  106. }
  107. bool inc_pg = !mIncPGCheck || mIncPGCheck->getValue().asBoolean();
  108. bool inc_mature = mIncMatureCheck &&
  109. mIncMatureCheck->getValue().asBoolean();
  110. bool inc_adult = mIncAdultCheck && mIncAdultCheck->getValue().asBoolean();
  111. U32 flags = 0x0;
  112. if (inc_pg) flags |= DFQ_INC_PG;
  113. if (inc_mature) flags |= DFQ_INC_MATURE;
  114. if (inc_adult) flags |= DFQ_INC_ADULT;
  115. // Pack old query flag in case we are talking to an old server
  116. if ((flags & DFQ_INC_PG) == DFQ_INC_PG &&
  117. (flags & DFQ_INC_MATURE) != DFQ_INC_MATURE)
  118. {
  119. flags |= DFQ_PG_PARCELS_ONLY;
  120. }
  121. if (flags == 0x0)
  122. {
  123. gNotifications.add("NoContentToSearch");
  124. return;
  125. }
  126. queryCore(query_string, category, flags);
  127. }
  128. void LLPanelDirPlaces::initialQuery()
  129. {
  130. // All Linden locations in PG/Mature sims, any name.
  131. U32 flags = DFQ_INC_PG | DFQ_INC_MATURE;
  132. queryCore(LLStringUtil::null, LLParcel::C_LINDEN, flags);
  133. }
  134. void LLPanelDirPlaces::queryCore(const std::string& name, S32 category,
  135. U32 flags)
  136. {
  137. setupNewSearch();
  138. // JC: Sorting by dwell severely impacts the performance of the query.
  139. // Instead of sorting on the dataserver, we sort locally once the results
  140. // are received.
  141. // IW: Re-enabled dwell sort based on new 3-character minimum description
  142. flags |= DFQ_DWELL_SORT;
  143. LLMessageSystem* msg = gMessageSystemp;
  144. msg->newMessage("DirPlacesQuery");
  145. msg->nextBlock("AgentData");
  146. msg->addUUID("AgentID", gAgentID);
  147. msg->addUUID("SessionID", gAgentSessionID);
  148. msg->nextBlock("QueryData");
  149. msg->addUUID("QueryID", getSearchID());
  150. msg->addString("QueryText", name);
  151. msg->addU32("QueryFlags", flags);
  152. msg->addS8("Category", (S8)category);
  153. // No longer support queries by region name, too many regions
  154. // for combobox, no easy way to do autocomplete. JC
  155. msg->addString("SimName", "");
  156. msg->addS32Fast(_PREHASH_QueryStart, mSearchStart);
  157. gAgent.sendReliableMessage();
  158. }