diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelgroupgeneral.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelgroupgeneral.cpp')
-rw-r--r-- | linden/indra/newview/llpanelgroupgeneral.cpp | 790 |
1 files changed, 790 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelgroupgeneral.cpp b/linden/indra/newview/llpanelgroupgeneral.cpp new file mode 100644 index 0000000..871bc4b --- /dev/null +++ b/linden/indra/newview/llpanelgroupgeneral.cpp | |||
@@ -0,0 +1,790 @@ | |||
1 | /** | ||
2 | * @file llpanelgroupgeneral.cpp | ||
3 | * @brief General information about a group. | ||
4 | * | ||
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llpanelgroupgeneral.h" | ||
31 | |||
32 | #include "llvieweruictrlfactory.h" | ||
33 | #include "llagent.h" | ||
34 | #include "roles_constants.h" | ||
35 | #include "llfloateravatarinfo.h" | ||
36 | #include "llfloatergroupinfo.h" | ||
37 | |||
38 | // UI elements | ||
39 | #include "llbutton.h" | ||
40 | #include "llcheckboxctrl.h" | ||
41 | #include "llcombobox.h" | ||
42 | #include "lldbstrings.h" | ||
43 | #include "lllineeditor.h" | ||
44 | #include "llnamebox.h" | ||
45 | #include "llnamelistctrl.h" | ||
46 | #include "llspinctrl.h" | ||
47 | #include "lltextbox.h" | ||
48 | #include "lltexteditor.h" | ||
49 | #include "lltexturectrl.h" | ||
50 | #include "llviewermessage.h" | ||
51 | #include "llviewerwindow.h" | ||
52 | |||
53 | // static | ||
54 | void* LLPanelGroupGeneral::createTab(void* data) | ||
55 | { | ||
56 | LLUUID* group_id = static_cast<LLUUID*>(data); | ||
57 | return new LLPanelGroupGeneral("panel group general", *group_id); | ||
58 | } | ||
59 | |||
60 | |||
61 | LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name, | ||
62 | const LLUUID& group_id) | ||
63 | : LLPanelGroupTab(name, group_id), | ||
64 | mPendingMemberUpdate(FALSE), | ||
65 | mChanged(FALSE), | ||
66 | mFirstUse(TRUE), | ||
67 | mGroupNameEditor(NULL), | ||
68 | mGroupName(NULL), | ||
69 | mFounderName(NULL), | ||
70 | mInsignia(NULL), | ||
71 | mEditCharter(NULL), | ||
72 | mEditName(NULL), | ||
73 | mBtnJoinGroup(NULL), | ||
74 | mListVisibleMembers(NULL), | ||
75 | mCtrlShowInGroupList(NULL), | ||
76 | mCtrlPublishOnWeb(NULL), | ||
77 | mCtrlMature(NULL), | ||
78 | mCtrlOpenEnrollment(NULL), | ||
79 | mCtrlEnrollmentFee(NULL), | ||
80 | mSpinEnrollmentFee(NULL), | ||
81 | mCtrlReceiveNotices(NULL), | ||
82 | mActiveTitleLabel(NULL), | ||
83 | mComboActiveTitle(NULL) | ||
84 | { | ||
85 | |||
86 | } | ||
87 | |||
88 | LLPanelGroupGeneral::~LLPanelGroupGeneral() | ||
89 | { | ||
90 | } | ||
91 | |||
92 | BOOL LLPanelGroupGeneral::postBuild() | ||
93 | { | ||
94 | llinfos << "LLPanelGroupGeneral::postBuild()" << llendl; | ||
95 | |||
96 | bool recurse = true; | ||
97 | |||
98 | // General info | ||
99 | mGroupNameEditor = (LLLineEditor*) getChildByName("group_name_editor", recurse); | ||
100 | mGroupName = (LLTextBox*) getChildByName("group_name", recurse); | ||
101 | |||
102 | mInsignia = (LLTextureCtrl*) getChildByName("insignia", recurse); | ||
103 | if (mInsignia) | ||
104 | { | ||
105 | mInsignia->setCommitCallback(onCommitAny); | ||
106 | mInsignia->setCallbackUserData(this); | ||
107 | mDefaultIconID = mInsignia->getImageAssetID(); | ||
108 | } | ||
109 | |||
110 | mEditCharter = (LLTextEditor*) getChildByName("charter", recurse); | ||
111 | if(mEditCharter) | ||
112 | { | ||
113 | mEditCharter->setCommitCallback(onCommitAny); | ||
114 | mEditCharter->setFocusReceivedCallback(onCommitAny); | ||
115 | mEditCharter->setFocusChangedCallback(onCommitAny); | ||
116 | mEditCharter->setCallbackUserData(this); | ||
117 | } | ||
118 | |||
119 | mBtnJoinGroup = (LLButton*) getChildByName("join_button", recurse); | ||
120 | if ( mBtnJoinGroup ) | ||
121 | { | ||
122 | mBtnJoinGroup->setClickedCallback(onClickJoin); | ||
123 | mBtnJoinGroup->setCallbackUserData(this); | ||
124 | } | ||
125 | |||
126 | mBtnInfo = (LLButton*) getChildByName("info_button", recurse); | ||
127 | if ( mBtnInfo ) | ||
128 | { | ||
129 | mBtnInfo->setClickedCallback(onClickInfo); | ||
130 | mBtnInfo->setCallbackUserData(this); | ||
131 | } | ||
132 | |||
133 | LLTextBox* founder = (LLTextBox*) getChildByName("founder_name"); | ||
134 | if (founder) | ||
135 | { | ||
136 | mFounderName = new LLNameBox(founder->getName(),founder->getRect(),LLUUID::null,FALSE,founder->getFont(),founder->getMouseOpaque()); | ||
137 | removeChild(founder); | ||
138 | addChild(mFounderName); | ||
139 | } | ||
140 | |||
141 | mListVisibleMembers = (LLNameListCtrl*) getChildByName("visible_members", recurse); | ||
142 | if (mListVisibleMembers) | ||
143 | { | ||
144 | mListVisibleMembers->setDoubleClickCallback(openProfile); | ||
145 | mListVisibleMembers->setCallbackUserData(this); | ||
146 | } | ||
147 | |||
148 | // Options | ||
149 | mCtrlShowInGroupList = (LLCheckBoxCtrl*) getChildByName("show_in_group_list", recurse); | ||
150 | if (mCtrlShowInGroupList) | ||
151 | { | ||
152 | mCtrlShowInGroupList->setCommitCallback(onCommitAny); | ||
153 | mCtrlShowInGroupList->setCallbackUserData(this); | ||
154 | } | ||
155 | |||
156 | mCtrlPublishOnWeb = (LLCheckBoxCtrl*) getChildByName("publish_on_web", recurse); | ||
157 | if (mCtrlPublishOnWeb) | ||
158 | { | ||
159 | mCtrlPublishOnWeb->setCommitCallback(onCommitAny); | ||
160 | mCtrlPublishOnWeb->setCallbackUserData(this); | ||
161 | } | ||
162 | |||
163 | mCtrlMature = (LLCheckBoxCtrl*) getChildByName("mature", recurse); | ||
164 | if (mCtrlMature) | ||
165 | { | ||
166 | mCtrlMature->setCommitCallback(onCommitAny); | ||
167 | mCtrlMature->setCallbackUserData(this); | ||
168 | } | ||
169 | |||
170 | mCtrlOpenEnrollment = (LLCheckBoxCtrl*) getChildByName("open_enrollement", recurse); | ||
171 | if (mCtrlOpenEnrollment) | ||
172 | { | ||
173 | mCtrlOpenEnrollment->setCommitCallback(onCommitAny); | ||
174 | mCtrlOpenEnrollment->setCallbackUserData(this); | ||
175 | } | ||
176 | |||
177 | mCtrlEnrollmentFee = (LLCheckBoxCtrl*) getChildByName("check_enrollment_fee", recurse); | ||
178 | if (mCtrlEnrollmentFee) | ||
179 | { | ||
180 | mCtrlEnrollmentFee->setCommitCallback(onCommitEnrollment); | ||
181 | mCtrlEnrollmentFee->setCallbackUserData(this); | ||
182 | } | ||
183 | |||
184 | mSpinEnrollmentFee = (LLSpinCtrl*) getChildByName("spin_enrollment_fee", recurse); | ||
185 | if (mSpinEnrollmentFee) | ||
186 | { | ||
187 | mSpinEnrollmentFee->setCommitCallback(onCommitAny); | ||
188 | mSpinEnrollmentFee->setCallbackUserData(this); | ||
189 | } | ||
190 | |||
191 | BOOL accept_notices = FALSE; | ||
192 | LLGroupData data; | ||
193 | if(gAgent.getGroupData(mGroupID,data)) | ||
194 | { | ||
195 | accept_notices = data.mAcceptNotices; | ||
196 | } | ||
197 | mCtrlReceiveNotices = (LLCheckBoxCtrl*) getChildByName("receive_notices", recurse); | ||
198 | if (mCtrlReceiveNotices) | ||
199 | { | ||
200 | mCtrlReceiveNotices->setCommitCallback(onReceiveNotices); | ||
201 | mCtrlReceiveNotices->setCallbackUserData(this); | ||
202 | mCtrlReceiveNotices->set(accept_notices); | ||
203 | mCtrlReceiveNotices->setEnabled(data.mID.notNull()); | ||
204 | } | ||
205 | |||
206 | mActiveTitleLabel = (LLTextBox*) getChildByName("active_title_label", recurse); | ||
207 | |||
208 | mComboActiveTitle = (LLComboBox*) getChildByName("active_title", recurse); | ||
209 | if (mComboActiveTitle) | ||
210 | { | ||
211 | mComboActiveTitle->setCommitCallback(onCommitTitle); | ||
212 | mComboActiveTitle->setCallbackUserData(this); | ||
213 | } | ||
214 | |||
215 | // Extra data | ||
216 | LLTextBox* txt; | ||
217 | // Don't recurse for this, since we don't currently have a recursive removeChild() | ||
218 | txt = (LLTextBox*)getChildByName("incomplete_member_data_str"); | ||
219 | if (txt) | ||
220 | { | ||
221 | mIncompleteMemberDataStr = txt->getText(); | ||
222 | removeChild(txt); | ||
223 | } | ||
224 | |||
225 | txt = (LLTextBox*)getChildByName("confirm_group_create_str"); | ||
226 | if (txt) | ||
227 | { | ||
228 | mConfirmGroupCreateStr = txt->getText(); | ||
229 | removeChild(txt); | ||
230 | } | ||
231 | |||
232 | // If the group_id is null, then we are creating a new group | ||
233 | if (mGroupID.isNull()) | ||
234 | { | ||
235 | mGroupNameEditor->setEnabled(TRUE); | ||
236 | mEditCharter->setEnabled(TRUE); | ||
237 | |||
238 | mCtrlShowInGroupList->setEnabled(TRUE); | ||
239 | mCtrlPublishOnWeb->setEnabled(TRUE); | ||
240 | mCtrlMature->setEnabled(TRUE); | ||
241 | mCtrlOpenEnrollment->setEnabled(TRUE); | ||
242 | mCtrlEnrollmentFee->setEnabled(TRUE); | ||
243 | mSpinEnrollmentFee->setEnabled(TRUE); | ||
244 | |||
245 | mBtnJoinGroup->setVisible(FALSE); | ||
246 | mBtnInfo->setVisible(FALSE); | ||
247 | mGroupName->setVisible(FALSE); | ||
248 | } | ||
249 | |||
250 | return LLPanelGroupTab::postBuild(); | ||
251 | } | ||
252 | |||
253 | // static | ||
254 | void LLPanelGroupGeneral::onCommitAny(LLUICtrl* ctrl, void* data) | ||
255 | { | ||
256 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; | ||
257 | self->mChanged = TRUE; | ||
258 | self->notifyObservers(); | ||
259 | } | ||
260 | |||
261 | // static | ||
262 | void LLPanelGroupGeneral::onCommitEnrollment(LLUICtrl* ctrl, void* data) | ||
263 | { | ||
264 | onCommitAny(ctrl, data); | ||
265 | |||
266 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; | ||
267 | // Make sure both enrollment related widgets are there. | ||
268 | if (!self->mCtrlEnrollmentFee || !self->mSpinEnrollmentFee) | ||
269 | { | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | // Make sure the agent can change enrollment info. | ||
274 | if (!gAgent.hasPowerInGroup(self->mGroupID,GP_MEMBER_OPTIONS) | ||
275 | || !self->mAllowEdit) | ||
276 | { | ||
277 | return; | ||
278 | } | ||
279 | |||
280 | if (self->mCtrlEnrollmentFee->get()) | ||
281 | { | ||
282 | self->mSpinEnrollmentFee->setEnabled(TRUE); | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | self->mSpinEnrollmentFee->setEnabled(FALSE); | ||
287 | self->mSpinEnrollmentFee->set(0); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | // static | ||
292 | void LLPanelGroupGeneral::onCommitTitle(LLUICtrl* ctrl, void* data) | ||
293 | { | ||
294 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; | ||
295 | if (self->mGroupID.isNull() || !self->mAllowEdit) return; | ||
296 | gGroupMgr->sendGroupTitleUpdate(self->mGroupID,self->mComboActiveTitle->getCurrentID()); | ||
297 | self->update(GC_TITLES); | ||
298 | } | ||
299 | |||
300 | // static | ||
301 | void LLPanelGroupGeneral::onClickInfo(void *userdata) | ||
302 | { | ||
303 | LLPanelGroupGeneral *self = (LLPanelGroupGeneral *)userdata; | ||
304 | |||
305 | if ( !self ) return; | ||
306 | |||
307 | lldebugs << "open group info: " << self->mGroupID << llendl; | ||
308 | |||
309 | LLFloaterGroupInfo::showFromUUID(self->mGroupID); | ||
310 | } | ||
311 | |||
312 | // static | ||
313 | void LLPanelGroupGeneral::onClickJoin(void *userdata) | ||
314 | { | ||
315 | LLPanelGroupGeneral *self = (LLPanelGroupGeneral *)userdata; | ||
316 | |||
317 | if ( !self ) return; | ||
318 | |||
319 | lldebugs << "joining group: " << self->mGroupID << llendl; | ||
320 | |||
321 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(self->mGroupID); | ||
322 | |||
323 | S32 cost = gdatap->mMembershipFee; | ||
324 | LLString::format_map_t args; | ||
325 | args["[COST]"] = llformat("%d", cost); | ||
326 | |||
327 | if (can_afford_transaction(cost)) | ||
328 | { | ||
329 | gViewerWindow->alertXml("JoinGroupCanAfford", args, | ||
330 | LLPanelGroupGeneral::joinDlgCB, | ||
331 | self); | ||
332 | } | ||
333 | else | ||
334 | { | ||
335 | gViewerWindow->alertXml("JoinGroupCannotAfford", args); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | // static | ||
340 | void LLPanelGroupGeneral::joinDlgCB(S32 which, void *userdata) | ||
341 | { | ||
342 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*) userdata; | ||
343 | |||
344 | if (which == 1 || !self) | ||
345 | { | ||
346 | // user clicked cancel | ||
347 | return; | ||
348 | } | ||
349 | |||
350 | gGroupMgr->sendGroupMemberJoin(self->mGroupID); | ||
351 | } | ||
352 | |||
353 | // static | ||
354 | void LLPanelGroupGeneral::onReceiveNotices(LLUICtrl* ctrl, void* data) | ||
355 | { | ||
356 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; | ||
357 | LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; | ||
358 | |||
359 | if(!self) return; | ||
360 | gAgent.setGroupAcceptNotices(self->mGroupID, check->get()); | ||
361 | } | ||
362 | |||
363 | // static | ||
364 | void LLPanelGroupGeneral::openProfile(void* data) | ||
365 | { | ||
366 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; | ||
367 | |||
368 | if (self && self->mListVisibleMembers) | ||
369 | { | ||
370 | LLScrollListItem* selected = self->mListVisibleMembers->getFirstSelected(); | ||
371 | if (selected) | ||
372 | { | ||
373 | LLFloaterAvatarInfo::showFromDirectory( selected->getUUID() ); | ||
374 | } | ||
375 | } | ||
376 | } | ||
377 | |||
378 | bool LLPanelGroupGeneral::needsApply(LLString& mesg) | ||
379 | { | ||
380 | llinfos << "LLPanelGroupGeneral::needsApply(LLString& mesg) " << mChanged << llendl; | ||
381 | |||
382 | mesg = "General group information has changed."; | ||
383 | return mChanged || mGroupID.isNull(); | ||
384 | } | ||
385 | |||
386 | void LLPanelGroupGeneral::activate() | ||
387 | { | ||
388 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID); | ||
389 | if (mGroupID.notNull() | ||
390 | && (!gdatap || mFirstUse)) | ||
391 | { | ||
392 | gGroupMgr->sendGroupTitlesRequest(mGroupID); | ||
393 | gGroupMgr->sendGroupPropertiesRequest(mGroupID); | ||
394 | |||
395 | |||
396 | if (!gdatap || !gdatap->isMemberDataComplete() ) | ||
397 | { | ||
398 | gGroupMgr->sendGroupMembersRequest(mGroupID); | ||
399 | } | ||
400 | |||
401 | mFirstUse = FALSE; | ||
402 | } | ||
403 | mChanged = FALSE; | ||
404 | |||
405 | update(GC_ALL); | ||
406 | } | ||
407 | |||
408 | void LLPanelGroupGeneral::draw() | ||
409 | { | ||
410 | LLPanelGroupTab::draw(); | ||
411 | |||
412 | if (mPendingMemberUpdate) | ||
413 | { | ||
414 | updateMembers(); | ||
415 | } | ||
416 | } | ||
417 | |||
418 | bool LLPanelGroupGeneral::apply(LLString& mesg) | ||
419 | { | ||
420 | if (!mAllowEdit) | ||
421 | { | ||
422 | llwarns << "LLPanelGroupGeneral::apply() called with false mAllowEdit" | ||
423 | << llendl; | ||
424 | return true; | ||
425 | } | ||
426 | |||
427 | llinfos << "LLPanelGroupGeneral::apply" << llendl; | ||
428 | if (mGroupID.isNull()) | ||
429 | { | ||
430 | // Validate the group name length. | ||
431 | S32 group_name_len = mGroupNameEditor->getText().size(); | ||
432 | if ( group_name_len < DB_GROUP_NAME_MIN_LEN | ||
433 | || group_name_len > DB_GROUP_NAME_STR_LEN) | ||
434 | { | ||
435 | std::ostringstream temp_error; | ||
436 | temp_error << "A group name must be between " << DB_GROUP_NAME_MIN_LEN | ||
437 | << " and " << DB_GROUP_NAME_STR_LEN << " characters."; | ||
438 | mesg = temp_error.str(); | ||
439 | return false; | ||
440 | } | ||
441 | |||
442 | LLString::format_map_t args; | ||
443 | args["[MESSAGE]"] = mConfirmGroupCreateStr; | ||
444 | gViewerWindow->alertXml("GenericAlertYesCancel", args, | ||
445 | createGroupCallback,this); | ||
446 | |||
447 | return false; | ||
448 | } | ||
449 | |||
450 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID); | ||
451 | |||
452 | if (!gdatap) | ||
453 | { | ||
454 | mesg = "No group data found for group "; | ||
455 | mesg.append(mGroupID.getString()); | ||
456 | return false; | ||
457 | } | ||
458 | |||
459 | bool can_change_ident = false; | ||
460 | bool can_change_member_opts = false; | ||
461 | can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY); | ||
462 | can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS); | ||
463 | |||
464 | if (can_change_ident) | ||
465 | { | ||
466 | if (mCtrlPublishOnWeb) gdatap->mAllowPublish = mCtrlPublishOnWeb->get(); | ||
467 | if (mEditCharter) gdatap->mCharter = mEditCharter->getText(); | ||
468 | if (mInsignia) gdatap->mInsigniaID = mInsignia->getImageAssetID(); | ||
469 | if (mCtrlMature) gdatap->mMaturePublish = mCtrlMature->get(); | ||
470 | if (mCtrlShowInGroupList) gdatap->mShowInList = mCtrlShowInGroupList->get(); | ||
471 | } | ||
472 | |||
473 | if (can_change_member_opts) | ||
474 | { | ||
475 | if (mCtrlOpenEnrollment) gdatap->mOpenEnrollment = mCtrlOpenEnrollment->get(); | ||
476 | if (mCtrlEnrollmentFee && mSpinEnrollmentFee) | ||
477 | { | ||
478 | gdatap->mMembershipFee = (mCtrlEnrollmentFee->get()) ? | ||
479 | (S32) mSpinEnrollmentFee->get() : 0; | ||
480 | } | ||
481 | } | ||
482 | |||
483 | if (can_change_ident || can_change_member_opts) | ||
484 | { | ||
485 | gGroupMgr->sendUpdateGroupInfo(mGroupID); | ||
486 | } | ||
487 | |||
488 | if (mCtrlReceiveNotices) gAgent.setGroupAcceptNotices(mGroupID, mCtrlReceiveNotices->get()); | ||
489 | |||
490 | mChanged = FALSE; | ||
491 | notifyObservers(); | ||
492 | |||
493 | return true; | ||
494 | } | ||
495 | |||
496 | void LLPanelGroupGeneral::cancel() | ||
497 | { | ||
498 | mChanged = FALSE; | ||
499 | |||
500 | //cancel out all of the click changes to, although since we are | ||
501 | //shifting tabs or closing the floater, this need not be done...yet | ||
502 | notifyObservers(); | ||
503 | } | ||
504 | |||
505 | // static | ||
506 | void LLPanelGroupGeneral::createGroupCallback(S32 option, void* userdata) | ||
507 | { | ||
508 | LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)userdata; | ||
509 | if (!self) return; | ||
510 | |||
511 | switch(option) | ||
512 | { | ||
513 | case 0: | ||
514 | { | ||
515 | // Yay! We are making a new group! | ||
516 | U32 enrollment_fee = (self->mCtrlEnrollmentFee->get() ? | ||
517 | (U32) self->mSpinEnrollmentFee->get() : 0); | ||
518 | |||
519 | gGroupMgr->sendCreateGroupRequest(self->mGroupNameEditor->getText(), | ||
520 | self->mEditCharter->getText(), | ||
521 | self->mCtrlShowInGroupList->get(), | ||
522 | self->mInsignia->getImageAssetID(), | ||
523 | enrollment_fee, | ||
524 | self->mCtrlOpenEnrollment->get(), | ||
525 | self->mCtrlPublishOnWeb->get(), | ||
526 | self->mCtrlMature->get()); | ||
527 | |||
528 | } | ||
529 | break; | ||
530 | case 1: | ||
531 | default: | ||
532 | break; | ||
533 | } | ||
534 | } | ||
535 | |||
536 | static F32 sSDTime = 0.0f; | ||
537 | static F32 sElementTime = 0.0f; | ||
538 | static F32 sAllTime = 0.0f; | ||
539 | |||
540 | // virtual | ||
541 | void LLPanelGroupGeneral::update(LLGroupChange gc) | ||
542 | { | ||
543 | if (mGroupID.isNull()) return; | ||
544 | |||
545 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID); | ||
546 | |||
547 | if (!gdatap) return; | ||
548 | |||
549 | LLGroupData agent_gdatap; | ||
550 | bool is_member = false; | ||
551 | if (gAgent.getGroupData(mGroupID,agent_gdatap)) is_member = true; | ||
552 | |||
553 | if (mComboActiveTitle) | ||
554 | { | ||
555 | mComboActiveTitle->setVisible(is_member); | ||
556 | mComboActiveTitle->setEnabled(mAllowEdit); | ||
557 | |||
558 | if ( mActiveTitleLabel) mActiveTitleLabel->setVisible(is_member); | ||
559 | |||
560 | if (is_member) | ||
561 | { | ||
562 | LLUUID current_title_role; | ||
563 | |||
564 | mComboActiveTitle->clear(); | ||
565 | mComboActiveTitle->removeall(); | ||
566 | bool has_selected_title = false; | ||
567 | |||
568 | if (1 == gdatap->mTitles.size()) | ||
569 | { | ||
570 | // Only the everyone title. Don't bother letting them try changing this. | ||
571 | mComboActiveTitle->setEnabled(FALSE); | ||
572 | } | ||
573 | else | ||
574 | { | ||
575 | mComboActiveTitle->setEnabled(TRUE); | ||
576 | } | ||
577 | |||
578 | std::vector<LLGroupTitle>::const_iterator citer = gdatap->mTitles.begin(); | ||
579 | std::vector<LLGroupTitle>::const_iterator end = gdatap->mTitles.end(); | ||
580 | |||
581 | for ( ; citer != end; ++citer) | ||
582 | { | ||
583 | mComboActiveTitle->add(citer->mTitle,citer->mRoleID, (citer->mSelected ? ADD_TOP : ADD_BOTTOM)); | ||
584 | if (citer->mSelected) | ||
585 | { | ||
586 | mComboActiveTitle->setCurrentByID(citer->mRoleID); | ||
587 | has_selected_title = true; | ||
588 | } | ||
589 | } | ||
590 | |||
591 | if (!has_selected_title) | ||
592 | { | ||
593 | mComboActiveTitle->setCurrentByID(LLUUID::null); | ||
594 | } | ||
595 | } | ||
596 | } | ||
597 | |||
598 | // If this was just a titles update, we are done. | ||
599 | if (gc == GC_TITLES) return; | ||
600 | |||
601 | bool can_change_ident = false; | ||
602 | bool can_change_member_opts = false; | ||
603 | can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY); | ||
604 | can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS); | ||
605 | |||
606 | if (mCtrlShowInGroupList) | ||
607 | { | ||
608 | mCtrlShowInGroupList->set(gdatap->mShowInList); | ||
609 | mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident); | ||
610 | } | ||
611 | if (mCtrlPublishOnWeb) | ||
612 | { | ||
613 | mCtrlPublishOnWeb->set(gdatap->mAllowPublish); | ||
614 | mCtrlPublishOnWeb->setEnabled(mAllowEdit && can_change_ident); | ||
615 | } | ||
616 | if (mCtrlMature) | ||
617 | { | ||
618 | mCtrlMature->set(gdatap->mMaturePublish); | ||
619 | mCtrlMature->setEnabled(mAllowEdit && can_change_ident); | ||
620 | } | ||
621 | if (mCtrlOpenEnrollment) | ||
622 | { | ||
623 | mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment); | ||
624 | mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts); | ||
625 | } | ||
626 | if (mCtrlEnrollmentFee) | ||
627 | { | ||
628 | mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0); | ||
629 | mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts); | ||
630 | } | ||
631 | |||
632 | if (mSpinEnrollmentFee) | ||
633 | { | ||
634 | S32 fee = gdatap->mMembershipFee; | ||
635 | mSpinEnrollmentFee->set((F32)fee); | ||
636 | mSpinEnrollmentFee->setEnabled( mAllowEdit | ||
637 | && (fee > 0) && can_change_member_opts); | ||
638 | } | ||
639 | if ( mBtnJoinGroup ) | ||
640 | { | ||
641 | char fee_buff[20]; | ||
642 | bool visible; | ||
643 | |||
644 | visible = !is_member && gdatap->mOpenEnrollment; | ||
645 | mBtnJoinGroup->setVisible(visible); | ||
646 | |||
647 | if ( visible ) | ||
648 | { | ||
649 | sprintf(fee_buff, "Join (L$%d)", gdatap->mMembershipFee); | ||
650 | mBtnJoinGroup->setLabelSelected(std::string(fee_buff)); | ||
651 | mBtnJoinGroup->setLabelUnselected(std::string(fee_buff)); | ||
652 | } | ||
653 | } | ||
654 | if ( mBtnInfo ) | ||
655 | { | ||
656 | mBtnInfo->setVisible(is_member && !mAllowEdit); | ||
657 | } | ||
658 | |||
659 | if (mCtrlReceiveNotices) | ||
660 | { | ||
661 | mCtrlReceiveNotices->setVisible(is_member); | ||
662 | if (is_member) | ||
663 | { | ||
664 | mCtrlReceiveNotices->set(agent_gdatap.mAcceptNotices); | ||
665 | mCtrlReceiveNotices->setEnabled(mAllowEdit); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | |||
670 | if (mInsignia) mInsignia->setEnabled(mAllowEdit && can_change_ident); | ||
671 | if (mEditCharter) mEditCharter->setEnabled(mAllowEdit && can_change_ident); | ||
672 | |||
673 | if (mGroupName) mGroupName->setText(gdatap->mName); | ||
674 | if (mGroupNameEditor) mGroupNameEditor->setVisible(FALSE); | ||
675 | if (mFounderName) mFounderName->setNameID(gdatap->mFounderID,FALSE); | ||
676 | if (mInsignia) | ||
677 | { | ||
678 | if (gdatap->mInsigniaID.notNull()) | ||
679 | { | ||
680 | mInsignia->setImageAssetID(gdatap->mInsigniaID); | ||
681 | } | ||
682 | else | ||
683 | { | ||
684 | |||
685 | mInsignia->setImageAssetID(mDefaultIconID); | ||
686 | } | ||
687 | } | ||
688 | if (mEditCharter) mEditCharter->setText(gdatap->mCharter); | ||
689 | |||
690 | if (mListVisibleMembers) | ||
691 | { | ||
692 | mListVisibleMembers->deleteAllItems(); | ||
693 | |||
694 | if (gdatap->isMemberDataComplete()) | ||
695 | { | ||
696 | mMemberProgress = gdatap->mMembers.begin(); | ||
697 | mPendingMemberUpdate = TRUE; | ||
698 | |||
699 | sSDTime = 0.0f; | ||
700 | sElementTime = 0.0f; | ||
701 | sAllTime = 0.0f; | ||
702 | } | ||
703 | else | ||
704 | { | ||
705 | LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null ); | ||
706 | std::stringstream pending; | ||
707 | pending << "Retrieving member list (" << gdatap->mMembers.size() << "\\" << gdatap->mMemberCount << ")"; | ||
708 | row->addColumn(pending.str(), LLFontGL::sSansSerif); | ||
709 | mListVisibleMembers->setEnabled(FALSE); | ||
710 | mListVisibleMembers->addItem(row); | ||
711 | } | ||
712 | } | ||
713 | } | ||
714 | |||
715 | void LLPanelGroupGeneral::updateMembers() | ||
716 | { | ||
717 | mPendingMemberUpdate = FALSE; | ||
718 | |||
719 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID); | ||
720 | |||
721 | if (!mListVisibleMembers || !gdatap | ||
722 | || !gdatap->isMemberDataComplete()) | ||
723 | { | ||
724 | return; | ||
725 | } | ||
726 | |||
727 | static LLTimer all_timer; | ||
728 | static LLTimer sd_timer; | ||
729 | static LLTimer element_timer; | ||
730 | |||
731 | all_timer.reset(); | ||
732 | S32 i = 0; | ||
733 | LLGroupMgrGroupData::member_iter end = gdatap->mMembers.end(); | ||
734 | |||
735 | for( ; mMemberProgress != end && i<UPDATE_MEMBERS_PER_FRAME; | ||
736 | ++mMemberProgress, ++i) | ||
737 | { | ||
738 | //llinfos << "Adding " << iter->first << ", " << iter->second->getTitle() << llendl; | ||
739 | LLGroupMemberData* member = mMemberProgress->second; | ||
740 | if (!member) | ||
741 | { | ||
742 | continue; | ||
743 | } | ||
744 | // Owners show up in bold. | ||
745 | LLString style = "NORMAL"; | ||
746 | if ( member->isOwner() ) | ||
747 | { | ||
748 | style = "BOLD"; | ||
749 | } | ||
750 | |||
751 | sd_timer.reset(); | ||
752 | LLSD row; | ||
753 | row["id"] = member->getID(); | ||
754 | |||
755 | row["columns"][0]["column"] = "name"; | ||
756 | row["columns"][0]["font-style"] = style; | ||
757 | // value is filled in by name list control | ||
758 | |||
759 | row["columns"][1]["column"] = "title"; | ||
760 | row["columns"][1]["value"] = member->getTitle(); | ||
761 | row["columns"][1]["font-style"] = style; | ||
762 | |||
763 | row["columns"][2]["column"] = "online"; | ||
764 | row["columns"][2]["value"] = member->getOnlineStatus(); | ||
765 | row["columns"][2]["font-style"] = style; | ||
766 | |||
767 | sSDTime += sd_timer.getElapsedTimeF32(); | ||
768 | |||
769 | element_timer.reset(); | ||
770 | mListVisibleMembers->addElement(row);//, ADD_SORTED); | ||
771 | sElementTime += element_timer.getElapsedTimeF32(); | ||
772 | } | ||
773 | sAllTime += all_timer.getElapsedTimeF32(); | ||
774 | |||
775 | llinfos << "Updated " << i << " of " << UPDATE_MEMBERS_PER_FRAME << "members in the list." << llendl; | ||
776 | if (mMemberProgress == end) | ||
777 | { | ||
778 | llinfos << " member list completed." << llendl; | ||
779 | mListVisibleMembers->setEnabled(TRUE); | ||
780 | |||
781 | llinfos << "All Time: " << sAllTime << llendl; | ||
782 | llinfos << "SD Time: " << sSDTime << llendl; | ||
783 | llinfos << "Element Time: " << sElementTime << llendl; | ||
784 | } | ||
785 | else | ||
786 | { | ||
787 | mPendingMemberUpdate = TRUE; | ||
788 | mListVisibleMembers->setEnabled(FALSE); | ||
789 | } | ||
790 | } | ||