PageRenderTime 323ms CodeModel.GetById 120ms app.highlight 8ms RepoModel.GetById 194ms app.codeStats 0ms

/indra/newview/llnameeditor.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 107 lines | 63 code | 18 blank | 26 comment | 6 complexity | 0b5efcada6e0433631f38065b817cfdf MD5 | raw file
  1/** 
  2 * @file llnameeditor.cpp
  3 * @brief Name Editor to refresh a name.
  4 *
  5 * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "llviewerprecompiledheaders.h"
 28 
 29#include "llnameeditor.h"
 30#include "llcachename.h"
 31
 32#include "llfontgl.h"
 33
 34#include "lluuid.h"
 35#include "llrect.h"
 36#include "llstring.h"
 37#include "llui.h"
 38
 39static LLDefaultChildRegistry::Register<LLNameEditor> r("name_editor");
 40
 41// statics
 42std::set<LLNameEditor*> LLNameEditor::sInstances;
 43
 44LLNameEditor::LLNameEditor(const LLNameEditor::Params& p)
 45:	LLLineEditor(p)
 46{
 47	LLNameEditor::sInstances.insert(this);
 48
 49	if(!p.name_id().isNull())
 50	{
 51		setNameID(p.name_id, p.is_group);
 52	}
 53}
 54
 55LLNameEditor::~LLNameEditor()
 56{
 57	LLNameEditor::sInstances.erase(this);
 58}
 59
 60void LLNameEditor::setNameID(const LLUUID& name_id, BOOL is_group)
 61{
 62	mNameID = name_id;
 63
 64	std::string name;
 65
 66	if (!is_group)
 67	{
 68		gCacheName->getFullName(name_id, name);
 69	}
 70	else
 71	{
 72		gCacheName->getGroupName(name_id, name);
 73	}
 74
 75	setText(name);
 76}
 77
 78void LLNameEditor::refresh(const LLUUID& id, const std::string& full_name, bool is_group)
 79{
 80	if (id == mNameID)
 81	{
 82		setText(full_name);
 83	}
 84}
 85
 86void LLNameEditor::refreshAll(const LLUUID& id, const std::string& full_name, bool is_group)
 87{
 88	std::set<LLNameEditor*>::iterator it;
 89	for (it = LLNameEditor::sInstances.begin();
 90		 it != LLNameEditor::sInstances.end();
 91		 ++it)
 92	{
 93		LLNameEditor* box = *it;
 94		box->refresh(id, full_name, is_group);
 95	}
 96}
 97
 98void LLNameEditor::setValue( const LLSD& value )
 99{
100	setNameID(value.asUUID(), FALSE);
101}
102
103LLSD LLNameEditor::getValue() const
104{
105	return LLSD(mNameID);
106}
107