llpanelgroupgeneral.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:23k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llpanelgroupgeneral.cpp
  3.  * @brief General information about a group.
  4.  *
  5.  * $LicenseInfo:firstyear=2006&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2006-2010, 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 "llpanelgroupgeneral.h"
  34. #include "lluictrlfactory.h"
  35. #include "llagent.h"
  36. #include "roles_constants.h"
  37. // UI elements
  38. #include "llbutton.h"
  39. #include "llcheckboxctrl.h"
  40. #include "llcombobox.h"
  41. #include "lldbstrings.h"
  42. #include "llavataractions.h"
  43. #include "llgroupactions.h"
  44. #include "lllineeditor.h"
  45. #include "llnamebox.h"
  46. #include "llnamelistctrl.h"
  47. #include "llnotificationsutil.h"
  48. #include "llscrolllistitem.h"
  49. #include "llspinctrl.h"
  50. #include "lltextbox.h"
  51. #include "lltexteditor.h"
  52. #include "lltexturectrl.h"
  53. #include "lltrans.h"
  54. #include "llviewerwindow.h"
  55. static LLRegisterPanelClassWrapper<LLPanelGroupGeneral> t_panel_group_general("panel_group_general");
  56. // consts
  57. const S32 MATURE_CONTENT = 1;
  58. const S32 NON_MATURE_CONTENT = 2;
  59. const S32 DECLINE_TO_STATE = 0;
  60. LLPanelGroupGeneral::LLPanelGroupGeneral()
  61. : LLPanelGroupTab(),
  62. mPendingMemberUpdate(FALSE),
  63. mChanged(FALSE),
  64. mFirstUse(TRUE),
  65. mGroupNameEditor(NULL),
  66. mFounderName(NULL),
  67. mInsignia(NULL),
  68. mEditCharter(NULL),
  69. mListVisibleMembers(NULL),
  70. mCtrlShowInGroupList(NULL),
  71. mComboMature(NULL),
  72. mCtrlOpenEnrollment(NULL),
  73. mCtrlEnrollmentFee(NULL),
  74. mSpinEnrollmentFee(NULL),
  75. mCtrlReceiveNotices(NULL),
  76. mCtrlListGroup(NULL),
  77. mActiveTitleLabel(NULL),
  78. mComboActiveTitle(NULL)
  79. {
  80. }
  81. LLPanelGroupGeneral::~LLPanelGroupGeneral()
  82. {
  83. }
  84. BOOL LLPanelGroupGeneral::postBuild()
  85. {
  86. bool recurse = true;
  87. mEditCharter = getChild<LLTextEditor>("charter", recurse);
  88. if(mEditCharter)
  89. {
  90. mEditCharter->setCommitCallback(onCommitAny, this);
  91. mEditCharter->setFocusReceivedCallback(boost::bind(onFocusEdit, _1, this));
  92. mEditCharter->setFocusChangedCallback(boost::bind(onFocusEdit, _1, this));
  93. }
  94. mListVisibleMembers = getChild<LLNameListCtrl>("visible_members", recurse);
  95. if (mListVisibleMembers)
  96. {
  97. mListVisibleMembers->setDoubleClickCallback(openProfile, this);
  98. mListVisibleMembers->setContextMenu(LLScrollListCtrl::MENU_AVATAR);
  99. }
  100. // Options
  101. mCtrlShowInGroupList = getChild<LLCheckBoxCtrl>("show_in_group_list", recurse);
  102. if (mCtrlShowInGroupList)
  103. {
  104. mCtrlShowInGroupList->setCommitCallback(onCommitAny, this);
  105. }
  106. mComboMature = getChild<LLComboBox>("group_mature_check", recurse);
  107. if(mComboMature)
  108. {
  109. mComboMature->setCurrentByIndex(0);
  110. mComboMature->setCommitCallback(onCommitAny, this);
  111. if (gAgent.isTeen())
  112. {
  113. // Teens don't get to set mature flag. JC
  114. mComboMature->setVisible(FALSE);
  115. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  116. }
  117. }
  118. mCtrlOpenEnrollment = getChild<LLCheckBoxCtrl>("open_enrollement", recurse);
  119. if (mCtrlOpenEnrollment)
  120. {
  121. mCtrlOpenEnrollment->setCommitCallback(onCommitAny, this);
  122. }
  123. mCtrlEnrollmentFee = getChild<LLCheckBoxCtrl>("check_enrollment_fee", recurse);
  124. if (mCtrlEnrollmentFee)
  125. {
  126. mCtrlEnrollmentFee->setCommitCallback(onCommitEnrollment, this);
  127. }
  128. mSpinEnrollmentFee = getChild<LLSpinCtrl>("spin_enrollment_fee", recurse);
  129. if (mSpinEnrollmentFee)
  130. {
  131. mSpinEnrollmentFee->setCommitCallback(onCommitAny, this);
  132. mSpinEnrollmentFee->setPrecision(0);
  133. mSpinEnrollmentFee->resetDirty();
  134. }
  135. BOOL accept_notices = FALSE;
  136. BOOL list_in_profile = FALSE;
  137. LLGroupData data;
  138. if(gAgent.getGroupData(mGroupID,data))
  139. {
  140. accept_notices = data.mAcceptNotices;
  141. list_in_profile = data.mListInProfile;
  142. }
  143. mCtrlReceiveNotices = getChild<LLCheckBoxCtrl>("receive_notices", recurse);
  144. if (mCtrlReceiveNotices)
  145. {
  146. mCtrlReceiveNotices->setCommitCallback(onCommitUserOnly, this);
  147. mCtrlReceiveNotices->set(accept_notices);
  148. mCtrlReceiveNotices->setEnabled(data.mID.notNull());
  149. }
  150. mCtrlListGroup = getChild<LLCheckBoxCtrl>("list_groups_in_profile", recurse);
  151. if (mCtrlListGroup)
  152. {
  153. mCtrlListGroup->setCommitCallback(onCommitUserOnly, this);
  154. mCtrlListGroup->set(list_in_profile);
  155. mCtrlListGroup->setEnabled(data.mID.notNull());
  156. mCtrlListGroup->resetDirty();
  157. }
  158. mActiveTitleLabel = getChild<LLTextBox>("active_title_label", recurse);
  159. mComboActiveTitle = getChild<LLComboBox>("active_title", recurse);
  160. if (mComboActiveTitle)
  161. {
  162. mComboActiveTitle->setCommitCallback(onCommitTitle, this);
  163. mComboActiveTitle->resetDirty();
  164. }
  165. mIncompleteMemberDataStr = getString("incomplete_member_data_str");
  166. // If the group_id is null, then we are creating a new group
  167. if (mGroupID.isNull())
  168. {
  169. mEditCharter->setEnabled(TRUE);
  170. mCtrlShowInGroupList->setEnabled(TRUE);
  171. mComboMature->setEnabled(TRUE);
  172. mCtrlOpenEnrollment->setEnabled(TRUE);
  173. mCtrlEnrollmentFee->setEnabled(TRUE);
  174. mSpinEnrollmentFee->setEnabled(TRUE);
  175. }
  176. return LLPanelGroupTab::postBuild();
  177. }
  178. void LLPanelGroupGeneral::setupCtrls(LLPanel* panel_group)
  179. {
  180. mInsignia = getChild<LLTextureCtrl>("insignia");
  181. if (mInsignia)
  182. {
  183. mInsignia->setCommitCallback(onCommitAny, this);
  184. mDefaultIconID = mInsignia->getImageAssetID();
  185. }
  186. mFounderName = getChild<LLNameBox>("founder_name");
  187. mGroupNameEditor = panel_group->getChild<LLLineEditor>("group_name_editor");
  188. mGroupNameEditor->setPrevalidate( LLTextValidate::validateASCII );
  189. }
  190. // static
  191. void LLPanelGroupGeneral::onFocusEdit(LLFocusableElement* ctrl, void* data)
  192. {
  193. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  194. self->updateChanged();
  195. self->notifyObservers();
  196. }
  197. // static
  198. void LLPanelGroupGeneral::onCommitAny(LLUICtrl* ctrl, void* data)
  199. {
  200. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  201. self->updateChanged();
  202. self->notifyObservers();
  203. }
  204. // static
  205. void LLPanelGroupGeneral::onCommitUserOnly(LLUICtrl* ctrl, void* data)
  206. {
  207. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  208. self->mChanged = TRUE;
  209. self->notifyObservers();
  210. }
  211. // static
  212. void LLPanelGroupGeneral::onCommitEnrollment(LLUICtrl* ctrl, void* data)
  213. {
  214. onCommitAny(ctrl, data);
  215. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  216. // Make sure both enrollment related widgets are there.
  217. if (!self->mCtrlEnrollmentFee || !self->mSpinEnrollmentFee)
  218. {
  219. return;
  220. }
  221. // Make sure the agent can change enrollment info.
  222. if (!gAgent.hasPowerInGroup(self->mGroupID,GP_MEMBER_OPTIONS)
  223. || !self->mAllowEdit)
  224. {
  225. return;
  226. }
  227. if (self->mCtrlEnrollmentFee->get())
  228. {
  229. self->mSpinEnrollmentFee->setEnabled(TRUE);
  230. }
  231. else
  232. {
  233. self->mSpinEnrollmentFee->setEnabled(FALSE);
  234. self->mSpinEnrollmentFee->set(0);
  235. }
  236. }
  237. // static
  238. void LLPanelGroupGeneral::onCommitTitle(LLUICtrl* ctrl, void* data)
  239. {
  240. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  241. if (self->mGroupID.isNull() || !self->mAllowEdit) return;
  242. LLGroupMgr::getInstance()->sendGroupTitleUpdate(self->mGroupID,self->mComboActiveTitle->getCurrentID());
  243. self->update(GC_TITLES);
  244. self->mComboActiveTitle->resetDirty();
  245. }
  246. // static
  247. void LLPanelGroupGeneral::onClickInfo(void *userdata)
  248. {
  249. LLPanelGroupGeneral *self = (LLPanelGroupGeneral *)userdata;
  250. if ( !self ) return;
  251. lldebugs << "open group info: " << self->mGroupID << llendl;
  252. LLGroupActions::show(self->mGroupID);
  253. }
  254. // static
  255. void LLPanelGroupGeneral::openProfile(void* data)
  256. {
  257. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  258. if (self && self->mListVisibleMembers)
  259. {
  260. LLScrollListItem* selected = self->mListVisibleMembers->getFirstSelected();
  261. if (selected)
  262. {
  263. LLAvatarActions::showProfile(selected->getUUID());
  264. }
  265. }
  266. }
  267. bool LLPanelGroupGeneral::needsApply(std::string& mesg)
  268. updateChanged();
  269. mesg = getString("group_info_unchanged");
  270. return mChanged || mGroupID.isNull();
  271. }
  272. void LLPanelGroupGeneral::activate()
  273. {
  274. LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
  275. if (mGroupID.notNull()
  276. && (!gdatap || mFirstUse))
  277. {
  278. LLGroupMgr::getInstance()->sendGroupTitlesRequest(mGroupID);
  279. LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mGroupID);
  280. if (!gdatap || !gdatap->isMemberDataComplete() )
  281. {
  282. LLGroupMgr::getInstance()->sendGroupMembersRequest(mGroupID);
  283. }
  284. mFirstUse = FALSE;
  285. }
  286. mChanged = FALSE;
  287. update(GC_ALL);
  288. }
  289. void LLPanelGroupGeneral::draw()
  290. {
  291. LLPanelGroupTab::draw();
  292. if (mPendingMemberUpdate)
  293. {
  294. updateMembers();
  295. }
  296. }
  297. bool LLPanelGroupGeneral::apply(std::string& mesg)
  298. {
  299. BOOL has_power_in_group = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
  300. if (has_power_in_group || mGroupID.isNull())
  301. {
  302. llinfos << "LLPanelGroupGeneral::apply" << llendl;
  303. // Check to make sure mature has been set
  304. if(mComboMature &&
  305.    mComboMature->getCurrentIndex() == DECLINE_TO_STATE)
  306. {
  307. LLNotificationsUtil::add("SetGroupMature", LLSD(), LLSD(), 
  308. boost::bind(&LLPanelGroupGeneral::confirmMatureApply, this, _1, _2));
  309. return false;
  310. }
  311. if (mGroupID.isNull())
  312. {
  313. // Validate the group name length.
  314. S32 group_name_len = mGroupNameEditor->getText().size();
  315. if ( group_name_len < DB_GROUP_NAME_MIN_LEN 
  316. || group_name_len > DB_GROUP_NAME_STR_LEN)
  317. {
  318. std::ostringstream temp_error;
  319. temp_error << "A group name must be between " << DB_GROUP_NAME_MIN_LEN
  320. << " and " << DB_GROUP_NAME_STR_LEN << " characters.";
  321. mesg = temp_error.str();
  322. return false;
  323. }
  324. LLNotificationsUtil::add("CreateGroupCost",  LLSD(), LLSD(), boost::bind(&LLPanelGroupGeneral::createGroupCallback, this, _1, _2));
  325. return false;
  326. }
  327. LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
  328. if (!gdatap)
  329. {
  330. mesg = LLTrans::getString("NoGroupDataFound");
  331. mesg.append(mGroupID.asString());
  332. return false;
  333. }
  334. bool can_change_ident = false;
  335. bool can_change_member_opts = false;
  336. can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
  337. can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS);
  338. if (can_change_ident)
  339. {
  340. if (mEditCharter) gdatap->mCharter = mEditCharter->getText();
  341. if (mInsignia) gdatap->mInsigniaID = mInsignia->getImageAssetID();
  342. if (mComboMature)
  343. {
  344. if (!gAgent.isTeen())
  345. {
  346. gdatap->mMaturePublish = 
  347. mComboMature->getCurrentIndex() == MATURE_CONTENT;
  348. }
  349. else
  350. {
  351. gdatap->mMaturePublish = FALSE;
  352. }
  353. }
  354. if (mCtrlShowInGroupList) gdatap->mShowInList = mCtrlShowInGroupList->get();
  355. }
  356. if (can_change_member_opts)
  357. {
  358. if (mCtrlOpenEnrollment) gdatap->mOpenEnrollment = mCtrlOpenEnrollment->get();
  359. if (mCtrlEnrollmentFee && mSpinEnrollmentFee)
  360. {
  361. gdatap->mMembershipFee = (mCtrlEnrollmentFee->get()) ? 
  362. (S32) mSpinEnrollmentFee->get() : 0;
  363. // Set to the used value, and reset initial value used for isdirty check
  364. mSpinEnrollmentFee->set( (F32)gdatap->mMembershipFee );
  365. }
  366. }
  367. if (can_change_ident || can_change_member_opts)
  368. {
  369. LLGroupMgr::getInstance()->sendUpdateGroupInfo(mGroupID);
  370. }
  371. }
  372. BOOL receive_notices = false;
  373. BOOL list_in_profile = false;
  374. if (mCtrlReceiveNotices)
  375. receive_notices = mCtrlReceiveNotices->get();
  376. if (mCtrlListGroup) 
  377. list_in_profile = mCtrlListGroup->get();
  378. gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile);
  379. mChanged = FALSE;
  380. return true;
  381. }
  382. void LLPanelGroupGeneral::cancel()
  383. {
  384. mChanged = FALSE;
  385. //cancel out all of the click changes to, although since we are
  386. //shifting tabs or closing the floater, this need not be done...yet
  387. notifyObservers();
  388. }
  389. // invoked from callbackConfirmMature
  390. bool LLPanelGroupGeneral::confirmMatureApply(const LLSD& notification, const LLSD& response)
  391. {
  392. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  393. // 0 == Yes
  394. // 1 == No
  395. // 2 == Cancel
  396. switch(option)
  397. {
  398. case 0:
  399. mComboMature->setCurrentByIndex(MATURE_CONTENT);
  400. break;
  401. case 1:
  402. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  403. break;
  404. default:
  405. return false;
  406. }
  407. // If we got here it means they set a valid value
  408. std::string mesg = "";
  409. bool ret = apply(mesg);
  410. if ( !mesg.empty() )
  411. {
  412. LLSD args;
  413. args["MESSAGE"] = mesg;
  414. LLNotificationsUtil::add("GenericAlert", args);
  415. }
  416. return ret;
  417. }
  418. // static
  419. bool LLPanelGroupGeneral::createGroupCallback(const LLSD& notification, const LLSD& response)
  420. {
  421. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  422. switch(option)
  423. {
  424. case 0:
  425. {
  426. // Yay!  We are making a new group!
  427. U32 enrollment_fee = (mCtrlEnrollmentFee->get() ? 
  428. (U32) mSpinEnrollmentFee->get() : 0);
  429. LLGroupMgr::getInstance()->sendCreateGroupRequest(mGroupNameEditor->getText(),
  430. mEditCharter->getText(),
  431. mCtrlShowInGroupList->get(),
  432. mInsignia->getImageAssetID(),
  433. enrollment_fee,
  434. mCtrlOpenEnrollment->get(),
  435. false,
  436. mComboMature->getCurrentIndex() == MATURE_CONTENT);
  437. }
  438. break;
  439. case 1:
  440. default:
  441. break;
  442. }
  443. return false;
  444. }
  445. static F32 sSDTime = 0.0f;
  446. static F32 sElementTime = 0.0f;
  447. static F32 sAllTime = 0.0f;
  448. // virtual
  449. void LLPanelGroupGeneral::update(LLGroupChange gc)
  450. {
  451. if (mGroupID.isNull()) return;
  452. LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
  453. if (!gdatap) return;
  454. LLGroupData agent_gdatap;
  455. bool is_member = false;
  456. if (gAgent.getGroupData(mGroupID,agent_gdatap)) is_member = true;
  457. if (mComboActiveTitle)
  458. {
  459. mComboActiveTitle->setVisible(is_member);
  460. mComboActiveTitle->setEnabled(mAllowEdit);
  461. if ( mActiveTitleLabel) mActiveTitleLabel->setVisible(is_member);
  462. if (is_member)
  463. {
  464. LLUUID current_title_role;
  465. mComboActiveTitle->clear();
  466. mComboActiveTitle->removeall();
  467. bool has_selected_title = false;
  468. if (1 == gdatap->mTitles.size())
  469. {
  470. // Only the everyone title.  Don't bother letting them try changing this.
  471. mComboActiveTitle->setEnabled(FALSE);
  472. }
  473. else
  474. {
  475. mComboActiveTitle->setEnabled(TRUE);
  476. }
  477. std::vector<LLGroupTitle>::const_iterator citer = gdatap->mTitles.begin();
  478. std::vector<LLGroupTitle>::const_iterator end = gdatap->mTitles.end();
  479. for ( ; citer != end; ++citer)
  480. {
  481. mComboActiveTitle->add(citer->mTitle,citer->mRoleID, (citer->mSelected ? ADD_TOP : ADD_BOTTOM));
  482. if (citer->mSelected)
  483. {
  484. mComboActiveTitle->setCurrentByID(citer->mRoleID);
  485. has_selected_title = true;
  486. }
  487. }
  488. if (!has_selected_title)
  489. {
  490. mComboActiveTitle->setCurrentByID(LLUUID::null);
  491. }
  492. }
  493. }
  494. // If this was just a titles update, we are done.
  495. if (gc == GC_TITLES) return;
  496. bool can_change_ident = false;
  497. bool can_change_member_opts = false;
  498. can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
  499. can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS);
  500. if (mCtrlShowInGroupList) 
  501. {
  502. mCtrlShowInGroupList->set(gdatap->mShowInList);
  503. mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident);
  504. }
  505. if (mComboMature)
  506. {
  507. if(gdatap->mMaturePublish)
  508. {
  509. mComboMature->setCurrentByIndex(MATURE_CONTENT);
  510. }
  511. else
  512. {
  513. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  514. }
  515. mComboMature->setEnabled(mAllowEdit && can_change_ident);
  516. mComboMature->setVisible( !gAgent.isTeen() );
  517. }
  518. if (mCtrlOpenEnrollment) 
  519. {
  520. mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment);
  521. mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts);
  522. }
  523. if (mCtrlEnrollmentFee) 
  524. {
  525. mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0);
  526. mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts);
  527. }
  528. if (mSpinEnrollmentFee)
  529. {
  530. S32 fee = gdatap->mMembershipFee;
  531. mSpinEnrollmentFee->set((F32)fee);
  532. mSpinEnrollmentFee->setEnabled( mAllowEdit &&
  533. (fee > 0) &&
  534. can_change_member_opts);
  535. }
  536. if (mCtrlReceiveNotices)
  537. {
  538. mCtrlReceiveNotices->setVisible(is_member);
  539. if (is_member)
  540. {
  541. mCtrlReceiveNotices->setEnabled(mAllowEdit);
  542. }
  543. }
  544. if (mInsignia) mInsignia->setEnabled(mAllowEdit && can_change_ident);
  545. if (mEditCharter) mEditCharter->setEnabled(mAllowEdit && can_change_ident);
  546. if (mGroupNameEditor) mGroupNameEditor->setVisible(FALSE);
  547. if (mFounderName) mFounderName->setNameID(gdatap->mFounderID,FALSE);
  548. if (mInsignia)
  549. {
  550. if (gdatap->mInsigniaID.notNull())
  551. {
  552. mInsignia->setImageAssetID(gdatap->mInsigniaID);
  553. }
  554. else
  555. {
  556. mInsignia->setImageAssetID(mDefaultIconID);
  557. }
  558. }
  559. if (mEditCharter)
  560. {
  561. mEditCharter->setText(gdatap->mCharter);
  562. }
  563. if (mListVisibleMembers)
  564. {
  565. mListVisibleMembers->deleteAllItems();
  566. if (gdatap->isMemberDataComplete())
  567. {
  568. mMemberProgress = gdatap->mMembers.begin();
  569. mPendingMemberUpdate = TRUE;
  570. sSDTime = 0.0f;
  571. sElementTime = 0.0f;
  572. sAllTime = 0.0f;
  573. }
  574. else
  575. {
  576. std::stringstream pending;
  577. pending << "Retrieving member list (" << gdatap->mMembers.size() << "\" << gdatap->mMemberCount  << ")";
  578. LLSD row;
  579. row["columns"][0]["value"] = pending.str();
  580. row["columns"][0]["column"] = "name";
  581. mListVisibleMembers->setEnabled(FALSE);
  582. mListVisibleMembers->addElement(row);
  583. }
  584. }
  585. resetDirty();
  586. }
  587. void LLPanelGroupGeneral::updateMembers()
  588. {
  589. mPendingMemberUpdate = FALSE;
  590. LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
  591. if (!mListVisibleMembers || !gdatap 
  592. || !gdatap->isMemberDataComplete())
  593. {
  594. return;
  595. }
  596. static LLTimer all_timer;
  597. static LLTimer sd_timer;
  598. static LLTimer element_timer;
  599. all_timer.reset();
  600. S32 i = 0;
  601. for( ; mMemberProgress != gdatap->mMembers.end() && i<UPDATE_MEMBERS_PER_FRAME; 
  602. ++mMemberProgress, ++i)
  603. {
  604. //llinfos << "Adding " << iter->first << ", " << iter->second->getTitle() << llendl;
  605. LLGroupMemberData* member = mMemberProgress->second;
  606. if (!member)
  607. {
  608. continue;
  609. }
  610. // Owners show up in bold.
  611. std::string style = "NORMAL";
  612. sd_timer.reset();
  613. LLSD row;
  614. row["id"] = member->getID();
  615. row["columns"][0]["column"] = "name";
  616. row["columns"][0]["font"]["name"] = "SANSSERIF_SMALL";
  617. row["columns"][0]["font"]["style"] = style;
  618. // value is filled in by name list control
  619. row["columns"][1]["column"] = "title";
  620. row["columns"][1]["value"] = member->getTitle();
  621. row["columns"][1]["font"]["name"] = "SANSSERIF_SMALL";
  622. row["columns"][1]["font"]["style"] = style;
  623. std::string status = member->getOnlineStatus();
  624. row["columns"][2]["column"] = "status";
  625. row["columns"][2]["value"] = status;
  626. row["columns"][2]["font"]["name"] = "SANSSERIF_SMALL";
  627. row["columns"][2]["font"]["style"] = style;
  628. sSDTime += sd_timer.getElapsedTimeF32();
  629. element_timer.reset();
  630. LLScrollListItem* member_row = mListVisibleMembers->addElement(row);//, ADD_SORTED);
  631. if ( member->isOwner() )
  632. {
  633. LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(member_row->getColumn(0));
  634. if (name_textp)
  635. name_textp->setFontStyle(LLFontGL::BOLD);
  636. }
  637. sElementTime += element_timer.getElapsedTimeF32();
  638. }
  639. sAllTime += all_timer.getElapsedTimeF32();
  640. llinfos << "Updated " << i << " of " << UPDATE_MEMBERS_PER_FRAME << "members in the list." << llendl;
  641. if (mMemberProgress == gdatap->mMembers.end())
  642. {
  643. llinfos << "   member list completed." << llendl;
  644. mListVisibleMembers->setEnabled(TRUE);
  645. llinfos << "All Time: " << sAllTime << llendl;
  646. llinfos << "SD Time: " << sSDTime << llendl;
  647. llinfos << "Element Time: " << sElementTime << llendl;
  648. }
  649. else
  650. {
  651. mPendingMemberUpdate = TRUE;
  652. mListVisibleMembers->setEnabled(FALSE);
  653. }
  654. }
  655. void LLPanelGroupGeneral::updateChanged()
  656. {
  657. // List all the controls we want to check for changes...
  658. LLUICtrl *check_list[] =
  659. {
  660. mGroupNameEditor,
  661. mFounderName,
  662. mInsignia,
  663. mEditCharter,
  664. mCtrlShowInGroupList,
  665. mComboMature,
  666. mCtrlOpenEnrollment,
  667. mCtrlEnrollmentFee,
  668. mSpinEnrollmentFee,
  669. mCtrlReceiveNotices,
  670. mCtrlListGroup,
  671. mActiveTitleLabel,
  672. mComboActiveTitle
  673. };
  674. mChanged = FALSE;
  675. for( size_t i=0; i<LL_ARRAY_SIZE(check_list); i++ )
  676. {
  677. if( check_list[i] && check_list[i]->isDirty() )
  678. {
  679. mChanged = TRUE;
  680. break;
  681. }
  682. }
  683. }
  684. void LLPanelGroupGeneral::reset()
  685. {
  686. mFounderName->setVisible(false);
  687. mCtrlReceiveNotices->set(false);
  688. mCtrlListGroup->set(true);
  689. mCtrlReceiveNotices->setEnabled(true);
  690. mCtrlReceiveNotices->setVisible(true);
  691. mCtrlListGroup->setEnabled(true);
  692. mGroupNameEditor->setEnabled(TRUE);
  693. mEditCharter->setEnabled(TRUE);
  694. mCtrlShowInGroupList->setEnabled(TRUE);
  695. mComboMature->setEnabled(TRUE);
  696. mCtrlOpenEnrollment->setEnabled(TRUE);
  697. mCtrlEnrollmentFee->setEnabled(TRUE);
  698. mSpinEnrollmentFee->setEnabled(TRUE);
  699. mSpinEnrollmentFee->set((F32)0);
  700. mGroupNameEditor->setVisible(true);
  701. mComboActiveTitle->setVisible(false);
  702. mInsignia->setImageAssetID(LLUUID::null);
  703. mInsignia->setEnabled(true);
  704. {
  705. std::string empty_str = "";
  706. mEditCharter->setText(empty_str);
  707. mGroupNameEditor->setText(empty_str);
  708. }
  709. {
  710. LLSD row;
  711. row["columns"][0]["value"] = "no members yet";
  712. row["columns"][0]["column"] = "name";
  713. mListVisibleMembers->deleteAllItems();
  714. mListVisibleMembers->setEnabled(FALSE);
  715. mListVisibleMembers->addElement(row);
  716. }
  717. {
  718. mComboMature->setEnabled(true);
  719. mComboMature->setVisible( !gAgent.isTeen() );
  720. mComboMature->selectFirstItem();
  721. }
  722. resetDirty();
  723. }
  724. void LLPanelGroupGeneral::resetDirty()
  725. {
  726. // List all the controls we want to check for changes...
  727. LLUICtrl *check_list[] =
  728. {
  729. mGroupNameEditor,
  730. mFounderName,
  731. mInsignia,
  732. mEditCharter,
  733. mCtrlShowInGroupList,
  734. mComboMature,
  735. mCtrlOpenEnrollment,
  736. mCtrlEnrollmentFee,
  737. mSpinEnrollmentFee,
  738. mCtrlReceiveNotices,
  739. mCtrlListGroup,
  740. mActiveTitleLabel,
  741. mComboActiveTitle
  742. };
  743. for( size_t i=0; i<LL_ARRAY_SIZE(check_list); i++ )
  744. {
  745. if( check_list[i] )
  746. check_list[i]->resetDirty() ;
  747. }
  748. }
  749. void LLPanelGroupGeneral::setGroupID(const LLUUID& id)
  750. {
  751. LLPanelGroupTab::setGroupID(id);
  752. if(id == LLUUID::null)
  753. {
  754. reset();
  755. return;
  756. }
  757. BOOL accept_notices = FALSE;
  758. BOOL list_in_profile = FALSE;
  759. LLGroupData data;
  760. if(gAgent.getGroupData(mGroupID,data))
  761. {
  762. accept_notices = data.mAcceptNotices;
  763. list_in_profile = data.mListInProfile;
  764. }
  765. mCtrlReceiveNotices = getChild<LLCheckBoxCtrl>("receive_notices");
  766. if (mCtrlReceiveNotices)
  767. {
  768. mCtrlReceiveNotices->set(accept_notices);
  769. mCtrlReceiveNotices->setEnabled(data.mID.notNull());
  770. }
  771. mCtrlListGroup = getChild<LLCheckBoxCtrl>("list_groups_in_profile");
  772. if (mCtrlListGroup)
  773. {
  774. mCtrlListGroup->set(list_in_profile);
  775. mCtrlListGroup->setEnabled(data.mID.notNull());
  776. }
  777. mActiveTitleLabel = getChild<LLTextBox>("active_title_label");
  778. mComboActiveTitle = getChild<LLComboBox>("active_title");
  779. mFounderName->setVisible(true);
  780. mInsignia->setImageAssetID(LLUUID::null);
  781. resetDirty();
  782. activate();
  783. }