summaryrefslogtreecommitdiff
path: root/indra/newview/llimfloatercontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llimfloatercontainer.cpp')
-rw-r--r--indra/newview/llimfloatercontainer.cpp145
1 files changed, 78 insertions, 67 deletions
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 4d2201ebb9..01456fee3b 100644
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -98,8 +98,8 @@ LLIMFloaterContainer::~LLIMFloaterContainer()
void LLIMFloaterContainer::sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
{
- LLIMFloater::addToHost(session_id);
addConversationListItem(session_id);
+ LLIMFloater::addToHost(session_id);
}
void LLIMFloaterContainer::sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id)
@@ -109,12 +109,13 @@ void LLIMFloaterContainer::sessionActivated(const LLUUID& session_id, const std:
void LLIMFloaterContainer::sessionVoiceOrIMStarted(const LLUUID& session_id)
{
- LLIMFloater::addToHost(session_id);
addConversationListItem(session_id);
+ LLIMFloater::addToHost(session_id);
}
void LLIMFloaterContainer::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id)
{
+ // CHUI-441 : We should do this *without* delete and recreate
addConversationListItem(new_session_id, removeConversationListItem(old_session_id));
}
@@ -407,7 +408,7 @@ bool LLIMFloaterContainer::onConversationModelEvent(const LLSD& event)
// For debug only
//std::ostringstream llsd_value;
//llsd_value << LLSDOStreamer<LLSDNotationFormatter>(event) << std::endl;
- //llinfos << "Merov debug : onConversationModelEvent, event = " << llsd_value.str() << llendl;
+ //llinfos << "LLIMFloaterContainer::onConversationModelEvent, event = " << llsd_value.str() << llendl;
// end debug
// Note: In conversations, the model is not responsible for creating the view, which is a good thing. This means that
@@ -421,16 +422,18 @@ bool LLIMFloaterContainer::onConversationModelEvent(const LLSD& event)
LLUUID session_id = event.get("session_uuid").asUUID();
LLUUID participant_id = event.get("participant_uuid").asUUID();
- LLConversationViewSession* session_view = dynamic_cast<LLConversationViewSession*>(mConversationsWidgets[session_id]);
+ LLConversationViewSession* session_view = dynamic_cast<LLConversationViewSession*>(get_ptr_in_map(mConversationsWidgets,session_id));
if (!session_view)
{
- // We skip events that are not associated to a session
+ // We skip events that are not associated with a session
return false;
}
LLConversationViewParticipant* participant_view = session_view->findParticipant(participant_id);
+ LLIMConversation *conversation_floater = (session_id.isNull() ? (LLIMConversation*)(LLFloaterReg::findTypedInstance<LLNearbyChat>("nearby_chat")) : (LLIMConversation*)(LLIMFloater::findInstance(session_id)));
if (type == "remove_participant")
{
+ // Remove a participant view from the hierarchical conversation list
if (participant_view)
{
session_view->extractItem(participant_view);
@@ -438,35 +441,49 @@ bool LLIMFloaterContainer::onConversationModelEvent(const LLSD& event)
session_view->refresh();
mConversationsRoot->arrangeAll();
}
+ // Remove a participant view from the conversation floater
+ if (conversation_floater)
+ {
+ conversation_floater->removeConversationViewParticipant(participant_id);
+ }
}
else if (type == "add_participant")
{
- if (!participant_view)
+ LLConversationItemSession* session_model = dynamic_cast<LLConversationItemSession*>(get_ptr_in_map(mConversationsItems,session_id));
+ LLConversationItemParticipant* participant_model = (session_model ? session_model->findParticipant(participant_id) : NULL);
+ // Add a participant view to the hierarchical conversation list
+ if (!participant_view && session_model && participant_model)
{
- LLConversationItemSession* session_model = dynamic_cast<LLConversationItemSession*>(mConversationsItems[session_id]);
- if (session_model)
- {
- LLConversationItemParticipant* participant_model = session_model->findParticipant(participant_id);
- if (participant_model)
- {
- participant_view = createConversationViewParticipant(participant_model);
- participant_view->addToFolder(session_view);
- participant_view->setVisible(TRUE);
- }
- }
-
+ participant_view = createConversationViewParticipant(participant_model);
+ participant_view->addToFolder(session_view);
+ participant_view->setVisible(TRUE);
+ }
+ // Add a participant view to the conversation floater
+ if (conversation_floater && participant_model)
+ {
+ conversation_floater->addConversationViewParticipant(participant_model);
}
}
else if (type == "update_participant")
{
+ // Update the participant view in the hierarchical conversation list
if (participant_view)
{
participant_view->refresh();
}
+ // Update the participant view in the conversation floater
+ if (conversation_floater)
+ {
+ conversation_floater->updateConversationViewParticipant(participant_id);
+ }
}
else if (type == "update_session")
{
session_view->refresh();
+ if (conversation_floater)
+ {
+ conversation_floater->refreshConversation();
+ }
}
mConversationViewModel.requestSortAll();
@@ -1097,10 +1114,10 @@ void LLIMFloaterContainer::showConversation(const LLUUID& session_id)
selectConversation(session_id);
}
-//Will select only the conversation item
+// Will select only the conversation item
void LLIMFloaterContainer::selectConversation(const LLUUID& session_id)
{
- LLFolderViewItem* widget = mConversationsWidgets[session_id];
+ LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,session_id);
if (widget)
{
(widget->getRoot())->setSelection(widget, FALSE, FALSE);
@@ -1110,63 +1127,55 @@ void LLIMFloaterContainer::selectConversation(const LLUUID& session_id)
void LLIMFloaterContainer::setTimeNow(const LLUUID& session_id, const LLUUID& participant_id)
{
- conversations_items_map::iterator item_it = mConversationsItems.find(session_id);
- if (item_it != mConversationsItems.end())
+ LLConversationItemSession* item = dynamic_cast<LLConversationItemSession*>(get_ptr_in_map(mConversationsItems,session_id));
+ if (item)
{
- LLConversationItemSession* item = dynamic_cast<LLConversationItemSession*>(item_it->second);
- if (item)
- {
- item->setTimeNow(participant_id);
- mConversationViewModel.requestSortAll();
- mConversationsRoot->arrangeAll();
- }
+ item->setTimeNow(participant_id);
+ mConversationViewModel.requestSortAll();
+ mConversationsRoot->arrangeAll();
}
}
void LLIMFloaterContainer::setNearbyDistances()
{
- // Get the nearby chat session: that's the one with uuid nul in mConversationsItems
- conversations_items_map::iterator item_it = mConversationsItems.find(LLUUID());
- if (item_it != mConversationsItems.end())
- {
- LLConversationItemSession* item = dynamic_cast<LLConversationItemSession*>(item_it->second);
- if (item)
+ // Get the nearby chat session: that's the one with uuid nul
+ LLConversationItemSession* item = dynamic_cast<LLConversationItemSession*>(get_ptr_in_map(mConversationsItems,LLUUID()));
+ if (item)
+ {
+ // Get the positions of the nearby avatars and their ids
+ std::vector<LLVector3d> positions;
+ uuid_vec_t avatar_ids;
+ LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("NearMeRange"));
+ // Get the position of the agent
+ const LLVector3d& me_pos = gAgent.getPositionGlobal();
+ // For each nearby avatar, compute and update the distance
+ int avatar_count = positions.size();
+ for (int i = 0; i < avatar_count; i++)
{
- // Get the positions of the nearby avatars and their ids
- std::vector<LLVector3d> positions;
- uuid_vec_t avatar_ids;
- LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("NearMeRange"));
- // Get the position of the agent
- const LLVector3d& me_pos = gAgent.getPositionGlobal();
- // For each nearby avatar, compute and update the distance
- int avatar_count = positions.size();
- for (int i = 0; i < avatar_count; i++)
- {
- F64 dist = dist_vec_squared(positions[i], me_pos);
- item->setDistance(avatar_ids[i],dist);
- }
- // Also does it for the agent itself
- item->setDistance(gAgent.getID(),0.0f);
- // Request resort
- mConversationViewModel.requestSortAll();
- mConversationsRoot->arrangeAll();
+ F64 dist = dist_vec_squared(positions[i], me_pos);
+ item->setDistance(avatar_ids[i],dist);
}
+ // Also does it for the agent itself
+ item->setDistance(gAgent.getID(),0.0f);
+ // Request resort
+ mConversationViewModel.requestSortAll();
+ mConversationsRoot->arrangeAll();
}
}
-void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWidgetSelected /*= false*/)
+LLConversationItem* LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWidgetSelected /*= false*/)
{
bool is_nearby_chat = uuid.isNull();
- //Stores the display name for the conversation line item
+ // Stores the display name for the conversation line item
std::string display_name = is_nearby_chat ? LLTrans::getString("NearbyChatLabel") : LLIMModel::instance().getName(uuid);
- // Check if the item is not already in the list, exit if it is and has the same name and uuid (nothing to do)
+ // Check if the item is not already in the list, exit (nothing to do)
// Note: this happens often, when reattaching a torn off conversation for instance
conversations_items_map::iterator item_it = mConversationsItems.find(uuid);
if (item_it != mConversationsItems.end())
{
- return;
+ return item_it->second;
}
// Remove the conversation item that might exist already: it'll be recreated anew further down anyway
@@ -1183,7 +1192,7 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWi
if (!item)
{
llwarns << "Couldn't create conversation session item : " << display_name << llendl;
- return;
+ return NULL;
}
item->renameItem(display_name);
item->updateParticipantName(NULL);
@@ -1209,6 +1218,12 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWi
participant_view->addToFolder(widget);
current_participant_model++;
}
+ // Do that too for the conversation dialog
+ LLIMConversation *conversation_floater = (uuid.isNull() ? (LLIMConversation*)(LLFloaterReg::findTypedInstance<LLNearbyChat>("nearby_chat")) : (LLIMConversation*)(LLIMFloater::findInstance(uuid)));
+ if (conversation_floater)
+ {
+ conversation_floater->buildConversationViewParticipant();
+ }
// set the widget to minimized mode if conversations pane is collapsed
widget->toggleMinimizedMode(mConversationsPane->isCollapsed());
@@ -1220,7 +1235,7 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid, bool isWi
mConversationsRoot->scrollToShowSelection();
}
- return;
+ return item;
}
bool LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool change_focus)
@@ -1229,15 +1244,11 @@ bool LLIMFloaterContainer::removeConversationListItem(const LLUUID& uuid, bool c
// Note : since the mConversationsItems is also the listener to the widget, deleting
// the widget will also delete its listener
bool isWidgetSelected = false;
- conversations_widgets_map::iterator widget_it = mConversationsWidgets.find(uuid);
- if (widget_it != mConversationsWidgets.end())
+ LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,uuid);
+ if (widget)
{
- LLFolderViewItem* widget = widget_it->second;
- if (widget)
- {
- isWidgetSelected = widget->isSelected();
- widget->destroyView();
- }
+ isWidgetSelected = widget->isSelected();
+ widget->destroyView();
}
// Suppress the conversation items and widgets from their respective maps