PageRenderTime 24ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llpanelgroupgeneral.cpp

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