llnamebox.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llnamebox.h"
00035 
00036 #include "llerror.h"
00037 #include "llfontgl.h"
00038 #include "llui.h"
00039 #include "llviewercontrol.h"
00040 #include "lluuid.h"
00041 
00042 #include "llcachename.h"
00043 #include "llagent.h"
00044 
00045 // statics
00046 std::set<LLNameBox*> LLNameBox::sInstances;
00047 
00048 
00049 LLNameBox::LLNameBox(const std::string& name, const LLRect& rect, const LLUUID& name_id, BOOL is_group, const LLFontGL* font, BOOL mouse_opaque)
00050 :       LLTextBox(name, rect, "(retrieving)", font, mouse_opaque),
00051         mNameID(name_id)
00052 {
00053         LLNameBox::sInstances.insert(this);
00054         if(!name_id.isNull())
00055         {
00056                 setNameID(name_id, is_group);
00057         }
00058         else
00059         {
00060                 setText(LLString::null);
00061         }
00062 }
00063 
00064 LLNameBox::~LLNameBox()
00065 {
00066         LLNameBox::sInstances.erase(this);
00067 }
00068 
00069 void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group)
00070 {
00071         mNameID = name_id;
00072 
00073         char first[DB_FIRST_NAME_BUF_SIZE];             /*Flawfinder: ignore*/
00074         char last[DB_LAST_NAME_BUF_SIZE];               /*Flawfinder: ignore*/
00075         char group_name[DB_GROUP_NAME_BUF_SIZE];                /*Flawfinder: ignore*/
00076         LLString name;
00077 
00078         if (!is_group)
00079         {
00080                 gCacheName->getName(name_id, first, last);
00081 
00082                 name.assign(first);
00083                 name.append(1, ' ');
00084                 name.append(last);
00085         }
00086         else
00087         {
00088                 gCacheName->getGroupName(name_id, group_name);
00089 
00090                 name.assign(group_name);
00091         }
00092 
00093         setText(name);
00094 }
00095 
00096 void LLNameBox::refresh(const LLUUID& id, const char* firstname,
00097                                                    const char* lastname, BOOL is_group)
00098 {
00099         if (id == mNameID)
00100         {
00101                 LLString name;
00102 
00103                 name.assign(firstname);
00104                 if (!is_group)
00105                 {
00106                         name.append(1, ' ');
00107                         name.append(lastname);
00108                 }
00109 
00110                 setText(name);
00111         }
00112 }
00113 
00114 void LLNameBox::refreshAll(const LLUUID& id, const char* firstname,
00115                                                    const char* lastname, BOOL is_group)
00116 {
00117         std::set<LLNameBox*>::iterator it;
00118         for (it = LLNameBox::sInstances.begin();
00119                  it != LLNameBox::sInstances.end();
00120                  ++it)
00121         {
00122                 LLNameBox* box = *it;
00123                 box->refresh(id, firstname, lastname, is_group);
00124         }
00125 }

Generated on Thu Jul 1 06:08:54 2010 for Second Life Viewer by  doxygen 1.4.7