llpanelgrouproles.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. /**
  2. * @file llpanelgrouproles.h
  3. * @brief Panel for roles information about a particular group.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-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. #ifndef LL_LLPANELGROUPROLES_H
  33. #define LL_LLPANELGROUPROLES_H
  34. #include "llpanelgroup.h"
  35. class LLCheckBoxCtrl;
  36. class LLNameListCtrl;
  37. class LLPanelGroupActionsSubTab;
  38. class LLPanelGroupMembersSubTab;
  39. class LLPanelGroupRolesSubTab;
  40. class LLPanelGroupSubTab;
  41. class LLScrollListCtrl;
  42. class LLScrollListItem;
  43. class LLTextBox;
  44. class LLTextEditor;
  45. class LLTimer;
  46. typedef std::map<std::string, std::string> icon_map_t;
  47. class LLPanelGroupRoles : public LLPanelGroupTab,
  48. public LLPanelGroupTabObserver
  49. {
  50. protected:
  51. LOG_CLASS(LLPanelGroupRoles);
  52. public:
  53. LLPanelGroupRoles(const std::string& name, const LLUUID& group_id);
  54. ~LLPanelGroupRoles() override;
  55. // Allow sub tabs to ask for sibling controls.
  56. friend class LLPanelGroupMembersSubTab;
  57. friend class LLPanelGroupRolesSubTab;
  58. friend class LLPanelGroupActionsSubTab;
  59. bool postBuild() override;
  60. bool isVisibleByAgent() override;
  61. static void* createTab(void* data);
  62. static void onClickSubTab(void*,bool);
  63. void handleClickSubTab();
  64. // Checks if the current tab needs to be applied, and tries to switch to
  65. // the requested tab.
  66. bool attemptTransition();
  67. // Switches to the requested tab (will close() if requested is NULL)
  68. void transitionToTab();
  69. // Used by attemptTransition to query the user's response to a tab that
  70. // needs to apply.
  71. bool handleNotifyCallback(const LLSD& notification, const LLSD& response);
  72. bool onModalClose(const LLSD& notification, const LLSD& response);
  73. // Most of these messages are just passed on to the current sub-tab.
  74. std::string getHelpText() const override;
  75. void activate() override;
  76. void deactivate() override;
  77. bool needsApply(std::string& mesg) override;
  78. bool hasModal() override;
  79. bool apply(std::string& mesg) override;
  80. void cancel() override;
  81. void update(LLGroupChange gc) override;
  82. // PanelGroupTab observer trigger
  83. void tabChanged() override;
  84. protected:
  85. LLPanelGroupTab* mCurrentTab;
  86. LLPanelGroupTab* mRequestedTab;
  87. LLTabContainer* mSubTabContainer;
  88. bool mIgnoreTransition;
  89. std::string mDefaultNeedsApplyMesg;
  90. std::string mWantApplyMesg;
  91. };
  92. class LLPanelGroupSubTab : public LLPanelGroupTab
  93. {
  94. protected:
  95. LOG_CLASS(LLPanelGroupSubTab);
  96. public:
  97. LLPanelGroupSubTab(const std::string& name, const LLUUID& group_id);
  98. bool postBuild() override;
  99. // This allows sub-tabs to collect child widgets from a higher level in the
  100. // view hierarchy.
  101. virtual bool postBuildSubTab(LLView* root) { return true; }
  102. static void onSearchKeystroke(LLLineEditor* caller, void* user_data);
  103. void handleSearchKeystroke(LLLineEditor* caller);
  104. static void onClickSearch(void*);
  105. void handleClickSearch();
  106. static void onClickShowAll(void*);
  107. void handleClickShowAll();
  108. void setSearchFilter(const std::string& filter);
  109. void activate() override;
  110. void deactivate() override;
  111. // Helper functions
  112. bool matchesActionSearchFilter(std::string action);
  113. void buildActionsList(LLScrollListCtrl* ctrl, U64 allowed_by_some,
  114. U64 allowed_by_all, icon_map_t& icons,
  115. void (*commit_callback)(LLUICtrl*, void*),
  116. bool show_all, bool filter, bool is_owner_role);
  117. void buildActionCategory(LLScrollListCtrl* ctrl, U64 allowed_by_some,
  118. U64 allowed_by_all, LLRoleActionSet* action_set,
  119. icon_map_t& icons,
  120. void (*commit_callback)(LLUICtrl*, void*),
  121. bool show_all, bool filter, bool is_owner_role);
  122. void setFooterEnabled(bool enable);
  123. protected:
  124. void setOthersVisible(bool b);
  125. protected:
  126. LLPanel* mHeader;
  127. LLPanel* mFooter;
  128. LLLineEditor* mSearchLineEditor;
  129. LLButton* mSearchButton;
  130. LLButton* mShowAllButton;
  131. // Used to communicate between action sets due to the dependency between
  132. // GP_GROUP_BAN_ACCESS and GP_EJECT_MEMBER and GP_ROLE_REMOVE_MEMBER
  133. bool mHasGroupBanPower;
  134. std::string mSearchFilter;
  135. icon_map_t mActionIcons;
  136. };
  137. class LLPanelGroupMembersSubTab final : public LLPanelGroupSubTab
  138. {
  139. protected:
  140. LOG_CLASS(LLPanelGroupMembersSubTab);
  141. public:
  142. LLPanelGroupMembersSubTab(const std::string& name, const LLUUID& group_id);
  143. bool postBuildSubTab(LLView* root) override;
  144. static void* createTab(void* data);
  145. static void onMemberSelect(LLUICtrl*, void*);
  146. void handleMemberSelect();
  147. static void onMemberDoubleClick(void*);
  148. static void onInviteMember(void*);
  149. static void onEjectMembers(void*);
  150. void handleEjectMembers();
  151. static void onRoleCheck(LLUICtrl* check, void* user_data);
  152. void handleRoleCheck(const LLUUID& role_id,
  153. LLRoleMemberChangeType type);
  154. static void onBanMember(void* user_data);
  155. void handleBanMember();
  156. void applyMemberChanges();
  157. bool addOwnerCB(const LLSD& notification, const LLSD& response);
  158. void activate() override;
  159. void deactivate() override;
  160. void cancel() override;
  161. bool needsApply(std::string& mesg) override;
  162. bool apply(std::string& mesg) override;
  163. void update(LLGroupChange gc) override;
  164. void updateMembers();
  165. void draw() override;
  166. protected:
  167. typedef fast_hmap<LLUUID, LLRoleMemberChangeType> role_change_data_map_t;
  168. typedef fast_hmap<LLUUID,
  169. role_change_data_map_t*> member_role_changes_map_t;
  170. bool matchesSearchFilter(std::string fullname);
  171. U64 getAgentPowersBasedOnRoleChanges(const LLUUID& agent_id);
  172. bool getRoleChangeType(const LLUUID& member_id,
  173. const LLUUID& role_id,
  174. LLRoleMemberChangeType& type);
  175. protected:
  176. LLNameListCtrl* mMembersList;
  177. LLScrollListCtrl* mAssignedRolesList;
  178. LLScrollListCtrl* mAllowedActionsList;
  179. LLButton* mEjectBtn;
  180. LLButton* mBanBtn;
  181. LLTimer mUpdateTimer;
  182. F32 mUpdateInterval;
  183. bool mSkipNextUpdate;
  184. bool mPendingMemberUpdate;
  185. bool mChanged;
  186. bool mHasMatch;
  187. member_role_changes_map_t mMemberRoleChangeData;
  188. U32 mNumOwnerAdditions;
  189. LLGroupMgrGroupData::member_list_t::iterator mMemberProgress;
  190. };
  191. class LLPanelGroupRolesSubTab final : public LLPanelGroupSubTab
  192. {
  193. protected:
  194. LOG_CLASS(LLPanelGroupRolesSubTab);
  195. public:
  196. LLPanelGroupRolesSubTab(const std::string& name, const LLUUID& group_id);
  197. bool postBuildSubTab(LLView* root) override;
  198. static void* createTab(void* data);
  199. void activate() override;
  200. void deactivate() override;
  201. bool needsApply(std::string& mesg) override;
  202. bool apply(std::string& mesg) override;
  203. void cancel() override;
  204. bool matchesSearchFilter(std::string rolename, std::string roletitle);
  205. void update(LLGroupChange gc) override;
  206. protected:
  207. static void onRoleSelect(LLUICtrl*, void*);
  208. void handleRoleSelect();
  209. void buildMembersList();
  210. static void onActionCheck(LLUICtrl*, void*);
  211. void handleActionCheck(LLCheckBoxCtrl*, bool force = false);
  212. bool addActionCB(const LLSD& notification, const LLSD& response,
  213. LLCheckBoxCtrl* check);
  214. static void onPropertiesKey(LLLineEditor*, void*);
  215. static void onDescriptionCommit(LLUICtrl*, void*);
  216. static void onDescriptionFocus(LLFocusableElement*, void*);
  217. static void onAssignedMemberDoubleClick(void*);
  218. static void onMemberVisibilityChange(LLUICtrl*, void*);
  219. void handleMemberVisibilityChange(bool value);
  220. static void onCreateRole(void*);
  221. void handleCreateRole();
  222. static void onDeleteRole(void*);
  223. void handleDeleteRole();
  224. void saveRoleChanges();
  225. LLSD createRoleItem(const LLUUID& role_id, std::string name,
  226. std::string title, S32 members);
  227. protected:
  228. LLScrollListCtrl* mRolesList;
  229. LLNameListCtrl* mAssignedMembersList;
  230. LLScrollListCtrl* mAllowedActionsList;
  231. LLLineEditor* mRoleName;
  232. LLLineEditor* mRoleTitle;
  233. LLTextEditor* mRoleDescription;
  234. LLCheckBoxCtrl* mMemberVisibleCheck;
  235. LLButton* mDeleteRoleButton;
  236. LLButton* mCreateRoleButton;
  237. LLUUID mSelectedRole;
  238. std::string mRemoveEveryoneTxt;
  239. bool mFirstOpen;
  240. bool mHasRoleChange;
  241. };
  242. class LLPanelGroupActionsSubTab final : public LLPanelGroupSubTab
  243. {
  244. protected:
  245. LOG_CLASS(LLPanelGroupActionsSubTab);
  246. public:
  247. LLPanelGroupActionsSubTab(const std::string& name, const LLUUID& group_id);
  248. bool postBuildSubTab(LLView* root) override;
  249. static void* createTab(void* data);
  250. void activate() override;
  251. void deactivate() override;
  252. bool needsApply(std::string& mesg) override;
  253. bool apply(std::string& mesg) override;
  254. void update(LLGroupChange gc) override;
  255. protected:
  256. static void onActionSelect(LLUICtrl*, void*);
  257. void handleActionSelect();
  258. protected:
  259. LLScrollListCtrl* mActionList;
  260. LLScrollListCtrl* mActionRoles;
  261. LLNameListCtrl* mActionMembers;
  262. LLTextEditor* mActionDescription;
  263. };
  264. class LLPanelGroupBanListSubTab final : public LLPanelGroupSubTab
  265. {
  266. protected:
  267. LOG_CLASS(LLPanelGroupBanListSubTab);
  268. public:
  269. LLPanelGroupBanListSubTab(const std::string& name, const LLUUID& group_id);
  270. bool postBuildSubTab(LLView* root) override;
  271. static void* createTab(void* data);
  272. void draw() override;
  273. void activate() override;
  274. void update(LLGroupChange gc) override;
  275. void handleBanEntrySelect();
  276. void handleCreateBanEntry();
  277. void handleDeleteBanEntry();
  278. void handleRefreshBanList();
  279. protected:
  280. void populateBanList();
  281. void setBanCount(S32 count);
  282. static void onBanEntrySelect(LLUICtrl* ctrl, void* user_data);
  283. static void onCreateBanEntry(void* user_data);
  284. static void onDeleteBanEntry(void* user_data);
  285. static void onRefreshBanList(void* user_data);
  286. static void onBanListMemberDoubleClick(void* user_data);
  287. protected:
  288. LLNameListCtrl* mBanList;
  289. LLButton* mCreateBanButton;
  290. LLButton* mDeleteBanButton;
  291. LLButton* mRefreshBanListButton;
  292. LLTextBox* mBanNotSupportedText;
  293. LLTextBox* mBanCountText;
  294. F32 mLastUpdate;
  295. std::string mBanCountString;
  296. };
  297. #endif // LL_LLPANELGROUPROLES_H