llpanelexperiencelisteditor.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * @file llpanelexperiencelisteditor.h
  3. * @brief Header file for LLPanelExperienceListEditor
  4. *
  5. * $LicenseInfo:firstyear=2014&license=viewergpl$
  6. *
  7. * Copyright (c) 2014, 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. #ifndef LL_LLPANELEXPERIENCELISTEDITOR_H
  33. #define LL_LLPANELEXPERIENCELISTEDITOR_H
  34. #include <set>
  35. #include "boost/signals2.hpp"
  36. #include "llpanel.h"
  37. #include "lluuid.h"
  38. class LLButton;
  39. class LLFloaterExperiencePicker;
  40. class LLScrollListCtrl;
  41. class LLTextBox;
  42. class LLPanelExperienceListEditor final : public LLPanel
  43. {
  44. public:
  45. typedef boost::signals2::signal<void(const LLUUID&)> list_changed_signal_t;
  46. // Filter function for experiences, return true if the experience should be
  47. // hidden.
  48. typedef boost::function<bool(const LLSD&)> experience_function;
  49. typedef std::vector<experience_function> filter_list;
  50. typedef LLHandle<LLFloaterExperiencePicker> PickerHandle;
  51. LLPanelExperienceListEditor();
  52. ~LLPanelExperienceListEditor() override;
  53. bool postBuild() override;
  54. void loading();
  55. LL_INLINE const uuid_list_t& getExperienceIds() const
  56. {
  57. return mExperienceIds;
  58. }
  59. void setExperienceIds(const LLSD& experience_ids);
  60. void addExperienceIds(const uuid_vec_t& experience_ids);
  61. void addExperience(const LLUUID& id);
  62. boost::signals2::connection setAddedCallback(list_changed_signal_t::slot_type cb);
  63. boost::signals2::connection setRemovedCallback(list_changed_signal_t::slot_type cb);
  64. void setReadonly(bool val = true);
  65. LL_INLINE bool getReadonly() const { return mReadonly; }
  66. void setDisabled(bool val = true);
  67. LL_INLINE bool getDisabled() const { return mDisabled; }
  68. void refreshExperienceCounter();
  69. LL_INLINE void addFilter(experience_function func) { mFilters.push_back(func); }
  70. LL_INLINE void setStickyFunction(experience_function func)
  71. {
  72. mSticky = func;
  73. }
  74. LL_INLINE U32 getMaxExperienceIDs() const { return mMaxExperienceIDs; }
  75. LL_INLINE void setMaxExperienceIDs(U32 val) { mMaxExperienceIDs = val; }
  76. private:
  77. static void onItems(LLUICtrl* ctrl, void* data);
  78. static void onRemove(void* data);
  79. static void onAdd(void* data);
  80. static void onProfile(void* data);
  81. static void checkButtonsEnabled(LLUICtrl*, void* data);
  82. static void experienceDetailsCallback(LLHandle<LLPanelExperienceListEditor> panel,
  83. const LLSD& experience);
  84. void onExperienceDetails(const LLSD& experience);
  85. void processResponse(const LLSD& content);
  86. private:
  87. LLButton* mAdd;
  88. LLButton* mRemove;
  89. LLButton* mProfile;
  90. LLScrollListCtrl* mItems;
  91. LLTextBox* mItemsCount;
  92. PickerHandle mPicker;
  93. LLUUID mKey;
  94. experience_function mSticky;
  95. U32 mMaxExperienceIDs;
  96. list_changed_signal_t mAddedCallback;
  97. list_changed_signal_t mRemovedCallback;
  98. filter_list mFilters;
  99. uuid_list_t mExperienceIds;
  100. bool mReadonly;
  101. bool mDisabled;
  102. bool mListEmpty;
  103. };
  104. #endif //LL_LLPANELEXPERIENCELISTEDITOR_H