summaryrefslogtreecommitdiff
path: root/indra/newview/llfloateropenobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloateropenobject.cpp')
-rw-r--r--indra/newview/llfloateropenobject.cpp163
1 files changed, 74 insertions, 89 deletions
diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp
index 4d782a1814..d6f6ba9e5b 100644
--- a/indra/newview/llfloateropenobject.cpp
+++ b/indra/newview/llfloateropenobject.cpp
@@ -2,37 +2,31 @@
* @file llfloateropenobject.cpp
* @brief LLFloaterOpenObject class implementation
*
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- *
- * Copyright (c) 2004-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2004&license=viewerlgpl$
* 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
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * 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
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * 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.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
/*
* Shows the contents of an object.
- * A floater wrapper for llpanelinventory
+ * A floater wrapper for LLPanelObjectInventory
*/
#include "llviewerprecompiledheaders.h"
@@ -41,14 +35,15 @@
#include "llcachename.h"
#include "llbutton.h"
+#include "llnotificationsutil.h"
#include "lltextbox.h"
-#include "llagent.h" // for agent id
-#include "llalertdialog.h"
#include "llinventorybridge.h"
-#include "llinventoryview.h"
+#include "llfloaterinventory.h"
#include "llinventorymodel.h"
-#include "llpanelinventory.h"
+#include "llinventorypanel.h"
+#include "llpanelobjectinventory.h"
+#include "llfloaterreg.h"
#include "llselectmgr.h"
#include "lluiconstants.h"
#include "llviewerobject.h"
@@ -56,38 +51,58 @@
#include "llviewerwindow.h"
-LLFloaterOpenObject* LLFloaterOpenObject::sInstance = NULL;
-
-LLFloaterOpenObject::LLFloaterOpenObject()
-: LLFloater(),
- mPanelInventory(NULL),
+LLFloaterOpenObject::LLFloaterOpenObject(const LLSD& key)
+: LLFloater(key),
+ mPanelInventoryObject(NULL),
mDirty(TRUE)
{
- LLUICtrlFactory::getInstance()->buildFloater(this,"floater_openobject.xml");
+// LLUICtrlFactory::getInstance()->buildFloater(this,"floater_openobject.xml");
+ mCommitCallbackRegistrar.add("OpenObject.MoveToInventory", boost::bind(&LLFloaterOpenObject::onClickMoveToInventory, this));
+ mCommitCallbackRegistrar.add("OpenObject.MoveAndWear", boost::bind(&LLFloaterOpenObject::onClickMoveAndWear, this));
}
LLFloaterOpenObject::~LLFloaterOpenObject()
{
- sInstance = NULL;
+// sInstance = NULL;
}
+
// virtual
BOOL LLFloaterOpenObject::postBuild()
{
- childSetAction("copy_to_inventory_button", onClickMoveToInventory, this);
- childSetAction("copy_and_wear_button", onClickMoveAndWear, this);
- childSetTextArg("object_name", "[DESC]", std::string("Object") ); // *Note: probably do not want to translate this
- mPanelInventory = getChild<LLPanelInventory>("object_contents");
+ getChild<LLUICtrl>("object_name")->setTextArg("[DESC]", std::string("Object") ); // *Note: probably do not want to translate this
+ mPanelInventoryObject = getChild<LLPanelObjectInventory>("object_contents");
+
+ refresh();
return TRUE;
}
+
+void LLFloaterOpenObject::onOpen(const LLSD& key)
+{
+ LLObjectSelectionHandle object_selection = LLSelectMgr::getInstance()->getSelection();
+ if (object_selection->getRootObjectCount() != 1)
+ {
+ LLNotificationsUtil::add("UnableToViewContentsMoreThanOne");
+ closeFloater();
+ return;
+ }
+ if(!(object_selection->getPrimaryObject()))
+ {
+ closeFloater();
+ return;
+ }
+ mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
+ refresh();
+}
+
void LLFloaterOpenObject::refresh()
{
- mPanelInventory->refresh();
+ mPanelInventoryObject->refresh();
- std::string name;
- BOOL enabled;
+ std::string name = "";
+ BOOL enabled = FALSE;
LLSelectNode* node = mObjectSelection->getFirstRootNode();
- if (node)
+ if (node)
{
name = node->mName;
enabled = TRUE;
@@ -97,11 +112,10 @@ void LLFloaterOpenObject::refresh()
name = "";
enabled = FALSE;
}
-
- childSetTextArg("object_name", "[DESC]", name);
- childSetEnabled("copy_to_inventory_button", enabled);
- childSetEnabled("copy_and_wear_button", enabled);
+ getChild<LLUICtrl>("object_name")->setTextArg("[DESC]", name);
+ getChildView("copy_to_inventory_button")->setEnabled(enabled);
+ getChildView("copy_and_wear_button")->setEnabled(enabled);
}
@@ -115,41 +129,18 @@ void LLFloaterOpenObject::draw()
LLFloater::draw();
}
-// static
void LLFloaterOpenObject::dirty()
{
- if (sInstance) sInstance->mDirty = TRUE;
+ mDirty = TRUE;
}
-// static
-void LLFloaterOpenObject::show()
-{
- LLObjectSelectionHandle object_selection = LLSelectMgr::getInstance()->getSelection();
- if (object_selection->getRootObjectCount() != 1)
- {
- LLNotifications::instance().add("UnableToViewContentsMoreThanOne");
- return;
- }
-
- // Create a new instance only if needed
- if (!sInstance)
- {
- sInstance = new LLFloaterOpenObject();
- sInstance->center();
- }
-
- sInstance->openFloater();
- sInstance->setFocus(TRUE);
-
- sInstance->mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
-}
void LLFloaterOpenObject::moveToInventory(bool wear)
{
if (mObjectSelection->getRootObjectCount() != 1)
{
- LLNotifications::instance().add("OnlyCopyContentsOfSingleItem");
+ LLNotificationsUtil::add("OnlyCopyContentsOfSingleItem");
return;
}
@@ -166,14 +157,14 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
if (wear)
{
parent_category_id = gInventory.findCategoryUUIDForType(
- LLAssetType::AT_CLOTHING);
+ LLFolderType::FT_CLOTHING);
}
else
{
- parent_category_id = gAgent.getInventoryRootID();
+ parent_category_id = gInventory.getRootFolderID();
}
LLUUID category_id = gInventory.createNewCategory(parent_category_id,
- LLAssetType::AT_NONE,
+ LLFolderType::FT_NONE,
name);
LLCatAndWear* data = new LLCatAndWear;
@@ -190,7 +181,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
delete data;
data = NULL;
- LLNotifications::instance().add("OpenObjectCannotCopy");
+ LLNotificationsUtil::add("OpenObjectCannotCopy");
}
}
@@ -201,31 +192,25 @@ void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data)
if (result == 0)
{
- LLInventoryView::showAgentInventory();
- LLInventoryView* view = LLInventoryView::getActiveInventory();
- if (view)
+ LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel();
+ if (active_panel)
{
- view->getPanel()->setSelection(cat->mCatID, TAKE_FOCUS_NO);
+ active_panel->setSelection(cat->mCatID, TAKE_FOCUS_NO);
}
}
delete cat;
}
-
-// static
-void LLFloaterOpenObject::onClickMoveToInventory(void* data)
+void LLFloaterOpenObject::onClickMoveToInventory()
{
- LLFloaterOpenObject* self = (LLFloaterOpenObject*)data;
- self->moveToInventory(false);
- self->closeFloater();
+ moveToInventory(false);
+ closeFloater();
}
-// static
-void LLFloaterOpenObject::onClickMoveAndWear(void* data)
+void LLFloaterOpenObject::onClickMoveAndWear()
{
- LLFloaterOpenObject* self = (LLFloaterOpenObject*)data;
- self->moveToInventory(true);
- self->closeFloater();
+ moveToInventory(true);
+ closeFloater();
}