/indra/newview/llfloatergroupinvite.cpp
C++ | 148 lines | 85 code | 27 blank | 36 comment | 6 complexity | 8ee8663d1f660fa2c45bc9625296b254 MD5 | raw file
Possible License(s): LGPL-2.1
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 27#include "llviewerprecompiledheaders.h" 28 29#include "llfloatergroupinvite.h" 30#include "llpanelgroupinvite.h" 31#include "lltrans.h" 32#include "lldraghandle.h" 33 34class LLFloaterGroupInvite::impl 35{ 36public: 37 impl(const LLUUID& group_id); 38 ~impl(); 39 40 static void closeFloater(void* data); 41 42public: 43 LLUUID mGroupID; 44 LLPanelGroupInvite* mInvitePanelp; 45 46 static std::map<LLUUID, LLFloaterGroupInvite*> sInstances; 47}; 48 49// 50// Globals 51// 52std::map<LLUUID, LLFloaterGroupInvite*> LLFloaterGroupInvite::impl::sInstances; 53 54LLFloaterGroupInvite::impl::impl(const LLUUID& group_id) : 55 mGroupID(group_id), 56 mInvitePanelp(NULL) 57{ 58} 59 60LLFloaterGroupInvite::impl::~impl() 61{ 62} 63 64//static 65void LLFloaterGroupInvite::impl::closeFloater(void* data) 66{ 67 LLFloaterGroupInvite* floaterp = (LLFloaterGroupInvite*) data; 68 69 if ( floaterp ) floaterp->closeFloater(); 70} 71 72//----------------------------------------------------------------------------- 73// Implementation 74//----------------------------------------------------------------------------- 75LLFloaterGroupInvite::LLFloaterGroupInvite(const LLUUID& group_id) 76: LLFloater(group_id) 77{ 78 S32 floater_header_size = getHeaderHeight(); 79 LLRect contents; 80 81 mImpl = new impl(group_id); 82 83 mImpl->mInvitePanelp = new LLPanelGroupInvite(group_id); 84 85 contents = mImpl->mInvitePanelp->getRect(); 86 contents.mTop -= floater_header_size; 87 88 setTitle (mImpl->mInvitePanelp->getString("GroupInvitation")); 89 90 mImpl->mInvitePanelp->setCloseCallback(impl::closeFloater, this); 91 92 mImpl->mInvitePanelp->setRect(contents); 93 addChild(mImpl->mInvitePanelp); 94} 95 96// virtual 97LLFloaterGroupInvite::~LLFloaterGroupInvite() 98{ 99 if (mImpl->mGroupID.notNull()) 100 { 101 impl::sInstances.erase(mImpl->mGroupID); 102 } 103 104 delete mImpl->mInvitePanelp; 105 delete mImpl; 106} 107 108// static 109void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id, uuid_vec_t *agent_ids) 110{ 111 const LLFloater::Params& floater_params = LLFloater::getDefaultParams(); 112 S32 floater_header_size = floater_params.header_height; 113 LLRect contents; 114 115 // Make sure group_id isn't null 116 if (group_id.isNull()) 117 { 118 llwarns << "LLFloaterGroupInvite::showForGroup with null group_id!" << llendl; 119 return; 120 } 121 122 // If we don't have a floater for this group, create one. 123 LLFloaterGroupInvite *fgi = get_if_there(impl::sInstances, 124 group_id, 125 (LLFloaterGroupInvite*)NULL); 126 if (!fgi) 127 { 128 fgi = new LLFloaterGroupInvite(group_id); 129 contents = fgi->mImpl->mInvitePanelp->getRect(); 130 contents.mTop += floater_header_size; 131 fgi->setRect(contents); 132 fgi->getDragHandle()->setRect(contents); 133 fgi->getDragHandle()->setTitle(fgi->mImpl->mInvitePanelp->getString("GroupInvitation")); 134 135 impl::sInstances[group_id] = fgi; 136 137 fgi->mImpl->mInvitePanelp->clear(); 138 } 139 140 if (agent_ids != NULL) 141 { 142 fgi->mImpl->mInvitePanelp->addUsers(*agent_ids); 143 } 144 145 fgi->center(); 146 fgi->openFloater(); 147 fgi->mImpl->mInvitePanelp->update(); 148}