llfloaterexperiencepicker.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * @file llfloaterexperiencepicker.h
  3. * @brief Header file for LLFloaterExperiencePicker and LLPanelExperiencePicker
  4. * @author [email protected]
  5. *
  6. * $LicenseInfo:firstyear=2014&license=viewergpl$
  7. *
  8. * Copyright (c) 2014, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LL_LLFLOATEREXPERIENCEPICKER_H
  34. #define LL_LLFLOATEREXPERIENCEPICKER_H
  35. #include "boost/function.hpp"
  36. #include "llavatarnamecache.h"
  37. #include "llfloater.h"
  38. class LLButton;
  39. class LLComboBox;
  40. class LLLineEditor;
  41. class LLScrollListCtrl;
  42. class LLPanelExperiencePicker : public LLPanel
  43. {
  44. friend class LLExperienceSearchResponder;
  45. friend class LLFloaterExperiencePicker;
  46. public:
  47. typedef boost::function<void(const uuid_vec_t&)> select_callback_t;
  48. // filter function for experiences, return true if the experience should
  49. // be hidden.
  50. typedef boost::function<bool(const LLSD&)> filter_function;
  51. typedef std::vector<filter_function> filter_list;
  52. LLPanelExperiencePicker();
  53. bool postBuild() override;
  54. void hideOkCancel();
  55. LL_INLINE void addFilter(filter_function func) { mFilters.push_back(func); }
  56. template <class IT>
  57. LL_INLINE void addFilters(IT begin, IT end)
  58. {
  59. mFilters.insert(mFilters.end(), begin, end);
  60. }
  61. void setDefaultFilters();
  62. bool FilterOverRating(const LLSD& experience);
  63. private:
  64. void closeParent();
  65. void getSelectedExperienceIds(const LLScrollListCtrl* results,
  66. uuid_vec_t& experience_ids);
  67. void setAllowMultiple(bool allow_multiple);
  68. void find();
  69. static void findResults(LLHandle<LLPanelExperiencePicker> handle,
  70. LLUUID query_id, LLSD result);
  71. bool isSelectButtonEnabled();
  72. void processResponse(const LLUUID& query_id, const LLSD& content);
  73. void filterContent();
  74. bool isExperienceHidden(const LLSD& experience) const;
  75. static void onBtnFind(void* data);
  76. static void onBtnSelect(void* data);
  77. static void onBtnClose(void* data);
  78. static void onBtnProfile(void* data);
  79. static void onNextPage(void* data);
  80. static void onPrevPage(void* data);
  81. static void onList(LLUICtrl* ctrl, void* data);
  82. static void onMaturity(LLUICtrl* ctrl, void* data);
  83. static void nameCallback(const LLHandle<LLPanelExperiencePicker>& floater,
  84. const LLUUID& experience_id,
  85. const LLUUID& agent_id,
  86. const LLAvatarName& av_name);
  87. private:
  88. LLButton* mOkBtn;
  89. LLButton* mCancelBtn;
  90. LLButton* mProfileBtn;
  91. LLButton* mNextBtn;
  92. LLButton* mPrevBtn;
  93. LLComboBox* mMaturityCombo;
  94. LLLineEditor* mLineEditor;
  95. LLScrollListCtrl* mSearchResultsList;
  96. S32 mCurrentPage;
  97. LLUUID mQueryID;
  98. select_callback_t mSelectionCallback;
  99. filter_list mFilters;
  100. LLSD mResponse;
  101. bool mCloseOnSelect;
  102. };
  103. class LLFloaterExperiencePicker final : public LLFloater
  104. {
  105. public:
  106. LLFloaterExperiencePicker(const LLUUID& key);
  107. ~LLFloaterExperiencePicker() override;
  108. typedef boost::function<void(const uuid_vec_t&)> select_callback_t;
  109. // Filter function for experiences, return true if the experience should be
  110. // hidden.
  111. typedef boost::function<bool(const LLSD&)> filter_function;
  112. typedef std::vector<filter_function> filter_list;
  113. static LLFloaterExperiencePicker* show(select_callback_t callback,
  114. const LLUUID& key,
  115. bool allow_multiple,
  116. bool close_on_select,
  117. filter_list filters);
  118. private:
  119. static void* createSearchPanel(void* data);
  120. private:
  121. LLUUID mKey;
  122. LLPanelExperiencePicker* mSearchPanel;
  123. typedef fast_hmap<LLUUID, LLFloaterExperiencePicker*> instances_map_t;
  124. static instances_map_t sInstancesMap;
  125. };
  126. #endif // LL_LLFLOATEREXPERIENCEPICKER_H