summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatergroups.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatergroups.cpp')
-rw-r--r--indra/newview/llfloatergroups.cpp169
1 files changed, 43 insertions, 126 deletions
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 9e0b0d7230..b1f40d9d1d 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -41,27 +41,18 @@
#include "llfloatergroups.h"
-#include "message.h"
#include "roles_constants.h"
#include "llagent.h"
#include "llbutton.h"
-#include "llfloatergroupinfo.h"
-#include "llfloaterdirectory.h"
-#include "llfocusmgr.h"
-#include "llalertdialog.h"
-#include "llselectmgr.h"
+#include "llgroupactions.h"
#include "llscrolllistctrl.h"
#include "lltextbox.h"
#include "lluictrlfactory.h"
-#include "llviewerwindow.h"
-#include "llimview.h"
+#include "lltrans.h"
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);
@@ -69,44 +60,16 @@ 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::LLFloaterGroupPicker(const LLSD& seed)
+: LLFloater(seed),
+ mPowersMask(GP_ALL_POWERS),
+ mID(seed.asUUID())
{
- LLFloaterGroupPicker* pickerp = new LLFloaterGroupPicker(seed);
- LLUICtrlFactory::getInstance()->buildFloater(pickerp, "floater_choose_group.xml");
- return pickerp;
-}
-
-LLFloaterGroupPicker::LLFloaterGroupPicker(const LLSD& seed) :
- mSelectCallback(NULL),
- mCallbackUserdata(NULL),
- mPowersMask(GP_ALL_POWERS)
-{
- mID = seed.asUUID();
- sInstances.insert(std::make_pair(mID, this));
+// LLUICtrlFactory::getInstance()->buildFloater(this, "floater_choose_group.xml");
}
LLFloaterGroupPicker::~LLFloaterGroupPicker()
{
- sInstances.erase(mID);
-}
-
-void LLFloaterGroupPicker::setSelectCallback(void (*callback)(LLUUID, void*),
- void* userdata)
-{
- mSelectCallback = callback;
- mCallbackUserdata = userdata;
}
void LLFloaterGroupPicker::setPowersMask(U64 powers_mask)
@@ -118,7 +81,23 @@ void LLFloaterGroupPicker::setPowersMask(U64 powers_mask)
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);
+ }
+
+ // 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 = list_ctrl->getListInterface();
+ if(group_list)
+ {
+ group_list->selectByValue(LLUUID::null);
+ group_list->operateOnSelection(LLCtrlListInterface::OP_DELETE);
+ }
childSetAction("OK", onBtnOK, this);
@@ -126,9 +105,6 @@ BOOL LLFloaterGroupPicker::postBuild()
setDefaultBtn("OK");
- childSetDoubleClickCallback("group list", onBtnOK);
- childSetUserData("group list", this);
-
childEnable("OK");
return TRUE;
@@ -143,7 +119,7 @@ void LLFloaterGroupPicker::onBtnOK(void* userdata)
void LLFloaterGroupPicker::onBtnCancel(void* userdata)
{
LLFloaterGroupPicker* self = (LLFloaterGroupPicker*)userdata;
- if(self) self->close();
+ if(self) self->closeFloater();
}
@@ -155,12 +131,9 @@ void LLFloaterGroupPicker::ok()
{
group_id = group_list->getCurrentID();
}
- if(mSelectCallback)
- {
- mSelectCallback(group_id, mCallbackUserdata);
- }
+ mGroupSelectSignal(group_id);
- close();
+ closeFloater();
}
///----------------------------------------------------------------------------
@@ -213,7 +186,13 @@ BOOL LLPanelGroups::postBuild()
childSetTextArg("groupcount", "[COUNT]", llformat("%d",gAgent.mGroups.count()));
childSetTextArg("groupcount", "[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);
@@ -229,9 +208,6 @@ BOOL LLPanelGroups::postBuild()
setDefaultBtn("IM");
- childSetDoubleClickCallback("group list", onBtnIM);
- childSetUserData("group list", this);
-
reset();
return TRUE;
@@ -315,113 +291,54 @@ void LLPanelGroups::onBtnSearch(void* userdata)
void LLPanelGroups::create()
{
- llinfos << "LLPanelGroups::create" << llendl;
- LLFloaterGroupInfo::showCreateGroup(NULL);
+ LLGroupActions::createGroup();
}
void LLPanelGroups::activate()
{
- llinfos << "LLPanelGroups::activate" << llendl;
LLCtrlListInterface *group_list = childGetListInterface("group list");
LLUUID group_id;
if (group_list)
{
group_id = group_list->getCurrentID();
}
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessageFast(_PREHASH_ActivateGroup);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->addUUIDFast(_PREHASH_GroupID, group_id);
- gAgent.sendReliableMessage();
+ LLGroupActions::activate(group_id);
}
void LLPanelGroups::info()
{
- llinfos << "LLPanelGroups::info" << llendl;
LLCtrlListInterface *group_list = childGetListInterface("group list");
LLUUID group_id;
if (group_list && (group_id = group_list->getCurrentID()).notNull())
{
- LLFloaterGroupInfo::showFromUUID(group_id);
+ LLGroupActions::show(group_id);
}
}
void LLPanelGroups::startIM()
{
- //llinfos << "LLPanelFriends::onClickIM()" << llendl;
LLCtrlListInterface *group_list = childGetListInterface("group list");
LLUUID group_id;
if (group_list && (group_id = group_list->getCurrentID()).notNull())
{
- LLGroupData group_data;
- if (gAgent.getGroupData(group_id, group_data))
- {
- gIMMgr->setFloaterOpen(TRUE);
- gIMMgr->addSession(
- group_data.mName,
- IM_SESSION_GROUP_START,
- group_id);
- make_ui_sound("UISndStartIM");
- }
- else
- {
- // this should never happen, as starting a group IM session
- // relies on you belonging to the group and hence having the group data
- make_ui_sound("UISndInvalidOp");
- }
+ LLGroupActions::startChat(group_id);
}
}
void LLPanelGroups::leave()
{
- llinfos << "LLPanelGroups::leave" << llendl;
LLCtrlListInterface *group_list = childGetListInterface("group list");
LLUUID group_id;
if (group_list && (group_id = group_list->getCurrentID()).notNull())
{
- S32 count = gAgent.mGroups.count();
- S32 i;
- for(i = 0; i < count; ++i)
- {
- if(gAgent.mGroups.get(i).mID == group_id)
- break;
- }
- if(i < count)
- {
- LLSD args;
- args["GROUP"] = gAgent.mGroups.get(i).mName;
- LLSD payload;
- payload["group_id"] = group_id;
- LLNotifications::instance().add("GroupLeaveConfirmMember", args, payload, callbackLeaveGroup);
- }
+ LLGroupActions::leave(group_id);
}
}
void LLPanelGroups::search()
{
- LLFloaterDirectory::showGroups();
-}
-
-// static
-bool LLPanelGroups::callbackLeaveGroup(const LLSD& notification, const LLSD& response)
-{
- S32 option = LLNotification::getSelectedOption(notification, response);
- LLUUID group_id = notification["payload"]["group_id"].asUUID();
- if(option == 0)
- {
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessageFast(_PREHASH_LeaveGroupRequest);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_GroupData);
- msg->addUUIDFast(_PREHASH_GroupID, group_id);
- gAgent.sendReliableMessage();
- }
- return false;
+ LLGroupActions::search();
}
void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata)
@@ -456,7 +373,7 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow
element["columns"][0]["column"] = "name";
element["columns"][0]["value"] = group_datap->mName;
element["columns"][0]["font"] = "SANSSERIF";
- element["columns"][0]["font-style"] = style;
+ element["columns"][0]["font"]["style"] = style;
group_list->addElement(element, ADD_SORTED);
}
@@ -472,9 +389,9 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow
LLSD element;
element["id"] = LLUUID::null;
element["columns"][0]["column"] = "name";
- element["columns"][0]["value"] = "none"; // *TODO: Translate
+ element["columns"][0]["value"] = LLTrans::getString("GroupsNone");
element["columns"][0]["font"] = "SANSSERIF";
- element["columns"][0]["font-style"] = style;
+ element["columns"][0]["font"]["style"] = style;
group_list->addElement(element, ADD_TOP);
}