Merge branch 'master' of git://github.com/siana/SingularityViewer

This commit is contained in:
Inusaito
2011-12-24 03:44:08 -05:00
2 changed files with 196 additions and 90 deletions

View File

@@ -1622,118 +1622,144 @@ void LLInventoryPanel::modelChanged(U32 mask)
LLFastTimer t2(LLFastTimer::FTM_REFRESH);
bool handled = false;
if(mask & LLInventoryObserver::LABEL)
//if (!mViewsInitialized) return;
const LLInventoryModel* model = getModel();
if (!model) return;
const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs();
if (changed_items.empty()) return;
for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin();
items_iter != changed_items.end();
++items_iter)
{
handled = true;
// label change - empty out the display name for each object
// in this change set.
const std::set<LLUUID>& changed_items = gInventory.getChangedIDs();
std::set<LLUUID>::const_iterator id_it = changed_items.begin();
std::set<LLUUID>::const_iterator id_end = changed_items.end();
LLFolderViewItem* view = NULL;
LLInvFVBridge* bridge = NULL;
for (;id_it != id_end; ++id_it)
const LLUUID& item_id = (*items_iter);
const LLInventoryObject* model_item = model->getObject(item_id);
LLFolderViewItem* view_item = getRootFolder()->getItemByID(item_id);
// LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item
// to folder is the fast way to get a folder without searching through folders tree.
//LLFolderViewFolder* view_folder = dynamic_cast<LLFolderViewFolder*>(view_item);
//////////////////////////////
// LABEL Operation
// Empty out the display name for relabel.
if (mask & LLInventoryObserver::LABEL)
{
view = mFolders->getItemByID(*id_it);
if(view)
handled = true;
if (view_item)
{
// request refresh on this item (also flags for filtering)
bridge = (LLInvFVBridge*)view->getListener();
// Request refresh on this item (also flags for filtering)
LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener();
if(bridge)
{ // Clear the display name first, so it gets properly re-built during refresh()
bridge->clearDisplayName();
view_item->refresh();
}
view->refresh();
}
}
}
if((mask & (LLInventoryObserver::STRUCTURE
| LLInventoryObserver::ADD
| LLInventoryObserver::REMOVE)) != 0)
{
handled = true;
// Record which folders are open by uuid.
LLInventoryModel* model = getModel();
if (model)
//////////////////////////////
// REBUILD Operation
// Destroy and regenerate the UI.
/*if (mask & LLInventoryObserver::REBUILD)
{
const std::set<LLUUID>& changed_items = gInventory.getChangedIDs();
std::set<LLUUID>::const_iterator id_it = changed_items.begin();
std::set<LLUUID>::const_iterator id_end = changed_items.end();
for (;id_it != id_end; ++id_it)
handled = true;
if (model_item && view_item)
{
// sync view with model
LLInventoryObject* model_item = model->getObject(*id_it);
LLFolderViewItem* view_item = mFolders->getItemByID(*id_it);
view_item->destroyView();
}
view_item = buildNewViews(item_id);
view_folder = dynamic_cast<LLFolderViewFolder *>(view_item);
}*/
if (model_item)
//////////////////////////////
// INTERNAL Operation
// This could be anything. For now, just refresh the item.
if (mask & LLInventoryObserver::INTERNAL)
{
if (view_item)
{
view_item->refresh();
}
}
//////////////////////////////
// SORT Operation
// Sort the folder.
/*if (mask & LLInventoryObserver::SORT)
{
if (view_folder)
{
view_folder->requestSort();
}
}*/
// We don't typically care which of these masks the item is actually flagged with, since the masks
// may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into
// Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks
// panel). What's relevant is that the item and UI are probably out of sync and thus need to be
// resynchronized.
if (mask & (LLInventoryObserver::STRUCTURE |
LLInventoryObserver::ADD |
LLInventoryObserver::REMOVE))
{
handled = true;
//////////////////////////////
// ADD Operation
// Item exists in memory but a UI element hasn't been created for it.
if (model_item && !view_item)
{
// Add the UI element for this item.
buildNewViews(item_id);
// Select any newly created object that has the auto rename at top of folder root set.
if(getRootFolder()->getRoot()->needsAutoRename())
{
if (!view_item)
{
// this object was just created, need to build a view for it
if ((mask & LLInventoryObserver::ADD) != LLInventoryObserver::ADD)
{
llwarns << *id_it << " is in model but not in view, but ADD flag not set" << llendl;
}
buildNewViews(*id_it);
// select any newly created object
// that has the auto rename at top of folder
// root set
if(mFolders->getRoot()->needsAutoRename())
{
setSelection(*id_it, FALSE);
}
}
else
{
// this object was probably moved, check its parent
if ((mask & LLInventoryObserver::STRUCTURE) != LLInventoryObserver::STRUCTURE)
{
llwarns << *id_it << " is in model and in view, but STRUCTURE flag not set" << llendl;
}
setSelection(item_id, FALSE);
}
}
LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID());
if (new_parent)
{
if (view_item->getParentFolder() != new_parent)
//////////////////////////////
// STRUCTURE Operation
// This item already exists in both memory and UI. It was probably reparented.
else if (model_item && view_item)
{
// Don't process the item if it is the root
if (view_item->getRoot() != view_item)
{
LLFolderViewFolder* new_parent = (LLFolderViewFolder*)getRootFolder()->getItemByID(model_item->getParentUUID());
// Item has been moved.
if (view_item->getParentFolder() != new_parent)
{
if (new_parent != NULL)
{
// Item is to be moved and we found its new parent in the panel's directory, so move the item's UI.
view_item->getParentFolder()->extractItem(view_item);
view_item->addToFolder(new_parent, mFolders);
view_item->addToFolder(new_parent, getRootFolder());
}
}
else
{
llwarns << model_item->getParentUUID() << ": parent folder gone !" << llendl;
// Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that
// doesn't include trash). Just remove the item's UI.
view_item->destroyView();
}
}
}
else
{
if (view_item)
{
if ((mask & LLInventoryObserver::REMOVE) != LLInventoryObserver::REMOVE)
{
llwarns << *id_it << " is not in model but in view, but REMOVE flag not set" << llendl;
}
// item in view but not model, need to delete view
view_item->destroyView();
}
else
{
llwarns << *id_it << ": Item does not exist in either view or model, but notification triggered" << llendl;
}
}
}
}
}
if (!handled)
{
// it's a small change that only requires a refresh.
// *TODO: figure out a more efficient way to do the refresh
// since it is expensive on large inventories
mFolders->refresh();
//////////////////////////////
// REMOVE Operation
// This item has been removed from memory, but its associated UI element still exists.
else if (!model_item && view_item)
{
// Remove the item's UI.
view_item->destroyView();
}
}
}
}

