llpanelgroupgeneral.cpp

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

Generated on Fri May 16 08:33:52 2008 for SecondLife by  doxygen 1.5.5