llfloaterproperties.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:26k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llfloaterproperties.cpp
  3.  * @brief A floater which shows an inventory item's properties.
  4.  *
  5.  * $LicenseInfo:firstyear=2002&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2002-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llfloaterproperties.h"
  34. #include <algorithm>
  35. #include <functional>
  36. #include "llcachename.h"
  37. #include "lldbstrings.h"
  38. #include "llfloaterreg.h"
  39. #include "llinventory.h"
  40. #include "llagent.h"
  41. #include "llbutton.h"
  42. #include "llcheckboxctrl.h"
  43. #include "llavataractions.h"
  44. #include "llinventoryobserver.h"
  45. #include "llinventorymodel.h"
  46. #include "lllineeditor.h"
  47. //#include "llspinctrl.h"
  48. #include "llradiogroup.h"
  49. #include "llresmgr.h"
  50. #include "roles_constants.h"
  51. #include "llselectmgr.h"
  52. #include "lltextbox.h"
  53. #include "lltrans.h"
  54. #include "lluiconstants.h"
  55. #include "llviewerinventory.h"
  56. #include "llviewerobjectlist.h"
  57. #include "llviewerregion.h"
  58. #include "llviewercontrol.h"
  59. #include "llviewerwindow.h"
  60. #include "llgroupactions.h"
  61. #include "lluictrlfactory.h"
  62. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. // Class LLPropertiesObserver
  64. //
  65. // helper class to watch the inventory. 
  66. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. // Ugh. This can't be a singleton because it needs to remove itself
  68. //  from the inventory observer list when destroyed, which could
  69. //  happen after gInventory has already been destroyed if a singleton.
  70. // Instead, do our own ref counting and create / destroy it as needed
  71. class LLPropertiesObserver : public LLInventoryObserver
  72. {
  73. public:
  74. LLPropertiesObserver(LLFloaterProperties* floater)
  75. : mFloater(floater)
  76. {
  77. gInventory.addObserver(this);
  78. }
  79. virtual ~LLPropertiesObserver()
  80. {
  81. gInventory.removeObserver(this);
  82. }
  83. virtual void changed(U32 mask);
  84. private:
  85. LLFloaterProperties* mFloater;
  86. };
  87. void LLPropertiesObserver::changed(U32 mask)
  88. {
  89. // if there's a change we're interested in.
  90. if((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0)
  91. {
  92. mFloater->dirty();
  93. }
  94. }
  95. ///----------------------------------------------------------------------------
  96. /// Class LLFloaterProperties
  97. ///----------------------------------------------------------------------------
  98. // Default constructor
  99. LLFloaterProperties::LLFloaterProperties(const LLUUID& item_id)
  100.   : LLFloater(mItemID),
  101. mItemID(item_id),
  102. mDirty(TRUE)
  103. {
  104. mPropertiesObserver = new LLPropertiesObserver(this);
  105. //LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml");
  106. }
  107. // Destroys the object
  108. LLFloaterProperties::~LLFloaterProperties()
  109. {
  110. delete mPropertiesObserver;
  111. mPropertiesObserver = NULL;
  112. }
  113. // virtual
  114. BOOL LLFloaterProperties::postBuild()
  115. {
  116. // build the UI
  117. // item name & description
  118. childSetPrevalidate("LabelItemName",&LLTextValidate::validateASCIIPrintableNoPipe);
  119. getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitName,this));
  120. childSetPrevalidate("LabelItemDesc",&LLTextValidate::validateASCIIPrintableNoPipe);
  121. getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLFloaterProperties:: onCommitDescription, this));
  122. // Creator information
  123. getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickCreator,this));
  124. // owner information
  125. getChild<LLUICtrl>("BtnOwner")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickOwner,this));
  126. // acquired date
  127. // owner permissions
  128. // Permissions debug text
  129. // group permissions
  130. getChild<LLUICtrl>("CheckShareWithGroup")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
  131. // everyone permissions
  132. getChild<LLUICtrl>("CheckEveryoneCopy")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
  133. // next owner permissions
  134. getChild<LLUICtrl>("CheckNextOwnerModify")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
  135. getChild<LLUICtrl>("CheckNextOwnerCopy")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
  136. getChild<LLUICtrl>("CheckNextOwnerTransfer")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitPermissions, this));
  137. // Mark for sale or not, and sale info
  138. getChild<LLUICtrl>("CheckPurchase")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleInfo, this));
  139. getChild<LLUICtrl>("RadioSaleType")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleType, this));
  140. // "Price" label for edit
  141. getChild<LLUICtrl>("Edit Cost")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitSaleInfo, this));
  142. // The UI has been built, now fill in all the values
  143. refresh();
  144. return TRUE;
  145. }
  146. // virtual
  147. void LLFloaterProperties::onOpen(const LLSD& key)
  148. {
  149. refresh();
  150. }
  151. void LLFloaterProperties::refresh()
  152. {
  153. LLInventoryItem* item = findItem();
  154. if(item)
  155. {
  156. refreshFromItem(item);
  157. }
  158. else
  159. {
  160. //RN: it is possible that the container object is in the middle of an inventory refresh
  161. // causing findItem() to fail, so just temporarily disable everything
  162. mDirty = TRUE;
  163. const char* enableNames[]={
  164. "LabelItemName",
  165. "LabelItemDesc",
  166. "LabelCreatorName",
  167. "BtnCreator",
  168. "LabelOwnerName",
  169. "BtnOwner",
  170. "CheckOwnerModify",
  171. "CheckOwnerCopy",
  172. "CheckOwnerTransfer",
  173. "CheckShareWithGroup",
  174. "CheckEveryoneCopy",
  175. "CheckNextOwnerModify",
  176. "CheckNextOwnerCopy",
  177. "CheckNextOwnerTransfer",
  178. "CheckPurchase",
  179. "RadioSaleType",
  180. "Edit Cost"
  181. };
  182. for(size_t t=0; t<LL_ARRAY_SIZE(enableNames); ++t)
  183. {
  184. childSetEnabled(enableNames[t],false);
  185. }
  186. const char* hideNames[]={
  187. "BaseMaskDebug",
  188. "OwnerMaskDebug",
  189. "GroupMaskDebug",
  190. "EveryoneMaskDebug",
  191. "NextMaskDebug"
  192. };
  193. for(size_t t=0; t<LL_ARRAY_SIZE(hideNames); ++t)
  194. {
  195. childSetVisible(hideNames[t],false);
  196. }
  197. }
  198. }
  199. void LLFloaterProperties::draw()
  200. {
  201. if (mDirty)
  202. {
  203. // RN: clear dirty first because refresh can set dirty to TRUE
  204. mDirty = FALSE;
  205. refresh();
  206. }
  207. LLFloater::draw();
  208. }
  209. void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
  210. {
  211. ////////////////////////
  212. // PERMISSIONS LOOKUP //
  213. ////////////////////////
  214. // do not enable the UI for incomplete items.
  215. LLViewerInventoryItem* i = (LLViewerInventoryItem*)item;
  216. BOOL is_complete = i->isComplete();
  217. const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(i->getInventoryType());
  218. const BOOL is_calling_card = (i->getInventoryType() == LLInventoryType::IT_CALLINGCARD);
  219. const LLPermissions& perm = item->getPermissions();
  220. const BOOL can_agent_manipulate = gAgent.allowOperation(PERM_OWNER, perm, 
  221. GP_OBJECT_MANIPULATE);
  222. const BOOL can_agent_sell = gAgent.allowOperation(PERM_OWNER, perm, 
  223.   GP_OBJECT_SET_SALE) &&
  224. !cannot_restrict_permissions;
  225. const BOOL is_link = i->getIsLinkType();
  226. // You need permission to modify the object to modify an inventory
  227. // item in it.
  228. LLViewerObject* object = NULL;
  229. if(!mObjectID.isNull()) object = gObjectList.findObject(mObjectID);
  230. BOOL is_obj_modify = TRUE;
  231. if(object)
  232. {
  233. is_obj_modify = object->permOwnerModify();
  234. }
  235. //////////////////////
  236. // ITEM NAME & DESC //
  237. //////////////////////
  238. BOOL is_modifiable = gAgent.allowOperation(PERM_MODIFY, perm,
  239.    GP_OBJECT_MANIPULATE)
  240. && is_obj_modify && is_complete;
  241. childSetEnabled("LabelItemNameTitle",TRUE);
  242. childSetEnabled("LabelItemName",is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
  243. childSetText("LabelItemName",item->getName());
  244. childSetEnabled("LabelItemDescTitle",TRUE);
  245. childSetEnabled("LabelItemDesc",is_modifiable);
  246. childSetVisible("IconLocked",!is_modifiable);
  247. childSetText("LabelItemDesc",item->getDescription());
  248. //////////////////
  249. // CREATOR NAME //
  250. //////////////////
  251. if(!gCacheName) return;
  252. if(!gAgent.getRegion()) return;
  253. if (item->getCreatorUUID().notNull())
  254. {
  255. std::string name;
  256. gCacheName->getFullName(item->getCreatorUUID(), name);
  257. childSetEnabled("BtnCreator",TRUE);
  258. childSetEnabled("LabelCreatorTitle",TRUE);
  259. childSetEnabled("LabelCreatorName",TRUE);
  260. childSetText("LabelCreatorName",name);
  261. }
  262. else
  263. {
  264. childSetEnabled("BtnCreator",FALSE);
  265. childSetEnabled("LabelCreatorTitle",FALSE);
  266. childSetEnabled("LabelCreatorName",FALSE);
  267. childSetText("LabelCreatorName",getString("unknown"));
  268. }
  269. ////////////////
  270. // OWNER NAME //
  271. ////////////////
  272. if(perm.isOwned())
  273. {
  274. std::string name;
  275. if (perm.isGroupOwned())
  276. {
  277. gCacheName->getGroupName(perm.getGroup(), name);
  278. }
  279. else
  280. {
  281. gCacheName->getFullName(perm.getOwner(), name);
  282. }
  283. childSetEnabled("BtnOwner",TRUE);
  284. childSetEnabled("LabelOwnerTitle",TRUE);
  285. childSetEnabled("LabelOwnerName",TRUE);
  286. childSetText("LabelOwnerName",name);
  287. }
  288. else
  289. {
  290. childSetEnabled("BtnOwner",FALSE);
  291. childSetEnabled("LabelOwnerTitle",FALSE);
  292. childSetEnabled("LabelOwnerName",FALSE);
  293. childSetText("LabelOwnerName",getString("public"));
  294. }
  295. //////////////////
  296. // ACQUIRE DATE //
  297. //////////////////
  298. time_t time_utc = item->getCreationDate();
  299. if (0 == time_utc)
  300. {
  301. childSetText("LabelAcquiredDate",getString("unknown"));
  302. }
  303. else
  304. {
  305. std::string timeStr = getString("acquiredDate");
  306. LLSD substitution;
  307. substitution["datetime"] = (S32) time_utc;
  308. LLStringUtil::format (timeStr, substitution);
  309. childSetText ("LabelAcquiredDate", timeStr);
  310. }
  311. ///////////////////////
  312. // OWNER PERMISSIONS //
  313. ///////////////////////
  314. if(can_agent_manipulate)
  315. {
  316. childSetText("OwnerLabel",getString("you_can"));
  317. }
  318. else
  319. {
  320. childSetText("OwnerLabel",getString("owner_can"));
  321. }
  322. U32 base_mask = perm.getMaskBase();
  323. U32 owner_mask = perm.getMaskOwner();
  324. U32 group_mask = perm.getMaskGroup();
  325. U32 everyone_mask = perm.getMaskEveryone();
  326. U32 next_owner_mask = perm.getMaskNextOwner();
  327. childSetEnabled("OwnerLabel",TRUE);
  328. childSetEnabled("CheckOwnerModify",FALSE);
  329. childSetValue("CheckOwnerModify",LLSD((BOOL)(owner_mask & PERM_MODIFY)));
  330. childSetEnabled("CheckOwnerCopy",FALSE);
  331. childSetValue("CheckOwnerCopy",LLSD((BOOL)(owner_mask & PERM_COPY)));
  332. childSetEnabled("CheckOwnerTransfer",FALSE);
  333. childSetValue("CheckOwnerTransfer",LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
  334. ///////////////////////
  335. // DEBUG PERMISSIONS //
  336. ///////////////////////
  337. if( gSavedSettings.getBOOL("DebugPermissions") )
  338. {
  339. BOOL slam_perm  = FALSE;
  340. BOOL overwrite_group = FALSE;
  341. BOOL overwrite_everyone = FALSE;
  342. if (item->getType() == LLAssetType::AT_OBJECT)
  343. {
  344. U32 flags = item->getFlags();
  345. slam_perm  = flags & LLInventoryItem::II_FLAGS_OBJECT_SLAM_PERM;
  346. overwrite_everyone = flags & LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
  347. overwrite_group = flags & LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
  348. }
  349. std::string perm_string;
  350. perm_string = "B: ";
  351. perm_string += mask_to_string(base_mask);
  352. childSetText("BaseMaskDebug",perm_string);
  353. childSetVisible("BaseMaskDebug",TRUE);
  354. perm_string = "O: ";
  355. perm_string += mask_to_string(owner_mask);
  356. childSetText("OwnerMaskDebug",perm_string);
  357. childSetVisible("OwnerMaskDebug",TRUE);
  358. perm_string = "G";
  359. perm_string += overwrite_group ? "*: " : ": ";
  360. perm_string += mask_to_string(group_mask);
  361. childSetText("GroupMaskDebug",perm_string);
  362. childSetVisible("GroupMaskDebug",TRUE);
  363. perm_string = "E";
  364. perm_string += overwrite_everyone ? "*: " : ": ";
  365. perm_string += mask_to_string(everyone_mask);
  366. childSetText("EveryoneMaskDebug",perm_string);
  367. childSetVisible("EveryoneMaskDebug",TRUE);
  368. perm_string = "N";
  369. perm_string += slam_perm ? "*: " : ": ";
  370. perm_string += mask_to_string(next_owner_mask);
  371. childSetText("NextMaskDebug",perm_string);
  372. childSetVisible("NextMaskDebug",TRUE);
  373. }
  374. else
  375. {
  376. childSetVisible("BaseMaskDebug",FALSE);
  377. childSetVisible("OwnerMaskDebug",FALSE);
  378. childSetVisible("GroupMaskDebug",FALSE);
  379. childSetVisible("EveryoneMaskDebug",FALSE);
  380. childSetVisible("NextMaskDebug",FALSE);
  381. }
  382. /////////////
  383. // SHARING //
  384. /////////////
  385. // Check for ability to change values.
  386. if (is_link || cannot_restrict_permissions)
  387. {
  388. childSetEnabled("CheckShareWithGroup",FALSE);
  389. childSetEnabled("CheckEveryoneCopy",FALSE);
  390. }
  391. else if (is_obj_modify && can_agent_manipulate)
  392. {
  393. childSetEnabled("CheckShareWithGroup",TRUE);
  394. childSetEnabled("CheckEveryoneCopy",(owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
  395. }
  396. else
  397. {
  398. childSetEnabled("CheckShareWithGroup",FALSE);
  399. childSetEnabled("CheckEveryoneCopy",FALSE);
  400. }
  401. // Set values.
  402. BOOL is_group_copy = (group_mask & PERM_COPY) ? TRUE : FALSE;
  403. BOOL is_group_modify = (group_mask & PERM_MODIFY) ? TRUE : FALSE;
  404. BOOL is_group_move = (group_mask & PERM_MOVE) ? TRUE : FALSE;
  405. if (is_group_copy && is_group_modify && is_group_move)
  406. {
  407. childSetValue("CheckShareWithGroup",LLSD((BOOL)TRUE));
  408. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  409. if(ctl)
  410. {
  411. ctl->setTentative(FALSE);
  412. }
  413. }
  414. else if (!is_group_copy && !is_group_modify && !is_group_move)
  415. {
  416. childSetValue("CheckShareWithGroup",LLSD((BOOL)FALSE));
  417. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  418. if(ctl)
  419. {
  420. ctl->setTentative(FALSE);
  421. }
  422. }
  423. else
  424. {
  425. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  426. if(ctl)
  427. {
  428. ctl->setTentative(TRUE);
  429. ctl->set(TRUE);
  430. }
  431. }
  432. childSetValue("CheckEveryoneCopy",LLSD((BOOL)(everyone_mask & PERM_COPY)));
  433. ///////////////
  434. // SALE INFO //
  435. ///////////////
  436. const LLSaleInfo& sale_info = item->getSaleInfo();
  437. BOOL is_for_sale = sale_info.isForSale();
  438. // Check for ability to change values.
  439. if (is_obj_modify && can_agent_sell 
  440. && gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE))
  441. {
  442. childSetEnabled("SaleLabel",is_complete);
  443. childSetEnabled("CheckPurchase",is_complete);
  444. childSetEnabled("NextOwnerLabel",TRUE);
  445. childSetEnabled("CheckNextOwnerModify",(base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
  446. childSetEnabled("CheckNextOwnerCopy",(base_mask & PERM_COPY) && !cannot_restrict_permissions);
  447. childSetEnabled("CheckNextOwnerTransfer",(next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
  448. childSetEnabled("RadioSaleType",is_complete && is_for_sale);
  449. childSetEnabled("TextPrice",is_complete && is_for_sale);
  450. childSetEnabled("Edit Cost",is_complete && is_for_sale);
  451. }
  452. else
  453. {
  454. childSetEnabled("SaleLabel",FALSE);
  455. childSetEnabled("CheckPurchase",FALSE);
  456. childSetEnabled("NextOwnerLabel",FALSE);
  457. childSetEnabled("CheckNextOwnerModify",FALSE);
  458. childSetEnabled("CheckNextOwnerCopy",FALSE);
  459. childSetEnabled("CheckNextOwnerTransfer",FALSE);
  460. childSetEnabled("RadioSaleType",FALSE);
  461. childSetEnabled("TextPrice",FALSE);
  462. childSetEnabled("Edit Cost",FALSE);
  463. }
  464. // Set values.
  465. childSetValue("CheckPurchase", is_for_sale);
  466. childSetEnabled("combobox sale copy", is_for_sale);
  467. childSetEnabled("Edit Cost", is_for_sale);
  468. childSetValue("CheckNextOwnerModify",LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
  469. childSetValue("CheckNextOwnerCopy",LLSD(BOOL(next_owner_mask & PERM_COPY)));
  470. childSetValue("CheckNextOwnerTransfer",LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
  471. LLRadioGroup* radioSaleType = getChild<LLRadioGroup>("RadioSaleType");
  472. if (is_for_sale)
  473. {
  474. radioSaleType->setSelectedIndex((S32)sale_info.getSaleType() - 1);
  475. S32 numerical_price;
  476. numerical_price = sale_info.getSalePrice();
  477. childSetText("Edit Cost",llformat("%d",numerical_price));
  478. }
  479. else
  480. {
  481. radioSaleType->setSelectedIndex(-1);
  482. childSetText("Edit Cost",llformat("%d",0));
  483. }
  484. }
  485. void LLFloaterProperties::onClickCreator()
  486. {
  487. LLInventoryItem* item = findItem();
  488. if(!item) return;
  489. if(!item->getCreatorUUID().isNull())
  490. {
  491. LLAvatarActions::showProfile(item->getCreatorUUID());
  492. }
  493. }
  494. // static
  495. void LLFloaterProperties::onClickOwner()
  496. {
  497. LLInventoryItem* item = findItem();
  498. if(!item) return;
  499. if(item->getPermissions().isGroupOwned())
  500. {
  501. LLGroupActions::show(item->getPermissions().getGroup());
  502. }
  503. else
  504. {
  505. LLAvatarActions::showProfile(item->getPermissions().getOwner());
  506. }
  507. }
  508. // static
  509. void LLFloaterProperties::onCommitName()
  510. {
  511. //llinfos << "LLFloaterProperties::onCommitName()" << llendl;
  512. LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
  513. if(!item)
  514. {
  515. return;
  516. }
  517. LLLineEditor* labelItemName = getChild<LLLineEditor>("LabelItemName");
  518. if(labelItemName&&
  519.    (item->getName() != labelItemName->getText()) && 
  520.    (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)) )
  521. {
  522. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  523. new_item->rename(labelItemName->getText());
  524. if(mObjectID.isNull())
  525. {
  526. new_item->updateServer(FALSE);
  527. gInventory.updateItem(new_item);
  528. gInventory.notifyObservers();
  529. }
  530. else
  531. {
  532. LLViewerObject* object = gObjectList.findObject(mObjectID);
  533. if(object)
  534. {
  535. object->updateInventory(
  536. new_item,
  537. TASK_INVENTORY_ITEM_KEY,
  538. false);
  539. }
  540. }
  541. }
  542. }
  543. void LLFloaterProperties::onCommitDescription()
  544. {
  545. //llinfos << "LLFloaterProperties::onCommitDescription()" << llendl;
  546. LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
  547. if(!item) return;
  548. LLLineEditor* labelItemDesc = getChild<LLLineEditor>("LabelItemDesc");
  549. if(!labelItemDesc)
  550. {
  551. return;
  552. }
  553. if((item->getDescription() != labelItemDesc->getText()) && 
  554.    (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)))
  555. {
  556. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  557. new_item->setDescription(labelItemDesc->getText());
  558. if(mObjectID.isNull())
  559. {
  560. new_item->updateServer(FALSE);
  561. gInventory.updateItem(new_item);
  562. gInventory.notifyObservers();
  563. }
  564. else
  565. {
  566. LLViewerObject* object = gObjectList.findObject(mObjectID);
  567. if(object)
  568. {
  569. object->updateInventory(
  570. new_item,
  571. TASK_INVENTORY_ITEM_KEY,
  572. false);
  573. }
  574. }
  575. }
  576. }
  577. // static
  578. void LLFloaterProperties::onCommitPermissions()
  579. {
  580. //llinfos << "LLFloaterProperties::onCommitPermissions()" << llendl;
  581. LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
  582. if(!item) return;
  583. LLPermissions perm(item->getPermissions());
  584. LLCheckBoxCtrl* CheckShareWithGroup = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  585. if(CheckShareWithGroup)
  586. {
  587. perm.setGroupBits(gAgent.getID(), gAgent.getGroupID(),
  588. CheckShareWithGroup->get(),
  589. PERM_MODIFY | PERM_MOVE | PERM_COPY);
  590. }
  591. LLCheckBoxCtrl* CheckEveryoneCopy = getChild<LLCheckBoxCtrl>("CheckEveryoneCopy");
  592. if(CheckEveryoneCopy)
  593. {
  594. perm.setEveryoneBits(gAgent.getID(), gAgent.getGroupID(),
  595.  CheckEveryoneCopy->get(), PERM_COPY);
  596. }
  597. LLCheckBoxCtrl* CheckNextOwnerModify = getChild<LLCheckBoxCtrl>("CheckNextOwnerModify");
  598. if(CheckNextOwnerModify)
  599. {
  600. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  601. CheckNextOwnerModify->get(), PERM_MODIFY);
  602. }
  603. LLCheckBoxCtrl* CheckNextOwnerCopy = getChild<LLCheckBoxCtrl>("CheckNextOwnerCopy");
  604. if(CheckNextOwnerCopy)
  605. {
  606. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  607. CheckNextOwnerCopy->get(), PERM_COPY);
  608. }
  609. LLCheckBoxCtrl* CheckNextOwnerTransfer = getChild<LLCheckBoxCtrl>("CheckNextOwnerTransfer");
  610. if(CheckNextOwnerTransfer)
  611. {
  612. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  613. CheckNextOwnerTransfer->get(), PERM_TRANSFER);
  614. }
  615. if(perm != item->getPermissions()
  616. && item->isComplete())
  617. {
  618. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  619. new_item->setPermissions(perm);
  620. U32 flags = new_item->getFlags();
  621. // If next owner permissions have changed (and this is an object)
  622. // then set the slam permissions flag so that they are applied on rez.
  623. if((perm.getMaskNextOwner()!=item->getPermissions().getMaskNextOwner())
  624.    && (item->getType() == LLAssetType::AT_OBJECT))
  625. {
  626. flags |= LLInventoryItem::II_FLAGS_OBJECT_SLAM_PERM;
  627. }
  628. // If everyone permissions have changed (and this is an object)
  629. // then set the overwrite everyone permissions flag so they
  630. // are applied on rez.
  631. if ((perm.getMaskEveryone()!=item->getPermissions().getMaskEveryone())
  632. && (item->getType() == LLAssetType::AT_OBJECT))
  633. {
  634. flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
  635. }
  636. // If group permissions have changed (and this is an object)
  637. // then set the overwrite group permissions flag so they
  638. // are applied on rez.
  639. if ((perm.getMaskGroup()!=item->getPermissions().getMaskGroup())
  640. && (item->getType() == LLAssetType::AT_OBJECT))
  641. {
  642. flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
  643. }
  644. new_item->setFlags(flags);
  645. if(mObjectID.isNull())
  646. {
  647. new_item->updateServer(FALSE);
  648. gInventory.updateItem(new_item);
  649. gInventory.notifyObservers();
  650. }
  651. else
  652. {
  653. LLViewerObject* object = gObjectList.findObject(mObjectID);
  654. if(object)
  655. {
  656. object->updateInventory(
  657. new_item,
  658. TASK_INVENTORY_ITEM_KEY,
  659. false);
  660. }
  661. }
  662. }
  663. else
  664. {
  665. // need to make sure we don't just follow the click
  666. refresh();
  667. }
  668. }
  669. // static
  670. void LLFloaterProperties::onCommitSaleInfo()
  671. {
  672. //llinfos << "LLFloaterProperties::onCommitSaleInfo()" << llendl;
  673. updateSaleInfo();
  674. }
  675. // static
  676. void LLFloaterProperties::onCommitSaleType()
  677. {
  678. //llinfos << "LLFloaterProperties::onCommitSaleType()" << llendl;
  679. updateSaleInfo();
  680. }
  681. void LLFloaterProperties::updateSaleInfo()
  682. {
  683. LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
  684. if(!item) return;
  685. LLSaleInfo sale_info(item->getSaleInfo());
  686. if(!gAgent.allowOperation(PERM_TRANSFER, item->getPermissions(), GP_OBJECT_SET_SALE))
  687. {
  688. childSetValue("CheckPurchase",LLSD((BOOL)FALSE));
  689. }
  690. if((BOOL)childGetValue("CheckPurchase"))
  691. {
  692. // turn on sale info
  693. LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_COPY;
  694. LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("RadioSaleType");
  695. if(RadioSaleType)
  696. {
  697. switch (RadioSaleType->getSelectedIndex())
  698. {
  699. case 0:
  700. sale_type = LLSaleInfo::FS_ORIGINAL;
  701. break;
  702. case 1:
  703. sale_type = LLSaleInfo::FS_COPY;
  704. break;
  705. case 2:
  706. sale_type = LLSaleInfo::FS_CONTENTS;
  707. break;
  708. default:
  709. sale_type = LLSaleInfo::FS_COPY;
  710. break;
  711. }
  712. }
  713. if (sale_type == LLSaleInfo::FS_COPY 
  714. && !gAgent.allowOperation(PERM_COPY, item->getPermissions(), 
  715.   GP_OBJECT_SET_SALE))
  716. {
  717. sale_type = LLSaleInfo::FS_ORIGINAL;
  718. }
  719.      
  720. S32 price = -1;
  721. price =  getChild<LLUICtrl>("Edit Cost")->getValue().asInteger();;
  722. // Invalid data - turn off the sale
  723. if (price < 0)
  724. {
  725. sale_type = LLSaleInfo::FS_NOT;
  726. price = 0;
  727. }
  728. sale_info.setSaleType(sale_type);
  729. sale_info.setSalePrice(price);
  730. }
  731. else
  732. {
  733. sale_info.setSaleType(LLSaleInfo::FS_NOT);
  734. }
  735. if(sale_info != item->getSaleInfo()
  736. && item->isComplete())
  737. {
  738. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  739. // Force an update on the sale price at rez
  740. if (item->getType() == LLAssetType::AT_OBJECT)
  741. {
  742. U32 flags = new_item->getFlags();
  743. flags |= LLInventoryItem::II_FLAGS_OBJECT_SLAM_SALE;
  744. new_item->setFlags(flags);
  745. }
  746. new_item->setSaleInfo(sale_info);
  747. if(mObjectID.isNull())
  748. {
  749. // This is in the agent's inventory.
  750. new_item->updateServer(FALSE);
  751. gInventory.updateItem(new_item);
  752. gInventory.notifyObservers();
  753. }
  754. else
  755. {
  756. // This is in an object's contents.
  757. LLViewerObject* object = gObjectList.findObject(mObjectID);
  758. if(object)
  759. {
  760. object->updateInventory(
  761. new_item,
  762. TASK_INVENTORY_ITEM_KEY,
  763. false);
  764. }
  765. }
  766. }
  767. else
  768. {
  769. // need to make sure we don't just follow the click
  770. refresh();
  771. }
  772. }
  773. LLInventoryItem* LLFloaterProperties::findItem() const
  774. {
  775. LLInventoryItem* item = NULL;
  776. if(mObjectID.isNull())
  777. {
  778. // it is in agent inventory
  779. item = gInventory.getItem(mItemID);
  780. }
  781. else
  782. {
  783. LLViewerObject* object = gObjectList.findObject(mObjectID);
  784. if(object)
  785. {
  786. item = (LLInventoryItem*)object->getInventoryObject(mItemID);
  787. }
  788. }
  789. return item;
  790. }
  791. //static
  792. void LLFloaterProperties::dirtyAll()
  793. {
  794. LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("properties");
  795. for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
  796.  iter != inst_list.end(); ++iter)
  797. {
  798. LLFloaterProperties* floater = dynamic_cast<LLFloaterProperties*>(*iter);
  799. llassert(floater); // else cast failed - wrong type D:
  800. if (floater)
  801. {
  802. floater->dirty();
  803. }
  804. }
  805. }
  806. ///----------------------------------------------------------------------------
  807. /// LLMultiProperties
  808. ///----------------------------------------------------------------------------
  809. LLMultiProperties::LLMultiProperties()
  810. : LLMultiFloater(LLSD())
  811. {
  812. // *TODO: There should be a .xml file for this
  813. const LLRect& nextrect = LLFloaterReg::getFloaterRect("properties"); // place where the next properties should show up
  814. if (nextrect.getWidth() > 0)
  815. {
  816. setRect(nextrect);
  817. }
  818. else
  819. {
  820. // start with a small rect in the top-left corner ; will get resized
  821. LLRect rect;
  822. rect.setLeftTopAndSize(0, gViewerWindow->getWindowHeightScaled(), 20, 20);
  823. setRect(rect);
  824. }
  825. setTitle(LLTrans::getString("MultiPropertiesTitle"));
  826. buildTabContainer();
  827. }
  828. ///----------------------------------------------------------------------------
  829. /// Local function definitions
  830. ///----------------------------------------------------------------------------