diff options
Diffstat (limited to 'linden/indra/newview/llpanelgroupinvite.cpp')
-rw-r--r-- | linden/indra/newview/llpanelgroupinvite.cpp | 146 |
1 files changed, 130 insertions, 16 deletions
diff --git a/linden/indra/newview/llpanelgroupinvite.cpp b/linden/indra/newview/llpanelgroupinvite.cpp index 7e5429f..4078c6d 100644 --- a/linden/indra/newview/llpanelgroupinvite.cpp +++ b/linden/indra/newview/llpanelgroupinvite.cpp | |||
@@ -36,6 +36,9 @@ | |||
36 | #include "llgroupmgr.h" | 36 | #include "llgroupmgr.h" |
37 | #include "llnamelistctrl.h" | 37 | #include "llnamelistctrl.h" |
38 | #include "llspinctrl.h" | 38 | #include "llspinctrl.h" |
39 | #include "lltextbox.h" | ||
40 | #include "llviewerobject.h" | ||
41 | #include "llviewerobjectlist.h" | ||
39 | #include "llvieweruictrlfactory.h" | 42 | #include "llvieweruictrlfactory.h" |
40 | 43 | ||
41 | class LLPanelGroupInvite::impl | 44 | class LLPanelGroupInvite::impl |
@@ -65,7 +68,9 @@ public: | |||
65 | 68 | ||
66 | LLNameListCtrl *mInvitees; | 69 | LLNameListCtrl *mInvitees; |
67 | LLComboBox *mRoleNames; | 70 | LLComboBox *mRoleNames; |
68 | LLButton *mRemoveButton; | 71 | LLButton *mOKButton; |
72 | LLButton *mRemoveButton; | ||
73 | LLTextBox *mGroupName; | ||
69 | 74 | ||
70 | void (*mCloseCallback)(void* data); | 75 | void (*mCloseCallback)(void* data); |
71 | 76 | ||
@@ -308,6 +313,8 @@ LLPanelGroupInvite::LLPanelGroupInvite(const std::string& name, | |||
308 | : LLPanel(name) | 313 | : LLPanel(name) |
309 | { | 314 | { |
310 | mImplementation = new impl(group_id); | 315 | mImplementation = new impl(group_id); |
316 | mPendingUpdate = FALSE; | ||
317 | mStoreSelected = LLUUID::null; | ||
311 | 318 | ||
312 | std::string panel_def_file; | 319 | std::string panel_def_file; |
313 | 320 | ||
@@ -329,29 +336,132 @@ void LLPanelGroupInvite::setCloseCallback(void (*close_callback)(void*), | |||
329 | 336 | ||
330 | void LLPanelGroupInvite::clear() | 337 | void LLPanelGroupInvite::clear() |
331 | { | 338 | { |
339 | mStoreSelected = LLUUID::null; | ||
332 | mImplementation->mInvitees->deleteAllItems(); | 340 | mImplementation->mInvitees->deleteAllItems(); |
333 | mImplementation->mRoleNames->clear(); | 341 | mImplementation->mRoleNames->clear(); |
334 | mImplementation->mRoleNames->removeall(); | 342 | mImplementation->mRoleNames->removeall(); |
343 | mImplementation->mOKButton->setEnabled(FALSE); | ||
335 | } | 344 | } |
336 | 345 | ||
346 | void LLPanelGroupInvite::addUsers(std::vector<LLUUID>& agent_ids) | ||
347 | { | ||
348 | std::vector<std::string> names; | ||
349 | for (S32 i = 0; i < (S32)agent_ids.size(); i++) | ||
350 | { | ||
351 | LLUUID agent_id = agent_ids[i]; | ||
352 | LLViewerObject* dest = gObjectList.findObject(agent_id); | ||
353 | if(dest && dest->isAvatar()) | ||
354 | { | ||
355 | LLString fullname; | ||
356 | LLString::format_map_t args; | ||
357 | LLNameValue* nvfirst = dest->getNVPair("FirstName"); | ||
358 | LLNameValue* nvlast = dest->getNVPair("LastName"); | ||
359 | if(nvfirst && nvlast) | ||
360 | { | ||
361 | args["[FIRST]"] = nvfirst->getString(); | ||
362 | args["[LAST]"] = nvlast->getString(); | ||
363 | fullname = nvfirst->getString(); | ||
364 | fullname += " "; | ||
365 | fullname += nvlast->getString(); | ||
366 | } | ||
367 | if (!fullname.empty()) | ||
368 | { | ||
369 | names.push_back(fullname); | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl; | ||
374 | names.push_back("(Unknown)"); | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | mImplementation->addUsers(names, agent_ids); | ||
379 | } | ||
380 | |||
381 | void LLPanelGroupInvite::draw() | ||
382 | { | ||
383 | LLPanel::draw(); | ||
384 | if (mPendingUpdate) | ||
385 | { | ||
386 | updateLists(); | ||
387 | } | ||
388 | } | ||
389 | |||
337 | void LLPanelGroupInvite::update() | 390 | void LLPanelGroupInvite::update() |
338 | { | 391 | { |
392 | mPendingUpdate = FALSE; | ||
393 | if (mImplementation->mGroupName) | ||
394 | { | ||
395 | mImplementation->mGroupName->setText("(loading...)"); | ||
396 | } | ||
397 | if ( mImplementation->mRoleNames ) | ||
398 | { | ||
399 | mStoreSelected = mImplementation->mRoleNames->getCurrentID(); | ||
400 | mImplementation->mRoleNames->clear(); | ||
401 | mImplementation->mRoleNames->removeall(); | ||
402 | mImplementation->mRoleNames->add("(loading...)", LLUUID::null, ADD_BOTTOM); | ||
403 | mImplementation->mRoleNames->setCurrentByID(LLUUID::null); | ||
404 | } | ||
405 | |||
406 | updateLists(); | ||
407 | } | ||
408 | |||
409 | void LLPanelGroupInvite::updateLists() | ||
410 | { | ||
339 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mImplementation->mGroupID); | 411 | LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mImplementation->mGroupID); |
412 | BOOL waiting = FALSE; | ||
340 | 413 | ||
341 | if (!gdatap || !gdatap->isRoleDataComplete()) | 414 | if (gdatap) |
415 | { | ||
416 | if (gdatap->isGroupPropertiesDataComplete()) | ||
417 | { | ||
418 | if (mImplementation->mGroupName) | ||
419 | { | ||
420 | mImplementation->mGroupName->setText(gdatap->mName); | ||
421 | } | ||
422 | } | ||
423 | else | ||
424 | { | ||
425 | waiting = TRUE; | ||
426 | } | ||
427 | if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete()) | ||
428 | { | ||
429 | if ( mImplementation->mRoleNames ) | ||
430 | { | ||
431 | mImplementation->mRoleNames->clear(); | ||
432 | mImplementation->mRoleNames->removeall(); | ||
433 | |||
434 | //add the role names and select the everybody role by default | ||
435 | mImplementation->addRoleNames(gdatap); | ||
436 | mImplementation->mRoleNames->setCurrentByID(mStoreSelected); | ||
437 | } | ||
438 | } | ||
439 | else | ||
440 | { | ||
441 | waiting = TRUE; | ||
442 | } | ||
443 | } | ||
444 | else | ||
342 | { | 445 | { |
343 | gGroupMgr->sendGroupRoleDataRequest(mImplementation->mGroupID); | 446 | waiting = TRUE; |
344 | } | 447 | } |
448 | |||
449 | if (waiting) | ||
450 | { | ||
451 | if (!mPendingUpdate) | ||
452 | { | ||
453 | gGroupMgr->sendGroupPropertiesRequest(mImplementation->mGroupID); | ||
454 | gGroupMgr->sendGroupMembersRequest(mImplementation->mGroupID); | ||
455 | gGroupMgr->sendGroupRoleDataRequest(mImplementation->mGroupID); | ||
456 | } | ||
457 | mPendingUpdate = TRUE; | ||
458 | } | ||
345 | else | 459 | else |
346 | { | 460 | { |
347 | if ( mImplementation->mRoleNames ) | 461 | mPendingUpdate = FALSE; |
462 | if (mImplementation->mOKButton && mImplementation->mRoleNames->getItemCount()) | ||
348 | { | 463 | { |
349 | mImplementation->mRoleNames->clear(); | 464 | mImplementation->mOKButton->setEnabled(TRUE); |
350 | mImplementation->mRoleNames->removeall(); | ||
351 | |||
352 | //add the role names and select the everybody role by default | ||
353 | mImplementation->addRoleNames(gdatap); | ||
354 | mImplementation->mRoleNames->setCurrentByID(LLUUID::null); | ||
355 | } | 465 | } |
356 | } | 466 | } |
357 | } | 467 | } |
@@ -362,6 +472,7 @@ BOOL LLPanelGroupInvite::postBuild() | |||
362 | 472 | ||
363 | mImplementation->mRoleNames = (LLComboBox*) getChildByName("role_name", | 473 | mImplementation->mRoleNames = (LLComboBox*) getChildByName("role_name", |
364 | recurse); | 474 | recurse); |
475 | mImplementation->mGroupName = (LLTextBox*) getChildByName("group_name_text", recurse); | ||
365 | mImplementation->mInvitees = | 476 | mImplementation->mInvitees = |
366 | (LLNameListCtrl*) getChildByName("invitee_list", recurse); | 477 | (LLNameListCtrl*) getChildByName("invitee_list", recurse); |
367 | if ( mImplementation->mInvitees ) | 478 | if ( mImplementation->mInvitees ) |
@@ -390,12 +501,15 @@ BOOL LLPanelGroupInvite::postBuild() | |||
390 | mImplementation->mRemoveButton->setEnabled(FALSE); | 501 | mImplementation->mRemoveButton->setEnabled(FALSE); |
391 | } | 502 | } |
392 | 503 | ||
393 | button = (LLButton*) getChildByName("ok_button", recurse); | 504 | mImplementation->mOKButton = |
394 | if ( button ) | 505 | (LLButton*) getChildByName("ok_button", recurse); |
395 | { | 506 | if ( mImplementation->mOKButton ) |
396 | button->setClickedCallback(impl::callbackClickOK); | 507 | { |
397 | button->setCallbackUserData(mImplementation); | 508 | mImplementation->mOKButton-> |
398 | } | 509 | setClickedCallback(impl::callbackClickOK); |
510 | mImplementation->mOKButton->setCallbackUserData(mImplementation); | ||
511 | mImplementation->mOKButton->setEnabled(FALSE); | ||
512 | } | ||
399 | 513 | ||
400 | button = (LLButton*) getChildByName("cancel_button", recurse); | 514 | button = (LLButton*) getChildByName("cancel_button", recurse); |
401 | if ( button ) | 515 | if ( button ) |