summaryrefslogtreecommitdiff
path: root/indra/newview/llgroupiconctrl.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-01-04 15:31:19 -0800
committerTofu Linden <tofu.linden@lindenlab.com>2010-01-04 15:31:19 -0800
commitc9868071b113b251e03d95163118b696e28bbe98 (patch)
tree8428d2e97f7a61b1a10e7e10494199a39969369d /indra/newview/llgroupiconctrl.cpp
parente833e7ad442f5b59f95c6ccfcaaf1d103d247d69 (diff)
parente8659e0e13c65308ad2f036dc7e7ccff0e665976 (diff)
Merge from trunk. Conflicts manually resolved in:
U indra/llui/lluictrlfactory.cpp U indra/newview/llinventorybridge.cpp U indra/newview/llviewertexture.cpp U indra/newview/llviewertexture.h
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;
+}
+