diff options
Diffstat (limited to 'indra/newview/llfloatergroups.cpp')
-rw-r--r-- | indra/newview/llfloatergroups.cpp | 157 |
1 files changed, 72 insertions, 85 deletions
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp index a967a1833f..234a09d157 100644 --- a/indra/newview/llfloatergroups.cpp +++ b/indra/newview/llfloatergroups.cpp @@ -2,31 +2,25 @@ * @file llfloatergroups.cpp * @brief LLPanelGroups class implementation * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -53,9 +47,6 @@ using namespace LLOldEvents; -// static -std::map<const LLUUID, LLFloaterGroupPicker*> LLFloaterGroupPicker::sInstances; - // helper functions void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 powers_mask = GP_ALL_POWERS); @@ -63,62 +54,60 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow /// Class LLFloaterGroupPicker ///---------------------------------------------------------------------------- -// static -LLFloaterGroupPicker* LLFloaterGroupPicker::findInstance(const LLSD& seed) -{ - instance_map_t::iterator found_it = sInstances.find(seed.asUUID()); - if (found_it != sInstances.end()) - { - return found_it->second; - } - return NULL; -} - -// static -LLFloaterGroupPicker* LLFloaterGroupPicker::createInstance(const LLSD &seed) -{ - LLFloaterGroupPicker* pickerp = new LLFloaterGroupPicker(seed); - return pickerp; -} - LLFloaterGroupPicker::LLFloaterGroupPicker(const LLSD& seed) -: LLFloater(), - mPowersMask(GP_ALL_POWERS) +: LLFloater(seed), + mPowersMask(GP_ALL_POWERS), + mID(seed.asUUID()) { - mID = seed.asUUID(); - sInstances.insert(std::make_pair(mID, this)); - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_choose_group.xml"); +// LLUICtrlFactory::getInstance()->buildFloater(this, "floater_choose_group.xml"); } LLFloaterGroupPicker::~LLFloaterGroupPicker() { - sInstances.erase(mID); } void LLFloaterGroupPicker::setPowersMask(U64 powers_mask) { mPowersMask = powers_mask; - postBuild(); + init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID(), mPowersMask); } BOOL LLFloaterGroupPicker::postBuild() { - init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID(), mPowersMask); - + LLScrollListCtrl* list_ctrl = getChild<LLScrollListCtrl>("group list"); + if (list_ctrl) + { + init_group_list(list_ctrl, gAgent.getGroupID(), mPowersMask); + list_ctrl->setDoubleClickCallback(onBtnOK, this); + list_ctrl->setContextMenu(LLScrollListCtrl::MENU_GROUP); + } + childSetAction("OK", onBtnOK, this); childSetAction("Cancel", onBtnCancel, this); setDefaultBtn("OK"); - getChild<LLScrollListCtrl>("group list")->setDoubleClickCallback(onBtnOK, this); - - childEnable("OK"); + getChildView("OK")->setEnabled(TRUE); return TRUE; } +void LLFloaterGroupPicker::removeNoneOption() +{ + // Remove group "none" from list. Group "none" is added in init_group_list(). + // Some UI elements use group "none", we need to manually delete it here. + // Group "none" ID is LLUUID:null. + LLCtrlListInterface* group_list = getChild<LLScrollListCtrl>("group list")->getListInterface(); + if(group_list) + { + group_list->selectByValue(LLUUID::null); + group_list->operateOnSelection(LLCtrlListInterface::OP_DELETE); + } +} + + void LLFloaterGroupPicker::onBtnOK(void* userdata) { LLFloaterGroupPicker* self = (LLFloaterGroupPicker*)userdata; @@ -181,8 +170,8 @@ void LLPanelGroups::reset() { group_list->operateOnAll(LLCtrlListInterface::OP_DELETE); } - childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count())); - childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS)); + getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count())); + getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS)); init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID()); enableButtons(); @@ -192,10 +181,16 @@ BOOL LLPanelGroups::postBuild() { childSetCommitCallback("group list", onGroupList, this); - childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count())); - childSetTextArg("groupcount", "[MAX]", llformat("%d",MAX_AGENT_GROUPS)); + getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count())); + getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",MAX_AGENT_GROUPS)); - init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID()); + LLScrollListCtrl *list = getChild<LLScrollListCtrl>("group list"); + if (list) + { + init_group_list(list, gAgent.getGroupID()); + list->setDoubleClickCallback(onBtnIM, this); + list->setContextMenu(LLScrollListCtrl::MENU_GROUP); + } childSetAction("Activate", onBtnActivate, this); @@ -211,8 +206,6 @@ BOOL LLPanelGroups::postBuild() setDefaultBtn("IM"); - getChild<LLScrollListCtrl>("group list")->setDoubleClickCallback(onBtnIM, this); - reset(); return TRUE; @@ -229,32 +222,25 @@ void LLPanelGroups::enableButtons() if(group_id != gAgent.getGroupID()) { - childEnable("Activate"); + getChildView("Activate")->setEnabled(TRUE); } else { - childDisable("Activate"); + getChildView("Activate")->setEnabled(FALSE); } if (group_id.notNull()) { - childEnable("Info"); - childEnable("IM"); - childEnable("Leave"); - } - else - { - childDisable("Info"); - childDisable("IM"); - childDisable("Leave"); - } - if(gAgent.mGroups.count() < MAX_AGENT_GROUPS) - { - childEnable("Create"); + getChildView("Info")->setEnabled(TRUE); + getChildView("IM")->setEnabled(TRUE); + getChildView("Leave")->setEnabled(TRUE); } else { - childDisable("Create"); + getChildView("Info")->setEnabled(FALSE); + getChildView("IM")->setEnabled(FALSE); + getChildView("Leave")->setEnabled(FALSE); } + getChildView("Create")->setEnabled(gAgent.canJoinGroups()); } @@ -296,7 +282,7 @@ void LLPanelGroups::onBtnSearch(void* userdata) void LLPanelGroups::create() { - LLGroupActions::create(); + LLGroupActions::createGroup(); } void LLPanelGroups::activate() @@ -316,7 +302,7 @@ void LLPanelGroups::info() LLUUID group_id; if (group_list && (group_id = group_list->getCurrentID()).notNull()) { - LLGroupActions::info(group_id); + LLGroupActions::show(group_id); } } @@ -327,7 +313,7 @@ void LLPanelGroups::startIM() if (group_list && (group_id = group_list->getCurrentID()).notNull()) { - LLGroupActions::startChat(group_id); + LLGroupActions::startIM(group_id); } } @@ -352,11 +338,10 @@ void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata) if(self) self->enableButtons(); } -void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 powers_mask) +void init_group_list(LLScrollListCtrl* group_list, const LLUUID& highlight_id, U64 powers_mask) { S32 count = gAgent.mGroups.count(); LLUUID id; - LLCtrlListInterface *group_list = ctrl->getListInterface(); if (!group_list) return; group_list->operateOnAll(LLCtrlListInterface::OP_DELETE); @@ -377,13 +362,15 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow element["id"] = id; element["columns"][0]["column"] = "name"; element["columns"][0]["value"] = group_datap->mName; - element["columns"][0]["font"] = "SANSSERIF"; + element["columns"][0]["font"]["name"] = "SANSSERIF"; element["columns"][0]["font"]["style"] = style; - group_list->addElement(element, ADD_SORTED); + group_list->addElement(element); } } + group_list->sortOnce(0, TRUE); + // add "none" to list at top { std::string style = "NORMAL"; @@ -395,7 +382,7 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow element["id"] = LLUUID::null; element["columns"][0]["column"] = "name"; element["columns"][0]["value"] = LLTrans::getString("GroupsNone"); - element["columns"][0]["font"] = "SANSSERIF"; + element["columns"][0]["font"]["name"] = "SANSSERIF"; element["columns"][0]["font"]["style"] = style; group_list->addElement(element, ADD_TOP); |