View File

@@ -1613,6 +1613,57 @@ bool goto_url_callback(const LLSD& notification, const LLSD& response)
}
static LLNotificationFunctorRegistration goto_url_callback_reg("GotoURL", goto_url_callback);
// Strip out "Resident" for display, but only if the message came from a user
// (rather than a script)
static std::string clean_name_from_im(const std::string& name, EInstantMessage type)
{
switch(type)
{
case IM_NOTHING_SPECIAL:
case IM_MESSAGEBOX:
case IM_GROUP_INVITATION:
case IM_INVENTORY_OFFERED:
case IM_INVENTORY_ACCEPTED:
case IM_INVENTORY_DECLINED:
case IM_GROUP_VOTE:
case IM_GROUP_MESSAGE_DEPRECATED:
//IM_TASK_INVENTORY_OFFERED
//IM_TASK_INVENTORY_ACCEPTED
//IM_TASK_INVENTORY_DECLINED
case IM_NEW_USER_DEFAULT:
case IM_SESSION_INVITE:
case IM_SESSION_P2P_INVITE:
case IM_SESSION_GROUP_START:
case IM_SESSION_CONFERENCE_START:
case IM_SESSION_SEND:
case IM_SESSION_LEAVE:
//IM_FROM_TASK
case IM_BUSY_AUTO_RESPONSE:
case IM_CONSOLE_AND_CHAT_HISTORY:
case IM_LURE_USER:
case IM_LURE_ACCEPTED:
case IM_LURE_DECLINED:
case IM_GODLIKE_LURE_USER:
case IM_YET_TO_BE_USED:
case IM_GROUP_ELECTION_DEPRECATED:
//IM_GOTO_URL
//IM_FROM_TASK_AS_ALERT
case IM_GROUP_NOTICE:
case IM_GROUP_NOTICE_INVENTORY_ACCEPTED:
case IM_GROUP_NOTICE_INVENTORY_DECLINED:
case IM_GROUP_INVITATION_ACCEPT:
case IM_GROUP_INVITATION_DECLINE:
case IM_GROUP_NOTICE_REQUESTED:
case IM_FRIENDSHIP_OFFERED:
case IM_FRIENDSHIP_ACCEPTED:
case IM_FRIENDSHIP_DECLINED_DEPRECATED:
//IM_TYPING_START
//IM_TYPING_STOP
return LLCacheName::cleanFullName(name);
default:
return name;
}
}
void process_improved_im(LLMessageSystem *msg, void **user_data)
{
@@ -1655,6 +1706,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
binary_bucket_size = msg->getSizeFast(_PREHASH_MessageBlock, _PREHASH_BinaryBucket);
EInstantMessage dialog = (EInstantMessage)d;
// make sure that we don't have an empty or all-whitespace name
LLStringUtil::trim(name);
if (name.empty())
{
name = LLTrans::getString("Unnamed");
}
// IDEVO convert new-style "Resident" names for display
name = clean_name_from_im(name, dialog);
// <edit>
llinfos << "RegionID: " << region_id.asString() << llendl;
// </edit>
@@ -2997,8 +3057,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
{
from_name = "(no name)";
}
chat.mFromName = from_name;
msg->getUUID("ChatData", "SourceID", from_id);
chat.mFromID = from_id;
@@ -3026,6 +3085,27 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
chat.mTime = LLFrameTimer::getElapsedSeconds();
// IDEVO Correct for new-style "Resident" names
if (chat.mSourceType == CHAT_SOURCE_AGENT)
{
// I don't know if it's OK to change this here, if
// anything downstream does lookups by name, for instance
LLAvatarName av_name;
if (LLAvatarNameCache::get(from_id, &av_name))
{
chat.mFromName = av_name.mDisplayName;
}
else
{
chat.mFromName = LLCacheName::cleanFullName(from_name);
}
}
else
{
chat.mFromName = from_name;
}
BOOL is_busy = gAgent.getBusy();
BOOL is_muted = FALSE;