llpaneldirgroups.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * @file llpaneldirgroups.cpp
  3. * @brief Groups panel 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 "llpaneldirgroups.h"
  34. #include "llcheckboxctrl.h"
  35. #include "llnotifications.h"
  36. #include "llqueryflags.h"
  37. #include "llmessage.h"
  38. #include "llagent.h"
  39. #include "llviewercontrol.h"
  40. LLPanelDirGroups::LLPanelDirGroups(const std::string& name,
  41. HBFloaterSearch* floater)
  42. : LLPanelDirBrowser(name, floater)
  43. {
  44. mMinSearchChars = 3;
  45. }
  46. bool LLPanelDirGroups::postBuild()
  47. {
  48. LLPanelDirBrowser::postBuild();
  49. mSearchEditor = getChild<LLSearchEditor>("search_text");
  50. mSearchEditor->setSearchCallback(onSearchEdit, this);
  51. childSetAction("search_btn", onClickSearchCore, this);
  52. childDisable("search_btn");
  53. setDefaultBtn("search_btn");
  54. return true;
  55. }
  56. //virtual
  57. void LLPanelDirGroups::draw()
  58. {
  59. updateMaturityCheckbox();
  60. LLPanelDirBrowser::draw();
  61. }
  62. //virtual
  63. void LLPanelDirGroups::performQuery()
  64. {
  65. std::string group_name = mSearchEditor->getText();
  66. if (group_name.length() < mMinSearchChars)
  67. {
  68. return;
  69. }
  70. // "hi " is three chars but not a long-enough search
  71. std::string query_string = group_name;
  72. LLStringUtil::trim(query_string);
  73. bool query_was_filtered = (query_string != group_name);
  74. // Possible we threw away all the short words in the query so check length
  75. if (query_string.length() < mMinSearchChars)
  76. {
  77. gNotifications.add("SeachFilteredOnShortWordsEmpty");
  78. return;
  79. }
  80. bool inc_pg = !mIncPGCheck || mIncPGCheck->getValue().asBoolean();
  81. bool inc_mature = mIncMatureCheck &&
  82. mIncMatureCheck->getValue().asBoolean();
  83. bool inc_adult = mIncAdultCheck && mIncAdultCheck->getValue().asBoolean();
  84. if (!(inc_pg || inc_mature || inc_adult))
  85. {
  86. gNotifications.add("NoContentToSearch");
  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. setupNewSearch();
  97. // Groups
  98. U32 scope = DFQ_GROUPS;
  99. if (inc_pg)
  100. {
  101. scope |= DFQ_INC_PG;
  102. }
  103. if (inc_mature)
  104. {
  105. scope |= DFQ_INC_MATURE;
  106. }
  107. if (inc_adult)
  108. {
  109. scope |= DFQ_INC_ADULT;
  110. }
  111. mCurrentSortColumn = "score";
  112. mCurrentSortAscending = false;
  113. // Send the message
  114. sendDirFindQuery(gMessageSystemp, mSearchID, query_string, scope,
  115. mSearchStart);
  116. }