/indra/newview/llfloatergroupinvite.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 148 lines · 85 code · 27 blank · 36 comment · 6 complexity · 8ee8663d1f660fa2c45bc9625296b254 MD5 · raw file

  1. /**
  2. * @file llfloatergroupinvite.cpp
  3. * @brief Floater to invite new members into a group.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfloatergroupinvite.h"
  28. #include "llpanelgroupinvite.h"
  29. #include "lltrans.h"
  30. #include "lldraghandle.h"
  31. class LLFloaterGroupInvite::impl
  32. {
  33. public:
  34. impl(const LLUUID& group_id);
  35. ~impl();
  36. static void closeFloater(void* data);
  37. public:
  38. LLUUID mGroupID;
  39. LLPanelGroupInvite* mInvitePanelp;
  40. static std::map<LLUUID, LLFloaterGroupInvite*> sInstances;
  41. };
  42. //
  43. // Globals
  44. //
  45. std::map<LLUUID, LLFloaterGroupInvite*> LLFloaterGroupInvite::impl::sInstances;
  46. LLFloaterGroupInvite::impl::impl(const LLUUID& group_id) :
  47. mGroupID(group_id),
  48. mInvitePanelp(NULL)
  49. {
  50. }
  51. LLFloaterGroupInvite::impl::~impl()
  52. {
  53. }
  54. //static
  55. void LLFloaterGroupInvite::impl::closeFloater(void* data)
  56. {
  57. LLFloaterGroupInvite* floaterp = (LLFloaterGroupInvite*) data;
  58. if ( floaterp ) floaterp->closeFloater();
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Implementation
  62. //-----------------------------------------------------------------------------
  63. LLFloaterGroupInvite::LLFloaterGroupInvite(const LLUUID& group_id)
  64. : LLFloater(group_id)
  65. {
  66. S32 floater_header_size = getHeaderHeight();
  67. LLRect contents;
  68. mImpl = new impl(group_id);
  69. mImpl->mInvitePanelp = new LLPanelGroupInvite(group_id);
  70. contents = mImpl->mInvitePanelp->getRect();
  71. contents.mTop -= floater_header_size;
  72. setTitle (mImpl->mInvitePanelp->getString("GroupInvitation"));
  73. mImpl->mInvitePanelp->setCloseCallback(impl::closeFloater, this);
  74. mImpl->mInvitePanelp->setRect(contents);
  75. addChild(mImpl->mInvitePanelp);
  76. }
  77. // virtual
  78. LLFloaterGroupInvite::~LLFloaterGroupInvite()
  79. {
  80. if (mImpl->mGroupID.notNull())
  81. {
  82. impl::sInstances.erase(mImpl->mGroupID);
  83. }
  84. delete mImpl->mInvitePanelp;
  85. delete mImpl;
  86. }
  87. // static
  88. void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id, uuid_vec_t *agent_ids)
  89. {
  90. const LLFloater::Params& floater_params = LLFloater::getDefaultParams();
  91. S32 floater_header_size = floater_params.header_height;
  92. LLRect contents;
  93. // Make sure group_id isn't null
  94. if (group_id.isNull())
  95. {
  96. llwarns << "LLFloaterGroupInvite::showForGroup with null group_id!" << llendl;
  97. return;
  98. }
  99. // If we don't have a floater for this group, create one.
  100. LLFloaterGroupInvite *fgi = get_if_there(impl::sInstances,
  101. group_id,
  102. (LLFloaterGroupInvite*)NULL);
  103. if (!fgi)
  104. {
  105. fgi = new LLFloaterGroupInvite(group_id);
  106. contents = fgi->mImpl->mInvitePanelp->getRect();
  107. contents.mTop += floater_header_size;
  108. fgi->setRect(contents);
  109. fgi->getDragHandle()->setRect(contents);
  110. fgi->getDragHandle()->setTitle(fgi->mImpl->mInvitePanelp->getString("GroupInvitation"));
  111. impl::sInstances[group_id] = fgi;
  112. fgi->mImpl->mInvitePanelp->clear();
  113. }
  114. if (agent_ids != NULL)
  115. {
  116. fgi->mImpl->mInvitePanelp->addUsers(*agent_ids);
  117. }
  118. fgi->center();
  119. fgi->openFloater();
  120. fgi->mImpl->mInvitePanelp->update();
  121. }