summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterproperties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterproperties.cpp')
-rw-r--r--indra/newview/llfloaterproperties.cpp243
1 files changed, 81 insertions, 162 deletions
diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp
index dc72b66949..7312808bd6 100644
--- a/indra/newview/llfloaterproperties.cpp
+++ b/indra/newview/llfloaterproperties.cpp
@@ -44,7 +44,7 @@
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llfloatergroupinfo.h"
-#include "llfriendactions.h"
+#include "llavataractions.h"
#include "llinventorymodel.h"
#include "lllineeditor.h"
#include "llradiogroup.h"
@@ -76,7 +76,8 @@
class LLPropertiesObserver : public LLInventoryObserver
{
public:
- LLPropertiesObserver()
+ LLPropertiesObserver(LLFloaterProperties* floater)
+ : mFloater(floater)
{
gInventory.addObserver(this);
}
@@ -85,6 +86,8 @@ public:
gInventory.removeObserver(this);
}
virtual void changed(U32 mask);
+private:
+ LLFloaterProperties* mFloater;
};
void LLPropertiesObserver::changed(U32 mask)
@@ -92,7 +95,7 @@ void LLPropertiesObserver::changed(U32 mask)
// if there's a change we're interested in.
if((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0)
{
- LLFloaterProperties::dirtyAll();
+ mFloater->dirty();
}
}
@@ -102,135 +105,65 @@ void LLPropertiesObserver::changed(U32 mask)
/// Class LLFloaterProperties
///----------------------------------------------------------------------------
-// static
-LLFloaterProperties::instance_map LLFloaterProperties::sInstances;
-LLPropertiesObserver* LLFloaterProperties::sPropertiesObserver = NULL;
-S32 LLFloaterProperties::sPropertiesObserverCount = 0;
-
-// static
-LLFloaterProperties* LLFloaterProperties::find(const LLUUID& item_id,
- const LLUUID& object_id)
-{
- // for simplicity's sake, we key the properties window with a
- // single uuid. However, the items are keyed by item and object
- // (obj == null -> agent inventory). So, we xor the two ids, and
- // use that as a lookup key
- instance_map::iterator it = sInstances.find(item_id ^ object_id);
- if(it != sInstances.end())
- {
- return (*it).second;
- }
- return NULL;
-}
-
-// static
-LLFloaterProperties* LLFloaterProperties::show(const LLUUID& item_id,
- const LLUUID& object_id)
-{
- LLFloaterProperties* instance = find(item_id, object_id);
- if(instance)
- {
- if (LLFloater::getFloaterHost() && LLFloater::getFloaterHost() != instance->getHost())
- {
- // this properties window is being opened in a new context
- // needs to be rehosted
- LLFloater::getFloaterHost()->addFloater(instance, TRUE);
- }
-
- instance->refresh();
- instance->openFloater();
- }
- else
- {
- LLFloaterProperties* floater = new LLFloaterProperties(item_id, object_id);
- // keep onscreen
- gFloaterView->adjustToFitScreen(floater, FALSE);
- }
- return instance;
-}
-
-void LLFloaterProperties::dirtyAll()
-{
- // ...this is more clear. Possibly more correct, because the
- // refresh method may delete the object.
- for(instance_map::iterator it = sInstances.begin(); it!=sInstances.end(); )
- {
- (*it++).second->dirty();
- }
-}
-
// Default constructor
-LLFloaterProperties::LLFloaterProperties(const LLUUID& item_id, const LLUUID& object_id)
- : LLFloater(),
+LLFloaterProperties::LLFloaterProperties(const LLUUID& item_id)
+ : LLFloater(mItemID),
mItemID(item_id),
- mObjectID(object_id),
mDirty(TRUE)
{
- LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml");
+ mPropertiesObserver = new LLPropertiesObserver(this);
- if (!sPropertiesObserver)
- {
- sPropertiesObserver = new LLPropertiesObserver;
- }
- sPropertiesObserverCount++;
-
- // add the object to the static structure
- LLUUID key = mItemID ^ mObjectID;
- sInstances.insert(instance_map::value_type(key, this));
-
+ //LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml");
}
// Destroys the object
LLFloaterProperties::~LLFloaterProperties()
{
- // clean up the static data.
- instance_map::iterator it = sInstances.find(mItemID ^ mObjectID);
- if(it != sInstances.end())
- {
- sInstances.erase(it);
- }
- sPropertiesObserverCount--;
- if (!sPropertiesObserverCount)
- {
- delete sPropertiesObserver;
- sPropertiesObserver = NULL;
- }
+ delete mPropertiesObserver;
+ mPropertiesObserver = NULL;
}
+
// virtual
BOOL LLFloaterProperties::postBuild()
{
// build the UI
// item name & description
childSetPrevalidate("LabelItemName",&LLLineEditor::prevalidatePrintableNotPipe);
- childSetCommitCallback("LabelItemName",onCommitName,this);
+ getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitName,this));
childSetPrevalidate("LabelItemDesc",&LLLineEditor::prevalidatePrintableNotPipe);
- childSetCommitCallback("LabelItemDesc", onCommitDescription, this);
+ getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLFloaterProperties:: onCommitDescription, this));
// Creator information
- childSetAction("BtnCreator",onClickCreator,this);
+ getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickCreator,this));
// owner information
- childSetAction("BtnOwner",onClickOwner,this);
+ getChild<LLUICtrl>("BtnOwner")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickOwner,this));
// acquired date
// owner permissions
// Permissions debug text
// group permissions
- childSetCommitCallback("CheckShareWithGroup",&onCommitPermissions, this);
+ getChild<LLUICtrl>("CheckShareWithGroup")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
// everyone permissions
- childSetCommitCallback("CheckEveryoneCopy",&onCommitPermissions, this);
+ getChild<LLUICtrl>("CheckEveryoneCopy")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
// next owner permissions
- childSetCommitCallback("CheckNextOwnerModify",&onCommitPermissions, this);
- childSetCommitCallback("CheckNextOwnerCopy",&onCommitPermissions, this);
- childSetCommitCallback("CheckNextOwnerTransfer",&onCommitPermissions, this);
+ getChild<LLUICtrl>("CheckNextOwnerModify")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
+ getChild<LLUICtrl>("CheckNextOwnerCopy")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
+ getChild<LLUICtrl>("CheckNextOwnerTransfer")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
// Mark for sale or not, and sale info
- childSetCommitCallback("CheckPurchase",&onCommitSaleInfo, this);
- childSetCommitCallback("RadioSaleType",&onCommitSaleType, this);
+ getChild<LLUICtrl>("CheckPurchase")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleInfo, this));
+ getChild<LLUICtrl>("RadioSaleType")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleType, this));
// "Price" label for edit
- childSetCommitCallback("EditPrice",&onCommitSaleInfo, this);
+ getChild<LLUICtrl>("EditPrice")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleInfo, this));
// The UI has been built, now fill in all the values
refresh();
return TRUE;
}
+// virtual
+void LLFloaterProperties::onOpen(const LLSD& key)
+{
+ refresh();
+}
+
void LLFloaterProperties::refresh()
{
LLInventoryItem* item = findItem();
@@ -303,12 +236,14 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
// do not enable the UI for incomplete items.
LLViewerInventoryItem* i = (LLViewerInventoryItem*)item;
BOOL is_complete = i->isComplete();
-
+ const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(i->getInventoryType());
+ const BOOL is_calling_card = (i->getInventoryType() == LLInventoryType::IT_CALLINGCARD);
const LLPermissions& perm = item->getPermissions();
const BOOL can_agent_manipulate = gAgent.allowOperation(PERM_OWNER, perm,
GP_OBJECT_MANIPULATE);
const BOOL can_agent_sell = gAgent.allowOperation(PERM_OWNER, perm,
- GP_OBJECT_SET_SALE);
+ GP_OBJECT_SET_SALE) &&
+ !cannot_restrict_permissions;
const BOOL is_link = LLAssetType::lookupIsLinkType(i->getActualType());
// You need permission to modify the object to modify an inventory
@@ -325,11 +260,11 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
// ITEM NAME & DESC //
//////////////////////
BOOL is_modifiable = gAgent.allowOperation(PERM_MODIFY, perm,
- GP_OBJECT_MANIPULATE)
- && is_obj_modify && is_complete;
+ GP_OBJECT_MANIPULATE)
+ && is_obj_modify && is_complete;
childSetEnabled("LabelItemNameTitle",TRUE);
- childSetEnabled("LabelItemName",is_modifiable);
+ childSetEnabled("LabelItemName",is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
childSetText("LabelItemName",item->getName());
childSetEnabled("LabelItemDescTitle",TRUE);
childSetEnabled("LabelItemDesc",is_modifiable);
@@ -492,7 +427,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
/////////////
// Check for ability to change values.
- if (is_link)
+ if (is_link || cannot_restrict_permissions)
{
childSetEnabled("CheckShareWithGroup",FALSE);
childSetEnabled("CheckEveryoneCopy",FALSE);
@@ -558,9 +493,9 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
childSetEnabled("CheckPurchase",is_complete);
childSetEnabled("NextOwnerLabel",TRUE);
- childSetEnabled("CheckNextOwnerModify",base_mask & PERM_MODIFY);
- childSetEnabled("CheckNextOwnerCopy",base_mask & PERM_COPY);
- childSetEnabled("CheckNextOwnerTransfer",next_owner_mask & PERM_COPY);
+ childSetEnabled("CheckNextOwnerModify",(base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
+ childSetEnabled("CheckNextOwnerCopy",(base_mask & PERM_COPY) && !cannot_restrict_permissions);
+ childSetEnabled("CheckNextOwnerTransfer",(next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
childSetEnabled("RadioSaleType",is_complete && is_for_sale);
childSetEnabled("TextPrice",is_complete && is_for_sale);
@@ -602,25 +537,20 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
}
}
-// static
-void LLFloaterProperties::onClickCreator(void* data)
+void LLFloaterProperties::onClickCreator()
{
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- LLInventoryItem* item = self->findItem();
+ LLInventoryItem* item = findItem();
if(!item) return;
if(!item->getCreatorUUID().isNull())
{
- LLFriendActions::showProfile(item->getCreatorUUID());
+ LLAvatarActions::showProfile(item->getCreatorUUID());
}
}
// static
-void LLFloaterProperties::onClickOwner(void* data)
+void LLFloaterProperties::onClickOwner()
{
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- LLInventoryItem* item = self->findItem();
+ LLInventoryItem* item = findItem();
if(!item) return;
if(item->getPermissions().isGroupOwned())
{
@@ -628,25 +558,20 @@ void LLFloaterProperties::onClickOwner(void* data)
}
else
{
- LLFriendActions::showProfile(item->getPermissions().getOwner());
+ LLAvatarActions::showProfile(item->getPermissions().getOwner());
}
}
// static
-void LLFloaterProperties::onCommitName(LLUICtrl* ctrl, void* data)
+void LLFloaterProperties::onCommitName()
{
//llinfos << "LLFloaterProperties::onCommitName()" << llendl;
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self)
- {
- return;
- }
- LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->findItem();
+ LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
if(!item)
{
return;
}
- LLLineEditor* labelItemName = self->getChild<LLLineEditor>("LabelItemName");
+ LLLineEditor* labelItemName = getChild<LLLineEditor>("LabelItemName");
if(labelItemName&&
(item->getName() != labelItemName->getText()) &&
@@ -654,15 +579,16 @@ void LLFloaterProperties::onCommitName(LLUICtrl* ctrl, void* data)
{
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->rename(labelItemName->getText());
- if(self->mObjectID.isNull())
+ if(mObjectID.isNull())
{
new_item->updateServer(FALSE);
gInventory.updateItem(new_item);
+ gInventory.updateLinkedObjects(new_item->getUUID());
gInventory.notifyObservers();
}
else
{
- LLViewerObject* object = gObjectList.findObject(self->mObjectID);
+ LLViewerObject* object = gObjectList.findObject(mObjectID);
if(object)
{
object->updateInventory(
@@ -674,16 +600,13 @@ void LLFloaterProperties::onCommitName(LLUICtrl* ctrl, void* data)
}
}
-// static
-void LLFloaterProperties::onCommitDescription(LLUICtrl* ctrl, void* data)
+void LLFloaterProperties::onCommitDescription()
{
//llinfos << "LLFloaterProperties::onCommitDescription()" << llendl;
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->findItem();
+ LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
if(!item) return;
- LLLineEditor* labelItemDesc = self->getChild<LLLineEditor>("LabelItemDesc");
+ LLLineEditor* labelItemDesc = getChild<LLLineEditor>("LabelItemDesc");
if(!labelItemDesc)
{
return;
@@ -694,7 +617,7 @@ void LLFloaterProperties::onCommitDescription(LLUICtrl* ctrl, void* data)
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->setDescription(labelItemDesc->getText());
- if(self->mObjectID.isNull())
+ if(mObjectID.isNull())
{
new_item->updateServer(FALSE);
gInventory.updateItem(new_item);
@@ -702,7 +625,7 @@ void LLFloaterProperties::onCommitDescription(LLUICtrl* ctrl, void* data)
}
else
{
- LLViewerObject* object = gObjectList.findObject(self->mObjectID);
+ LLViewerObject* object = gObjectList.findObject(mObjectID);
if(object)
{
object->updateInventory(
@@ -715,17 +638,15 @@ void LLFloaterProperties::onCommitDescription(LLUICtrl* ctrl, void* data)
}
// static
-void LLFloaterProperties::onCommitPermissions(LLUICtrl* ctrl, void* data)
+void LLFloaterProperties::onCommitPermissions()
{
//llinfos << "LLFloaterProperties::onCommitPermissions()" << llendl;
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->findItem();
+ LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
if(!item) return;
LLPermissions perm(item->getPermissions());
- LLCheckBoxCtrl* CheckShareWithGroup = self->getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
+ LLCheckBoxCtrl* CheckShareWithGroup = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
if(CheckShareWithGroup)
{
@@ -733,26 +654,26 @@ void LLFloaterProperties::onCommitPermissions(LLUICtrl* ctrl, void* data)
CheckShareWithGroup->get(),
PERM_MODIFY | PERM_MOVE | PERM_COPY);
}
- LLCheckBoxCtrl* CheckEveryoneCopy = self->getChild<LLCheckBoxCtrl>("CheckEveryoneCopy");
+ LLCheckBoxCtrl* CheckEveryoneCopy = getChild<LLCheckBoxCtrl>("CheckEveryoneCopy");
if(CheckEveryoneCopy)
{
perm.setEveryoneBits(gAgent.getID(), gAgent.getGroupID(),
CheckEveryoneCopy->get(), PERM_COPY);
}
- LLCheckBoxCtrl* CheckNextOwnerModify = self->getChild<LLCheckBoxCtrl>("CheckNextOwnerModify");
+ LLCheckBoxCtrl* CheckNextOwnerModify = getChild<LLCheckBoxCtrl>("CheckNextOwnerModify");
if(CheckNextOwnerModify)
{
perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
CheckNextOwnerModify->get(), PERM_MODIFY);
}
- LLCheckBoxCtrl* CheckNextOwnerCopy = self->getChild<LLCheckBoxCtrl>("CheckNextOwnerCopy");
+ LLCheckBoxCtrl* CheckNextOwnerCopy = getChild<LLCheckBoxCtrl>("CheckNextOwnerCopy");
if(CheckNextOwnerCopy)
{
perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
CheckNextOwnerCopy->get(), PERM_COPY);
}
- LLCheckBoxCtrl* CheckNextOwnerTransfer = self->getChild<LLCheckBoxCtrl>("CheckNextOwnerTransfer");
+ LLCheckBoxCtrl* CheckNextOwnerTransfer = getChild<LLCheckBoxCtrl>("CheckNextOwnerTransfer");
if(CheckNextOwnerTransfer)
{
perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
@@ -788,7 +709,7 @@ void LLFloaterProperties::onCommitPermissions(LLUICtrl* ctrl, void* data)
flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
}
new_item->setFlags(flags);
- if(self->mObjectID.isNull())
+ if(mObjectID.isNull())
{
new_item->updateServer(FALSE);
gInventory.updateItem(new_item);
@@ -796,7 +717,7 @@ void LLFloaterProperties::onCommitPermissions(LLUICtrl* ctrl, void* data)
}
else
{
- LLViewerObject* object = gObjectList.findObject(self->mObjectID);
+ LLViewerObject* object = gObjectList.findObject(mObjectID);
if(object)
{
object->updateInventory(
@@ -809,26 +730,22 @@ void LLFloaterProperties::onCommitPermissions(LLUICtrl* ctrl, void* data)
else
{
// need to make sure we don't just follow the click
- self->refresh();
+ refresh();
}
}
// static
-void LLFloaterProperties::onCommitSaleInfo(LLUICtrl* ctrl, void* data)
+void LLFloaterProperties::onCommitSaleInfo()
{
//llinfos << "LLFloaterProperties::onCommitSaleInfo()" << llendl;
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- self->updateSaleInfo();
+ updateSaleInfo();
}
// static
-void LLFloaterProperties::onCommitSaleType(LLUICtrl* ctrl, void* data)
+void LLFloaterProperties::onCommitSaleType()
{
//llinfos << "LLFloaterProperties::onCommitSaleType()" << llendl;
- LLFloaterProperties* self = (LLFloaterProperties*)data;
- if(!self) return;
- self->updateSaleInfo();
+ updateSaleInfo();
}
void LLFloaterProperties::updateSaleInfo()
@@ -954,13 +871,15 @@ LLInventoryItem* LLFloaterProperties::findItem() const
return item;
}
-void LLFloaterProperties::closeByID(const LLUUID& item_id, const LLUUID &object_id)
+//static
+void LLFloaterProperties::dirtyAll()
{
- LLFloaterProperties* floaterp = find(item_id, object_id);
-
- if (floaterp)
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("properties");
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
+ iter != inst_list.end(); ++iter)
{
- floaterp->closeFloater();
+ LLFloaterProperties* floater = dynamic_cast<LLFloaterProperties*>(*iter);
+ floater->dirty();
}
}
@@ -969,7 +888,7 @@ void LLFloaterProperties::closeByID(const LLUUID& item_id, const LLUUID &object_
///----------------------------------------------------------------------------
LLMultiProperties::LLMultiProperties()
- : LLMultiFloater()
+ : LLMultiFloater(LLSD())
{
// *TODO: There should be a .xml file for this
const LLRect& nextrect = LLFloaterReg::getFloaterRect("properties"); // place where the next properties should show up