summaryrefslogtreecommitdiff
path: root/indra/newview/llgroupiconctrl.cpp
diff options
context:
space:
mode:
authorLeyla Farazha <leyla@lindenlab.com>2010-01-04 15:04:38 -0800
committerLeyla Farazha <leyla@lindenlab.com>2010-01-04 15:04:38 -0800
commit53abe3c7802b8c8579ce868b4ecb05d9ebdd20ef (patch)
tree4a2c9b325f6ceb75403db9d29e1efa583de434e3 /indra/newview/llgroupiconctrl.cpp
parent34328eed67a10ccca73ec78cd70488ac35f2ee91 (diff)
parent1355d16d2f24f9d623df70059b1f0001cf673209 (diff)
Merge
Diffstat (limited to 'indra/newview/llgroupiconctrl.cpp')
-rw-r--r--indra/newview/llgroupiconctrl.cpp145
1 files changed, 145 insertions, 0 deletions
diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp
new file mode 100644
index 0000000000..0b03d49cbc
--- /dev/null
+++ b/indra/newview/llgroupiconctrl.cpp
@@ -0,0 +1,145 @@
+/**
+ * @file llgroupiconctrl.cpp
+ * @brief LLGroupIconCtrl class implementation
+ *
+ * $LicenseInfo:firstyear=2009&license=viewergpl$
+ *
+ * Copyright (c) 2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llgroupiconctrl.h"
+
+#include "llagent.h"
+/*
+#include "llavatarconstants.h"
+#include "llcallingcard.h" // for LLAvatarTracker
+#include "llavataractions.h"
+#include "llmenugl.h"
+#include "lluictrlfactory.h"
+
+#include "llcachename.h"
+#include "llagentdata.h"
+#include "llimfloater.h"
+*/
+
+static LLDefaultChildRegistry::Register<LLGroupIconCtrl> g_i("group_icon");
+
+LLGroupIconCtrl::Params::Params()
+: group_id("group_id")
+, draw_tooltip("draw_tooltip", true)
+, default_icon_name("default_icon_name")
+{
+}
+
+
+LLGroupIconCtrl::LLGroupIconCtrl(const LLGroupIconCtrl::Params& p)
+: LLIconCtrl(p)
+, mGroupId(LLUUID::null)
+, mDrawTooltip(p.draw_tooltip)
+, mDefaultIconName(p.default_icon_name)
+{
+ mPriority = LLViewerFetchedTexture::BOOST_ICON;
+
+ if (p.group_id.isProvided())
+ {
+ LLSD value(p.group_id);
+ setValue(value);
+ }
+ else
+ {
+ LLIconCtrl::setValue(mDefaultIconName);
+ }
+}
+
+LLGroupIconCtrl::~LLGroupIconCtrl()
+{
+ LLGroupMgr::getInstance()->removeObserver(this);
+}
+
+void LLGroupIconCtrl::setValue(const LLSD& value)
+{
+ if (value.isUUID())
+ {
+ LLGroupMgr* gm = LLGroupMgr::getInstance();
+ if (mGroupId.notNull())
+ {
+ gm->removeObserver(this);
+ }
+
+ if (mGroupId != value.asUUID())
+ {
+ mGroupId = value.asUUID();
+
+ // Check if cache already contains image_id for that group
+ if (!updateFromCache())
+ {
+ LLIconCtrl::setValue(mDefaultIconName);
+ gm->addObserver(this);
+ gm->sendGroupPropertiesRequest(mGroupId);
+ }
+ }
+ }
+ else
+ {
+ LLIconCtrl::setValue(value);
+ }
+}
+
+void LLGroupIconCtrl::changed(LLGroupChange gc)
+{
+ if (GC_PROPERTIES == gc)
+ {
+ updateFromCache();
+ }
+}
+
+bool LLGroupIconCtrl::updateFromCache()
+{
+ LLGroupMgrGroupData* group_data = LLGroupMgr::getInstance()->getGroupData(mGroupId);
+ if (!group_data) return false;
+
+ if (group_data->mInsigniaID.notNull())
+ {
+ LLIconCtrl::setValue(group_data->mInsigniaID);
+ }
+ else
+ {
+ LLIconCtrl::setValue(mDefaultIconName);
+ }
+
+ if (mDrawTooltip && !group_data->mName.empty())
+ {
+ setToolTip(group_data->mName);
+ }
+ else
+ {
+ setToolTip(LLStringUtil::null);
+ }
+ return true;
+}
+