llpanelgroupgeneral.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpanelgroupgeneral.h"
00035 
00036 #include "llvieweruictrlfactory.h"
00037 #include "llagent.h"
00038 #include "roles_constants.h"
00039 #include "llfloateravatarinfo.h"
00040 #include "llfloatergroupinfo.h"
00041 
00042 // UI elements
00043 #include "llbutton.h"
00044 #include "llcheckboxctrl.h"
00045 #include "llcombobox.h"
00046 #include "lldbstrings.h"
00047 #include "lllineeditor.h"
00048 #include "llnamebox.h"
00049 #include "llnamelistctrl.h"
00050 #include "llspinctrl.h"
00051 #include "llstatusbar.h"        // can_afford_transaction()
00052 #include "lltextbox.h"
00053 #include "lltexteditor.h"
00054 #include "lltexturectrl.h"
00055 #include "llviewerwindow.h"
00056 
00057 // static
00058 void* LLPanelGroupGeneral::createTab(void* data)
00059 {
00060         LLUUID* group_id = static_cast<LLUUID*>(data);
00061         return new LLPanelGroupGeneral("panel group general", *group_id);
00062 }
00063 
00064 
00065 LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name, 
00066                                                                                  const LLUUID& group_id)
00067 :       LLPanelGroupTab(name, group_id),
00068         mPendingMemberUpdate(FALSE),
00069         mChanged(FALSE),
00070         mFirstUse(TRUE),
00071         mGroupNameEditor(NULL),
00072         mGroupName(NULL),
00073         mFounderName(NULL),
00074         mInsignia(NULL),
00075         mEditCharter(NULL),
00076         mBtnJoinGroup(NULL),
00077         mListVisibleMembers(NULL),
00078         mCtrlShowInGroupList(NULL),
00079         mCtrlMature(NULL),
00080         mCtrlOpenEnrollment(NULL),
00081         mCtrlEnrollmentFee(NULL),
00082         mSpinEnrollmentFee(NULL),
00083         mCtrlReceiveNotices(NULL),
00084         mCtrlListGroup(NULL),
00085         mActiveTitleLabel(NULL),
00086         mComboActiveTitle(NULL)
00087 {
00088 
00089 }
00090 
00091 LLPanelGroupGeneral::~LLPanelGroupGeneral()
00092 {
00093 }
00094 
00095 BOOL LLPanelGroupGeneral::postBuild()
00096 {
00097         llinfos << "LLPanelGroupGeneral::postBuild()" << llendl;
00098 
00099         bool recurse = true;
00100 
00101         // General info
00102         mGroupNameEditor = (LLLineEditor*) getChildByName("group_name_editor", recurse);
00103         mGroupName = (LLTextBox*) getChildByName("group_name", recurse);
00104         
00105         mInsignia = (LLTextureCtrl*) getChildByName("insignia", recurse);
00106         if (mInsignia)
00107         {
00108                 mInsignia->setCommitCallback(onCommitAny);
00109                 mInsignia->setCallbackUserData(this);
00110                 mDefaultIconID = mInsignia->getImageAssetID();
00111         }
00112         
00113         mEditCharter = (LLTextEditor*) getChildByName("charter", recurse);
00114         if(mEditCharter)
00115         {
00116                 mEditCharter->setCommitCallback(onCommitAny);
00117                 mEditCharter->setFocusReceivedCallback(onCommitAny);
00118                 mEditCharter->setFocusChangedCallback(onCommitAny);
00119                 mEditCharter->setCallbackUserData(this);
00120         }
00121 
00122         mBtnJoinGroup = (LLButton*) getChildByName("join_button", recurse);
00123         if ( mBtnJoinGroup )
00124         {
00125                 mBtnJoinGroup->setClickedCallback(onClickJoin);
00126                 mBtnJoinGroup->setCallbackUserData(this);
00127         }
00128 
00129         mBtnInfo = (LLButton*) getChildByName("info_button", recurse);
00130         if ( mBtnInfo )
00131         {
00132                 mBtnInfo->setClickedCallback(onClickInfo);
00133                 mBtnInfo->setCallbackUserData(this);
00134         }
00135 
00136         LLTextBox* founder = (LLTextBox*) getChildByName("founder_name");
00137         if (founder)
00138         {
00139                 mFounderName = new LLNameBox(founder->getName(),founder->getRect(),LLUUID::null,FALSE,founder->getFont(),founder->getMouseOpaque());
00140                 removeChild(founder, TRUE);
00141                 addChild(mFounderName);
00142         }
00143 
00144         mListVisibleMembers = (LLNameListCtrl*) getChildByName("visible_members", recurse);
00145         if (mListVisibleMembers)
00146         {
00147                 mListVisibleMembers->setDoubleClickCallback(openProfile);
00148                 mListVisibleMembers->setCallbackUserData(this);
00149         }
00150 
00151         // Options
00152         mCtrlShowInGroupList = (LLCheckBoxCtrl*) getChildByName("show_in_group_list", recurse);
00153         if (mCtrlShowInGroupList)
00154         {
00155                 mCtrlShowInGroupList->setCommitCallback(onCommitAny);
00156                 mCtrlShowInGroupList->setCallbackUserData(this);
00157         }
00158 
00159         mCtrlMature = (LLCheckBoxCtrl*) getChildByName("mature", recurse);
00160         if (mCtrlMature)
00161         {
00162                 mCtrlMature->setCommitCallback(onCommitAny);
00163                 mCtrlMature->setCallbackUserData(this);
00164                 mCtrlMature->setVisible( !gAgent.isTeen() );
00165         }
00166 
00167         mCtrlOpenEnrollment = (LLCheckBoxCtrl*) getChildByName("open_enrollement", recurse);
00168         if (mCtrlOpenEnrollment)
00169         {
00170                 mCtrlOpenEnrollment->setCommitCallback(onCommitAny);
00171                 mCtrlOpenEnrollment->setCallbackUserData(this);
00172         }
00173 
00174         mCtrlEnrollmentFee = (LLCheckBoxCtrl*) getChildByName("check_enrollment_fee", recurse);
00175         if (mCtrlEnrollmentFee)
00176         {
00177                 mCtrlEnrollmentFee->setCommitCallback(onCommitEnrollment);
00178                 mCtrlEnrollmentFee->setCallbackUserData(this);
00179         }
00180 
00181         mSpinEnrollmentFee = (LLSpinCtrl*) getChildByName("spin_enrollment_fee", recurse);
00182         if (mSpinEnrollmentFee)
00183         {
00184                 mSpinEnrollmentFee->setCommitCallback(onCommitAny);
00185                 mSpinEnrollmentFee->setCallbackUserData(this);
00186                 mSpinEnrollmentFee->setPrecision(0);
00187         }
00188 
00189         BOOL accept_notices = FALSE;
00190         BOOL list_in_profile = FALSE;
00191         LLGroupData data;
00192         if(gAgent.getGroupData(mGroupID,data))
00193         {
00194                 accept_notices = data.mAcceptNotices;
00195                 list_in_profile = data.mListInProfile;
00196         }
00197         mCtrlReceiveNotices = (LLCheckBoxCtrl*) getChildByName("receive_notices", recurse);
00198         if (mCtrlReceiveNotices)
00199         {
00200                 mCtrlReceiveNotices->setCommitCallback(onCommitUserOnly);
00201                 mCtrlReceiveNotices->setCallbackUserData(this);
00202                 mCtrlReceiveNotices->set(accept_notices);
00203                 mCtrlReceiveNotices->setEnabled(data.mID.notNull());
00204         }
00205         
00206         mCtrlListGroup = (LLCheckBoxCtrl*) getChildByName("list_groups_in_profile", recurse);
00207         if (mCtrlListGroup)
00208         {
00209                 mCtrlListGroup->setCommitCallback(onCommitUserOnly);
00210                 mCtrlListGroup->setCallbackUserData(this);
00211                 mCtrlListGroup->set(list_in_profile);
00212                 mCtrlListGroup->setEnabled(data.mID.notNull());
00213         }
00214 
00215         mActiveTitleLabel = (LLTextBox*) getChildByName("active_title_label", recurse);
00216         
00217         mComboActiveTitle = (LLComboBox*) getChildByName("active_title", recurse);
00218         if (mComboActiveTitle)
00219         {
00220                 mComboActiveTitle->setCommitCallback(onCommitTitle);
00221                 mComboActiveTitle->setCallbackUserData(this);
00222         }
00223 
00224         // Extra data
00225         LLTextBox* txt;
00226         // Don't recurse for this, since we don't currently have a recursive removeChild()
00227         txt = (LLTextBox*)getChildByName("incomplete_member_data_str");
00228         if (txt)
00229         {
00230                 mIncompleteMemberDataStr = txt->getText();
00231                 removeChild(txt, TRUE);
00232         }
00233 
00234         txt = (LLTextBox*)getChildByName("confirm_group_create_str");
00235         if (txt)
00236         {
00237                 mConfirmGroupCreateStr = txt->getText();
00238                 removeChild(txt, TRUE);
00239         }
00240 
00241         // If the group_id is null, then we are creating a new group
00242         if (mGroupID.isNull())
00243         {
00244                 mGroupNameEditor->setEnabled(TRUE);
00245                 mEditCharter->setEnabled(TRUE);
00246 
00247                 mCtrlShowInGroupList->setEnabled(TRUE);
00248                 mCtrlMature->setEnabled(TRUE);
00249                 mCtrlOpenEnrollment->setEnabled(TRUE);
00250                 mCtrlEnrollmentFee->setEnabled(TRUE);
00251                 mSpinEnrollmentFee->setEnabled(TRUE);
00252 
00253                 mBtnJoinGroup->setVisible(FALSE);
00254                 mBtnInfo->setVisible(FALSE);
00255                 mGroupName->setVisible(FALSE);
00256         }
00257 
00258         return LLPanelGroupTab::postBuild();
00259 }
00260 
00261 // static
00262 void LLPanelGroupGeneral::onCommitAny(LLUICtrl* ctrl, void* data)
00263 {
00264         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
00265         self->updateChanged();
00266         self->notifyObservers();
00267 }
00268 
00269 // static
00270 void LLPanelGroupGeneral::onCommitUserOnly(LLUICtrl* ctrl, void* data)
00271 {
00272         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
00273         self->mChanged = TRUE;
00274         self->notifyObservers();
00275 }
00276 
00277 
00278 // static
00279 void LLPanelGroupGeneral::onCommitEnrollment(LLUICtrl* ctrl, void* data)
00280 {
00281         onCommitAny(ctrl, data);
00282 
00283         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
00284         // Make sure both enrollment related widgets are there.
00285         if (!self->mCtrlEnrollmentFee || !self->mSpinEnrollmentFee)
00286         {
00287                 return;
00288         }
00289 
00290         // Make sure the agent can change enrollment info.
00291         if (!gAgent.hasPowerInGroup(self->mGroupID,GP_MEMBER_OPTIONS)
00292                 || !self->mAllowEdit)
00293         {
00294                 return;
00295         }
00296 
00297         if (self->mCtrlEnrollmentFee->get())
00298         {
00299                 self->mSpinEnrollmentFee->setEnabled(TRUE);
00300         }
00301         else
00302         {
00303                 self->mSpinEnrollmentFee->setEnabled(FALSE);
00304                 self->mSpinEnrollmentFee->set(0);
00305         }
00306 }
00307 
00308 // static
00309 void LLPanelGroupGeneral::onCommitTitle(LLUICtrl* ctrl, void* data)
00310 {
00311         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
00312         if (self->mGroupID.isNull() || !self->mAllowEdit) return;
00313         gGroupMgr->sendGroupTitleUpdate(self->mGroupID,self->mComboActiveTitle->getCurrentID());
00314         self->update(GC_TITLES);
00315 }
00316 
00317 // static
00318 void LLPanelGroupGeneral::onClickInfo(void *userdata)
00319 {
00320         LLPanelGroupGeneral *self = (LLPanelGroupGeneral *)userdata;
00321 
00322         if ( !self ) return;
00323 
00324         lldebugs << "open group info: " << self->mGroupID << llendl;
00325 
00326         LLFloaterGroupInfo::showFromUUID(self->mGroupID);
00327 }
00328 
00329 // static
00330 void LLPanelGroupGeneral::onClickJoin(void *userdata)
00331 {
00332         LLPanelGroupGeneral *self = (LLPanelGroupGeneral *)userdata;
00333 
00334         if ( !self ) return;
00335 
00336         lldebugs << "joining group: " << self->mGroupID << llendl;
00337 
00338         LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(self->mGroupID);
00339 
00340         if (gdatap)
00341         {
00342                 S32 cost = gdatap->mMembershipFee;
00343                 LLString::format_map_t args;
00344                 args["[COST]"] = llformat("%d", cost);
00345                 
00346                 if (can_afford_transaction(cost))
00347                 {
00348                         gViewerWindow->alertXml("JoinGroupCanAfford", args,
00349                                                 LLPanelGroupGeneral::joinDlgCB,
00350                                                 self);
00351                 }
00352                 else
00353                 {
00354                         gViewerWindow->alertXml("JoinGroupCannotAfford", args);
00355                 }
00356         }
00357         else
00358         {
00359                 llwarns << "gGroupMgr->getGroupData(" << self->mGroupID
00360                         << ") was NULL" << llendl;
00361         }
00362 }
00363 
00364 // static
00365 void LLPanelGroupGeneral::joinDlgCB(S32 which, void *userdata)
00366 {
00367         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*) userdata;
00368 
00369         if (which == 1 || !self)
00370         {
00371                 // user clicked cancel
00372                 return;
00373         }
00374 
00375         gGroupMgr->sendGroupMemberJoin(self->mGroupID);
00376 }
00377 
00378 // static
00379 void LLPanelGroupGeneral::openProfile(void* data)
00380 {
00381         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
00382 
00383         if (self && self->mListVisibleMembers)
00384         {
00385                 LLScrollListItem* selected = self->mListVisibleMembers->getFirstSelected();
00386                 if (selected)
00387                 {
00388                         LLFloaterAvatarInfo::showFromDirectory( selected->getUUID() );
00389                 }
00390         }
00391 }
00392 
00393 bool LLPanelGroupGeneral::needsApply(LLString& mesg)
00394 { 
00395         mesg = getUIString("group_info_unchanged");
00396         return mChanged || mGroupID.isNull();
00397 }
00398 
00399 void LLPanelGroupGeneral::activate()
00400 {
00401         LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID);
00402         if (mGroupID.notNull()
00403                 && (!gdatap || mFirstUse))
00404         {
00405                 gGroupMgr->sendGroupTitlesRequest(mGroupID);
00406                 gGroupMgr->sendGroupPropertiesRequest(mGroupID);
00407 
00408                 
00409                 if (!gdatap || !gdatap->isMemberDataComplete() )
00410                 {
00411                         gGroupMgr->sendGroupMembersRequest(mGroupID);
00412                 }
00413 
00414                 mFirstUse = FALSE;
00415         }
00416         mChanged = FALSE;
00417         
00418         update(GC_ALL);
00419 }
00420 
00421 void LLPanelGroupGeneral::draw()
00422 {
00423         LLPanelGroupTab::draw();
00424 
00425         if (mPendingMemberUpdate)
00426         {
00427                 updateMembers();
00428         }
00429 }
00430 
00431 bool LLPanelGroupGeneral::apply(LLString& mesg)
00432 {
00433         BOOL has_power_in_group = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
00434 
00435         if (has_power_in_group || mGroupID.isNull())
00436         {
00437                 llinfos << "LLPanelGroupGeneral::apply" << llendl;
00438                 if (mGroupID.isNull())
00439                 {
00440                         // Validate the group name length.
00441                         S32 group_name_len = mGroupNameEditor->getText().size();
00442                         if ( group_name_len < DB_GROUP_NAME_MIN_LEN 
00443                                 || group_name_len > DB_GROUP_NAME_STR_LEN)
00444                         {
00445                                 std::ostringstream temp_error;
00446                                 temp_error << "A group name must be between " << DB_GROUP_NAME_MIN_LEN
00447                                         << " and " << DB_GROUP_NAME_STR_LEN << " characters.";
00448                                 mesg = temp_error.str();
00449                                 return false;
00450                         }
00451 
00452                         LLString::format_map_t args;
00453                         args["[MESSAGE]"] = mConfirmGroupCreateStr;
00454                         gViewerWindow->alertXml("GenericAlertYesCancel", args,
00455                                 createGroupCallback,this);
00456 
00457                         return false;
00458                 }
00459 
00460                 LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID);
00461 
00462                 if (!gdatap)
00463                 {
00464                         mesg = "No group data found for group ";
00465                         mesg.append(mGroupID.asString());
00466                         return false;
00467                 }
00468                 bool can_change_ident = false;
00469                 bool can_change_member_opts = false;
00470                 can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
00471                 can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS);
00472 
00473                 if (can_change_ident)
00474                 {
00475                         if (mEditCharter) gdatap->mCharter = mEditCharter->getText();
00476                         if (mInsignia) gdatap->mInsigniaID = mInsignia->getImageAssetID();
00477                         if (mCtrlMature)
00478                         {
00479                                 if (!gAgent.isTeen())
00480                                 {
00481                                         gdatap->mMaturePublish = mCtrlMature->get();
00482                                 }
00483                                 else
00484                                 {
00485                                         gdatap->mMaturePublish = FALSE;
00486                                 }
00487                         }
00488                         if (mCtrlShowInGroupList) gdatap->mShowInList = mCtrlShowInGroupList->get();
00489                 }
00490 
00491                 if (can_change_member_opts)
00492                 {
00493                         if (mCtrlOpenEnrollment) gdatap->mOpenEnrollment = mCtrlOpenEnrollment->get();
00494                         if (mCtrlEnrollmentFee && mSpinEnrollmentFee)
00495                         {
00496                                 gdatap->mMembershipFee = (mCtrlEnrollmentFee->get()) ? 
00497                                         (S32) mSpinEnrollmentFee->get() : 0;
00498                                 // Set to the used value, and reset initial value used for isdirty check
00499                                 mSpinEnrollmentFee->set( (F32)gdatap->mMembershipFee );
00500                         }
00501                 }
00502 
00503                 if (can_change_ident || can_change_member_opts)
00504                 {
00505                         gGroupMgr->sendUpdateGroupInfo(mGroupID);
00506                 }
00507         }
00508 
00509         BOOL receive_notices = false;
00510         BOOL list_in_profile = false;
00511         if (mCtrlReceiveNotices)
00512                 receive_notices = mCtrlReceiveNotices->get();
00513         if (mCtrlListGroup) 
00514                 list_in_profile = mCtrlListGroup->get();
00515 
00516         gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile);
00517 
00518         mChanged = FALSE;
00519 
00520         return true;
00521 }
00522 
00523 void LLPanelGroupGeneral::cancel()
00524 {
00525         mChanged = FALSE;
00526 
00527         //cancel out all of the click changes to, although since we are
00528         //shifting tabs or closing the floater, this need not be done...yet
00529         notifyObservers();
00530 }
00531 
00532 // static
00533 void LLPanelGroupGeneral::createGroupCallback(S32 option, void* userdata)
00534 {
00535         LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)userdata;
00536         if (!self) return;
00537 
00538         switch(option)
00539         {
00540         case 0:
00541                 {
00542                         // Yay!  We are making a new group!
00543                         U32 enrollment_fee = (self->mCtrlEnrollmentFee->get() ? 
00544                                                                         (U32) self->mSpinEnrollmentFee->get() : 0);
00545                 
00546                         gGroupMgr->sendCreateGroupRequest(self->mGroupNameEditor->getText(),
00547                                                                                                 self->mEditCharter->getText(),
00548                                                                                                 self->mCtrlShowInGroupList->get(),
00549                                                                                                 self->mInsignia->getImageAssetID(),
00550                                                                                                 enrollment_fee,
00551                                                                                                 self->mCtrlOpenEnrollment->get(),
00552                                                                                                 false,
00553                                                                                                 self->mCtrlMature->get());
00554 
00555                 }
00556                 break;
00557         case 1:
00558         default:
00559                 break;
00560         }
00561 }
00562 
00563 static F32 sSDTime = 0.0f;
00564 static F32 sElementTime = 0.0f;
00565 static F32 sAllTime = 0.0f;
00566 
00567 // virtual
00568 void LLPanelGroupGeneral::update(LLGroupChange gc)
00569 {
00570         if (mGroupID.isNull()) return;
00571 
00572         LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID);
00573 
00574         if (!gdatap) return;
00575 
00576         LLGroupData agent_gdatap;
00577         bool is_member = false;
00578         if (gAgent.getGroupData(mGroupID,agent_gdatap)) is_member = true;
00579 
00580         if (mComboActiveTitle)
00581         {
00582                 mComboActiveTitle->setVisible(is_member);
00583                 mComboActiveTitle->setEnabled(mAllowEdit);
00584                 
00585                 if ( mActiveTitleLabel) mActiveTitleLabel->setVisible(is_member);
00586 
00587                 if (is_member)
00588                 {
00589                         LLUUID current_title_role;
00590 
00591                         mComboActiveTitle->clear();
00592                         mComboActiveTitle->removeall();
00593                         bool has_selected_title = false;
00594 
00595                         if (1 == gdatap->mTitles.size())
00596                         {
00597                                 // Only the everyone title.  Don't bother letting them try changing this.
00598                                 mComboActiveTitle->setEnabled(FALSE);
00599                         }
00600                         else
00601                         {
00602                                 mComboActiveTitle->setEnabled(TRUE);
00603                         }
00604 
00605                         std::vector<LLGroupTitle>::const_iterator citer = gdatap->mTitles.begin();
00606                         std::vector<LLGroupTitle>::const_iterator end = gdatap->mTitles.end();
00607                         
00608                         for ( ; citer != end; ++citer)
00609                         {
00610                                 mComboActiveTitle->add(citer->mTitle,citer->mRoleID, (citer->mSelected ? ADD_TOP : ADD_BOTTOM));
00611                                 if (citer->mSelected)
00612                                 {
00613                                         mComboActiveTitle->setCurrentByID(citer->mRoleID);
00614                                         has_selected_title = true;
00615                                 }
00616                         }
00617                         
00618                         if (!has_selected_title)
00619                         {
00620                                 mComboActiveTitle->setCurrentByID(LLUUID::null);
00621                         }
00622                 }
00623         }
00624 
00625         // If this was just a titles update, we are done.
00626         if (gc == GC_TITLES) return;
00627 
00628         bool can_change_ident = false;
00629         bool can_change_member_opts = false;
00630         can_change_ident = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY);
00631         can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,GP_MEMBER_OPTIONS);
00632 
00633         if (mCtrlShowInGroupList) 
00634         {
00635                 mCtrlShowInGroupList->set(gdatap->mShowInList);
00636                 mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident);
00637         }
00638         if (mCtrlMature)
00639         {
00640                 mCtrlMature->set(gdatap->mMaturePublish);
00641                 mCtrlMature->setEnabled(mAllowEdit && can_change_ident);
00642                 mCtrlMature->setVisible( !gAgent.isTeen() );
00643         }
00644         if (mCtrlOpenEnrollment) 
00645         {
00646                 mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment);
00647                 mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts);
00648         }
00649         if (mCtrlEnrollmentFee) 
00650         {       
00651                 mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0);
00652                 mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts);
00653         }
00654         
00655         if (mSpinEnrollmentFee)
00656         {
00657                 S32 fee = gdatap->mMembershipFee;
00658                 mSpinEnrollmentFee->set((F32)fee);
00659                 mSpinEnrollmentFee->setEnabled( mAllowEdit 
00660                                                                 && (fee > 0) && can_change_member_opts);
00661         }
00662         if ( mBtnJoinGroup )
00663         {
00664                 char fee_buff[20];              /*Flawfinder: ignore*/
00665                 bool visible;
00666 
00667                 visible = !is_member && gdatap->mOpenEnrollment;
00668                 mBtnJoinGroup->setVisible(visible);
00669 
00670                 if ( visible )
00671                 {
00672                         snprintf(fee_buff, sizeof(fee_buff), "Join (L$%d)", gdatap->mMembershipFee);                    /* Flawfinder: ignore */
00673                         mBtnJoinGroup->setLabelSelected(std::string(fee_buff));
00674                         mBtnJoinGroup->setLabelUnselected(std::string(fee_buff));
00675                 }
00676         }
00677         if ( mBtnInfo )
00678         {
00679                 mBtnInfo->setVisible(is_member && !mAllowEdit);
00680         }
00681 
00682         if (mCtrlReceiveNotices)
00683         {
00684                 mCtrlReceiveNotices->setVisible(is_member);
00685                 if (is_member)
00686                 {
00687                         mCtrlReceiveNotices->setEnabled(mAllowEdit);
00688                 }
00689         }
00690         
00691 
00692         if (mInsignia) mInsignia->setEnabled(mAllowEdit && can_change_ident);
00693         if (mEditCharter) mEditCharter->setEnabled(mAllowEdit && can_change_ident);
00694         
00695         if (mGroupName) mGroupName->setText(gdatap->mName);
00696         if (mGroupNameEditor) mGroupNameEditor->setVisible(FALSE);
00697         if (mFounderName) mFounderName->setNameID(gdatap->mFounderID,FALSE);
00698         if (mInsignia)
00699         {
00700                 if (gdatap->mInsigniaID.notNull())
00701                 {
00702                         mInsignia->setImageAssetID(gdatap->mInsigniaID);
00703                 }
00704                 else
00705                 {
00706                         
00707                         mInsignia->setImageAssetID(mDefaultIconID);
00708                 }
00709         }
00710         if (mEditCharter) mEditCharter->setText(gdatap->mCharter);
00711         
00712         if (mListVisibleMembers)
00713         {
00714                 mListVisibleMembers->deleteAllItems();
00715 
00716                 if (gdatap->isMemberDataComplete())
00717                 {
00718                         mMemberProgress = gdatap->mMembers.begin();
00719                         mPendingMemberUpdate = TRUE;
00720 
00721                         sSDTime = 0.0f;
00722                         sElementTime = 0.0f;
00723                         sAllTime = 0.0f;
00724                 }
00725                 else
00726                 {
00727                         std::stringstream pending;
00728                         pending << "Retrieving member list (" << gdatap->mMembers.size() << "\\" << gdatap->mMemberCount  << ")";
00729 
00730                         LLSD row;
00731                         row["columns"][0]["value"] = pending.str();
00732 
00733                         mListVisibleMembers->setEnabled(FALSE);
00734                         mListVisibleMembers->addElement(row);
00735                 }
00736         }
00737 }
00738 
00739 void LLPanelGroupGeneral::updateMembers()
00740 {
00741         mPendingMemberUpdate = FALSE;
00742 
00743         LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mGroupID);
00744 
00745         if (!mListVisibleMembers || !gdatap 
00746                 || !gdatap->isMemberDataComplete())
00747         {
00748                 return;
00749         }
00750 
00751         static LLTimer all_timer;
00752         static LLTimer sd_timer;
00753         static LLTimer element_timer;
00754 
00755         all_timer.reset();
00756         S32 i = 0;
00757         LLGroupMgrGroupData::member_iter end = gdatap->mMembers.end();
00758 
00759         for( ; mMemberProgress != end && i<UPDATE_MEMBERS_PER_FRAME; 
00760                         ++mMemberProgress, ++i)
00761         {
00762                 //llinfos << "Adding " << iter->first << ", " << iter->second->getTitle() << llendl;
00763                 LLGroupMemberData* member = mMemberProgress->second;
00764                 if (!member)
00765                 {
00766                         continue;
00767                 }
00768                 // Owners show up in bold.
00769                 LLString style = "NORMAL";
00770                 if ( member->isOwner() )
00771                 {
00772                         style = "BOLD";
00773                 }
00774                 
00775                 sd_timer.reset();
00776                 LLSD row;
00777                 row["id"] = member->getID();
00778 
00779                 row["columns"][0]["column"] = "name";
00780                 row["columns"][0]["font-style"] = style;
00781                 // value is filled in by name list control
00782 
00783                 row["columns"][1]["column"] = "title";
00784                 row["columns"][1]["value"] = member->getTitle();
00785                 row["columns"][1]["font-style"] = style;
00786                 
00787                 row["columns"][2]["column"] = "online";
00788                 row["columns"][2]["value"] = member->getOnlineStatus();
00789                 row["columns"][2]["font-style"] = style;
00790 
00791                 sSDTime += sd_timer.getElapsedTimeF32();
00792 
00793                 element_timer.reset();
00794                 mListVisibleMembers->addElement(row);//, ADD_SORTED);
00795                 sElementTime += element_timer.getElapsedTimeF32();
00796         }
00797         sAllTime += all_timer.getElapsedTimeF32();
00798 
00799         llinfos << "Updated " << i << " of " << UPDATE_MEMBERS_PER_FRAME << "members in the list." << llendl;
00800         if (mMemberProgress == end)
00801         {
00802                 llinfos << "   member list completed." << llendl;
00803                 mListVisibleMembers->setEnabled(TRUE);
00804 
00805                 llinfos << "All Time: " << sAllTime << llendl;
00806                 llinfos << "SD Time: " << sSDTime << llendl;
00807                 llinfos << "Element Time: " << sElementTime << llendl;
00808         }
00809         else
00810         {
00811                 mPendingMemberUpdate = TRUE;
00812                 mListVisibleMembers->setEnabled(FALSE);
00813         }
00814 }
00815 
00816 void LLPanelGroupGeneral::updateChanged()
00817 {
00818         // List all the controls we want to check for changes...
00819         LLUICtrl *check_list[] =
00820         {
00821                 mGroupNameEditor,
00822                 mGroupName,
00823                 mFounderName,
00824                 mInsignia,
00825                 mEditCharter,
00826                 mCtrlShowInGroupList,
00827                 mCtrlMature,
00828                 mCtrlOpenEnrollment,
00829                 mCtrlEnrollmentFee,
00830                 mSpinEnrollmentFee,
00831                 mCtrlReceiveNotices,
00832                 mCtrlListGroup,
00833                 mActiveTitleLabel,
00834                 mComboActiveTitle
00835         };
00836 
00837         mChanged = FALSE;
00838 
00839         for( int i= 0; i< sizeof(check_list)/sizeof(*check_list); i++ )
00840         {
00841                 if( check_list[i] && check_list[i]->isDirty() )
00842                 {
00843                         mChanged = TRUE;
00844                         break;
00845                 }
00846         }
00847 }

Generated on Thu Jul 1 06:08:57 2010 for Second Life Viewer by  doxygen 1.4.7