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

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llsidepaneliteminfo.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 "llsidepaneliteminfo.h"
  34. #include "roles_constants.h"
  35. #include "llagent.h"
  36. #include "llavataractions.h"
  37. #include "llbutton.h"
  38. #include "llfloaterreg.h"
  39. #include "llgroupactions.h"
  40. #include "llinventorymodel.h"
  41. #include "llinventoryobserver.h"
  42. #include "lllineeditor.h"
  43. #include "llradiogroup.h"
  44. #include "llviewercontrol.h"
  45. #include "llviewerinventory.h"
  46. #include "llviewerobjectlist.h"
  47. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. // Class LLItemPropertiesObserver
  49. //
  50. // Helper class to watch for changes to the item.
  51. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. class LLItemPropertiesObserver : public LLInventoryObserver
  53. {
  54. public:
  55. LLItemPropertiesObserver(LLSidepanelItemInfo* floater)
  56. : mFloater(floater)
  57. {
  58. gInventory.addObserver(this);
  59. }
  60. virtual ~LLItemPropertiesObserver()
  61. {
  62. gInventory.removeObserver(this);
  63. }
  64. virtual void changed(U32 mask);
  65. private:
  66. LLSidepanelItemInfo* mFloater;
  67. };
  68. void LLItemPropertiesObserver::changed(U32 mask)
  69. {
  70. // if there's a change we're interested in.
  71. if((mask & (LLInventoryObserver::LABEL | LLInventoryObserver::INTERNAL | LLInventoryObserver::REMOVE)) != 0)
  72. {
  73. mFloater->dirty();
  74. }
  75. }
  76. ///----------------------------------------------------------------------------
  77. /// Class LLSidepanelItemInfo
  78. ///----------------------------------------------------------------------------
  79. static LLRegisterPanelClassWrapper<LLSidepanelItemInfo> t_item_info("sidepanel_item_info");
  80. // Default constructor
  81. LLSidepanelItemInfo::LLSidepanelItemInfo()
  82.   : mItemID(LLUUID::null)
  83. {
  84. mPropertiesObserver = new LLItemPropertiesObserver(this);
  85. //LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml");
  86. }
  87. // Destroys the object
  88. LLSidepanelItemInfo::~LLSidepanelItemInfo()
  89. {
  90. delete mPropertiesObserver;
  91. mPropertiesObserver = NULL;
  92. }
  93. // virtual
  94. BOOL LLSidepanelItemInfo::postBuild()
  95. {
  96. LLSidepanelInventorySubpanel::postBuild();
  97. childSetPrevalidate("LabelItemName",&LLTextValidate::validateASCIIPrintableNoPipe);
  98. getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitName,this));
  99. childSetPrevalidate("LabelItemDesc",&LLTextValidate::validateASCIIPrintableNoPipe);
  100. getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLSidepanelItemInfo:: onCommitDescription, this));
  101. // Creator information
  102. getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onClickCreator,this));
  103. // owner information
  104. getChild<LLUICtrl>("BtnOwner")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onClickOwner,this));
  105. // acquired date
  106. // owner permissions
  107. // Permissions debug text
  108. // group permissions
  109. getChild<LLUICtrl>("CheckShareWithGroup")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
  110. // everyone permissions
  111. getChild<LLUICtrl>("CheckEveryoneCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
  112. // next owner permissions
  113. getChild<LLUICtrl>("CheckNextOwnerModify")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
  114. getChild<LLUICtrl>("CheckNextOwnerCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
  115. getChild<LLUICtrl>("CheckNextOwnerTransfer")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
  116. // Mark for sale or not, and sale info
  117. getChild<LLUICtrl>("CheckPurchase")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleInfo, this));
  118. getChild<LLUICtrl>("RadioSaleType")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleType, this));
  119. // "Price" label for edit
  120. getChild<LLUICtrl>("Edit Cost")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleInfo, this));
  121. refresh();
  122. return TRUE;
  123. }
  124. void LLSidepanelItemInfo::setObjectID(const LLUUID& object_id)
  125. {
  126. mObjectID = object_id;
  127. }
  128. void LLSidepanelItemInfo::setItemID(const LLUUID& item_id)
  129. {
  130. mItemID = item_id;
  131. }
  132. void LLSidepanelItemInfo::reset()
  133. {
  134. LLSidepanelInventorySubpanel::reset();
  135. mObjectID = LLUUID::null;
  136. mItemID = LLUUID::null;
  137. }
  138. void LLSidepanelItemInfo::refresh()
  139. {
  140. LLViewerInventoryItem* item = findItem();
  141. if(item)
  142. {
  143. refreshFromItem(item);
  144. updateVerbs();
  145. return;
  146. }
  147. else
  148. {
  149. if (getIsEditing())
  150. {
  151. setIsEditing(FALSE);
  152. }
  153. }
  154. if (!getIsEditing())
  155. {
  156. const std::string no_item_names[]={
  157. "LabelItemName",
  158. "LabelItemDesc",
  159. "LabelCreatorName",
  160. "LabelOwnerName",
  161. "CheckOwnerModify",
  162. "CheckOwnerCopy",
  163. "CheckOwnerTransfer",
  164. "CheckShareWithGroup",
  165. "CheckEveryoneCopy",
  166. "CheckNextOwnerModify",
  167. "CheckNextOwnerCopy",
  168. "CheckNextOwnerTransfer",
  169. "CheckPurchase",
  170. "RadioSaleType",
  171. "Edit Cost"
  172. };
  173. for(size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t)
  174. {
  175. childSetEnabled(no_item_names[t],false);
  176. }
  177. const std::string hide_names[]={
  178. "BaseMaskDebug",
  179. "OwnerMaskDebug",
  180. "GroupMaskDebug",
  181. "EveryoneMaskDebug",
  182. "NextMaskDebug"
  183. };
  184. for(size_t t=0; t<LL_ARRAY_SIZE(hide_names); ++t)
  185. {
  186. childSetVisible(hide_names[t],false);
  187. }
  188. }
  189. if (!item)
  190. {
  191. const std::string no_edit_mode_names[]={
  192. "BtnCreator",
  193. "BtnOwner",
  194. };
  195. for(size_t t=0; t<LL_ARRAY_SIZE(no_edit_mode_names); ++t)
  196. {
  197. childSetEnabled(no_edit_mode_names[t],false);
  198. }
  199. }
  200. updateVerbs();
  201. }
  202. void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
  203. {
  204. ////////////////////////
  205. // PERMISSIONS LOOKUP //
  206. ////////////////////////
  207. llassert(item);
  208. if (!item) return;
  209. // do not enable the UI for incomplete items.
  210. BOOL is_complete = item->isComplete();
  211. const BOOL cannot_restrict_permissions = LLInventoryType::cannotRestrictPermissions(item->getInventoryType());
  212. const BOOL is_calling_card = (item->getInventoryType() == LLInventoryType::IT_CALLINGCARD);
  213. const LLPermissions& perm = item->getPermissions();
  214. const BOOL can_agent_manipulate = gAgent.allowOperation(PERM_OWNER, perm, 
  215. GP_OBJECT_MANIPULATE);
  216. const BOOL can_agent_sell = gAgent.allowOperation(PERM_OWNER, perm, 
  217.   GP_OBJECT_SET_SALE) &&
  218. !cannot_restrict_permissions;
  219. const BOOL is_link = item->getIsLinkType();
  220. const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
  221. bool not_in_trash = (item->getUUID() != trash_id) && !gInventory.isObjectDescendentOf(item->getUUID(), trash_id);
  222. // You need permission to modify the object to modify an inventory
  223. // item in it.
  224. LLViewerObject* object = NULL;
  225. if(!mObjectID.isNull()) object = gObjectList.findObject(mObjectID);
  226. BOOL is_obj_modify = TRUE;
  227. if(object)
  228. {
  229. is_obj_modify = object->permOwnerModify();
  230. }
  231. //////////////////////
  232. // ITEM NAME & DESC //
  233. //////////////////////
  234. BOOL is_modifiable = gAgent.allowOperation(PERM_MODIFY, perm,
  235.    GP_OBJECT_MANIPULATE)
  236. && is_obj_modify && is_complete && not_in_trash;
  237. childSetEnabled("LabelItemNameTitle",TRUE);
  238. childSetEnabled("LabelItemName",is_modifiable && !is_calling_card); // for now, don't allow rename of calling cards
  239. childSetText("LabelItemName",item->getName());
  240. childSetEnabled("LabelItemDescTitle",TRUE);
  241. childSetEnabled("LabelItemDesc",is_modifiable);
  242. childSetVisible("IconLocked",!is_modifiable);
  243. childSetText("LabelItemDesc",item->getDescription());
  244. //////////////////
  245. // CREATOR NAME //
  246. //////////////////
  247. if(!gCacheName) return;
  248. if(!gAgent.getRegion()) return;
  249. if (item->getCreatorUUID().notNull())
  250. {
  251. std::string name;
  252. gCacheName->getFullName(item->getCreatorUUID(), name);
  253. childSetEnabled("BtnCreator",TRUE);
  254. childSetEnabled("LabelCreatorTitle",TRUE);
  255. childSetEnabled("LabelCreatorName",TRUE);
  256. childSetText("LabelCreatorName",name);
  257. }
  258. else
  259. {
  260. childSetEnabled("BtnCreator",FALSE);
  261. childSetEnabled("LabelCreatorTitle",FALSE);
  262. childSetEnabled("LabelCreatorName",FALSE);
  263. childSetText("LabelCreatorName",getString("unknown"));
  264. }
  265. ////////////////
  266. // OWNER NAME //
  267. ////////////////
  268. if(perm.isOwned())
  269. {
  270. std::string name;
  271. if (perm.isGroupOwned())
  272. {
  273. gCacheName->getGroupName(perm.getGroup(), name);
  274. }
  275. else
  276. {
  277. gCacheName->getFullName(perm.getOwner(), name);
  278. }
  279. childSetEnabled("BtnOwner",TRUE);
  280. childSetEnabled("LabelOwnerTitle",TRUE);
  281. childSetEnabled("LabelOwnerName",TRUE);
  282. childSetText("LabelOwnerName",name);
  283. }
  284. else
  285. {
  286. childSetEnabled("BtnOwner",FALSE);
  287. childSetEnabled("LabelOwnerTitle",FALSE);
  288. childSetEnabled("LabelOwnerName",FALSE);
  289. childSetText("LabelOwnerName",getString("public"));
  290. }
  291. //////////////////
  292. // ACQUIRE DATE //
  293. //////////////////
  294. time_t time_utc = item->getCreationDate();
  295. if (0 == time_utc)
  296. {
  297. childSetText("LabelAcquiredDate",getString("unknown"));
  298. }
  299. else
  300. {
  301. std::string timeStr = getString("acquiredDate");
  302. LLSD substitution;
  303. substitution["datetime"] = (S32) time_utc;
  304. LLStringUtil::format (timeStr, substitution);
  305. childSetText ("LabelAcquiredDate", timeStr);
  306. }
  307. /////////////////////////////////////
  308. // PERMISSIONS AND SALE ITEM HIDING
  309. /////////////////////////////////////
  310. const std::string perm_and_sale_items[]={
  311. "perms_inv",
  312. "OwnerLabel",
  313. "perm_modify",
  314. "CheckOwnerModify",
  315. "CheckOwnerCopy",
  316. "CheckOwnerTransfer",
  317. "GroupLabel",
  318. "CheckShareWithGroup",
  319. "AnyoneLabel",
  320. "CheckEveryoneCopy",
  321. "NextOwnerLabel",
  322. "CheckNextOwnerModify",
  323. "CheckNextOwnerCopy",
  324. "CheckNextOwnerTransfer",
  325. "CheckPurchase",
  326. "SaleLabel",
  327. "RadioSaleType",
  328. "combobox sale copy",
  329. "Edit Cost",
  330. "TextPrice"
  331. };
  332. const std::string debug_items[]={
  333. "BaseMaskDebug",
  334. "OwnerMaskDebug",
  335. "GroupMaskDebug",
  336. "EveryoneMaskDebug",
  337. "NextMaskDebug"
  338. };
  339. // Hide permissions checkboxes and labels and for sale info if in the trash
  340. // or ui elements don't apply to these objects and return from function
  341. if (!not_in_trash || cannot_restrict_permissions)
  342. {
  343. for(size_t t=0; t<LL_ARRAY_SIZE(perm_and_sale_items); ++t)
  344. {
  345. childSetVisible(perm_and_sale_items[t],false);
  346. }
  347. for(size_t t=0; t<LL_ARRAY_SIZE(debug_items); ++t)
  348. {
  349. childSetVisible(debug_items[t],false);
  350. }
  351. return;
  352. }
  353. else // Make sure perms and sale ui elements are visible
  354. {
  355. for(size_t t=0; t<LL_ARRAY_SIZE(perm_and_sale_items); ++t)
  356. {
  357. childSetVisible(perm_and_sale_items[t],true);
  358. }
  359. }
  360. ///////////////////////
  361. // OWNER PERMISSIONS //
  362. ///////////////////////
  363. if(can_agent_manipulate)
  364. {
  365. childSetText("OwnerLabel",getString("you_can"));
  366. }
  367. else
  368. {
  369. childSetText("OwnerLabel",getString("owner_can"));
  370. }
  371. U32 base_mask = perm.getMaskBase();
  372. U32 owner_mask = perm.getMaskOwner();
  373. U32 group_mask = perm.getMaskGroup();
  374. U32 everyone_mask = perm.getMaskEveryone();
  375. U32 next_owner_mask = perm.getMaskNextOwner();
  376. childSetEnabled("OwnerLabel",TRUE);
  377. childSetEnabled("CheckOwnerModify",FALSE);
  378. childSetValue("CheckOwnerModify",LLSD((BOOL)(owner_mask & PERM_MODIFY)));
  379. childSetEnabled("CheckOwnerCopy",FALSE);
  380. childSetValue("CheckOwnerCopy",LLSD((BOOL)(owner_mask & PERM_COPY)));
  381. childSetEnabled("CheckOwnerTransfer",FALSE);
  382. childSetValue("CheckOwnerTransfer",LLSD((BOOL)(owner_mask & PERM_TRANSFER)));
  383. ///////////////////////
  384. // DEBUG PERMISSIONS //
  385. ///////////////////////
  386. if( gSavedSettings.getBOOL("DebugPermissions") )
  387. {
  388. BOOL slam_perm  = FALSE;
  389. BOOL overwrite_group = FALSE;
  390. BOOL overwrite_everyone = FALSE;
  391. if (item->getType() == LLAssetType::AT_OBJECT)
  392. {
  393. U32 flags = item->getFlags();
  394. slam_perm  = flags & LLInventoryItem::II_FLAGS_OBJECT_SLAM_PERM;
  395. overwrite_everyone = flags & LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
  396. overwrite_group = flags & LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
  397. }
  398. std::string perm_string;
  399. perm_string = "B: ";
  400. perm_string += mask_to_string(base_mask);
  401. childSetText("BaseMaskDebug",perm_string);
  402. childSetVisible("BaseMaskDebug",TRUE);
  403. perm_string = "O: ";
  404. perm_string += mask_to_string(owner_mask);
  405. childSetText("OwnerMaskDebug",perm_string);
  406. childSetVisible("OwnerMaskDebug",TRUE);
  407. perm_string = "G";
  408. perm_string += overwrite_group ? "*: " : ": ";
  409. perm_string += mask_to_string(group_mask);
  410. childSetText("GroupMaskDebug",perm_string);
  411. childSetVisible("GroupMaskDebug",TRUE);
  412. perm_string = "E";
  413. perm_string += overwrite_everyone ? "*: " : ": ";
  414. perm_string += mask_to_string(everyone_mask);
  415. childSetText("EveryoneMaskDebug",perm_string);
  416. childSetVisible("EveryoneMaskDebug",TRUE);
  417. perm_string = "N";
  418. perm_string += slam_perm ? "*: " : ": ";
  419. perm_string += mask_to_string(next_owner_mask);
  420. childSetText("NextMaskDebug",perm_string);
  421. childSetVisible("NextMaskDebug",TRUE);
  422. }
  423. else
  424. {
  425. childSetVisible("BaseMaskDebug",FALSE);
  426. childSetVisible("OwnerMaskDebug",FALSE);
  427. childSetVisible("GroupMaskDebug",FALSE);
  428. childSetVisible("EveryoneMaskDebug",FALSE);
  429. childSetVisible("NextMaskDebug",FALSE);
  430. }
  431. /////////////
  432. // SHARING //
  433. /////////////
  434. // Check for ability to change values.
  435. if (is_link || cannot_restrict_permissions)
  436. {
  437. childSetEnabled("CheckShareWithGroup",FALSE);
  438. childSetEnabled("CheckEveryoneCopy",FALSE);
  439. }
  440. else if (is_obj_modify && can_agent_manipulate)
  441. {
  442. childSetEnabled("CheckShareWithGroup",TRUE);
  443. childSetEnabled("CheckEveryoneCopy",(owner_mask & PERM_COPY) && (owner_mask & PERM_TRANSFER));
  444. }
  445. else
  446. {
  447. childSetEnabled("CheckShareWithGroup",FALSE);
  448. childSetEnabled("CheckEveryoneCopy",FALSE);
  449. }
  450. // Set values.
  451. BOOL is_group_copy = (group_mask & PERM_COPY) ? TRUE : FALSE;
  452. BOOL is_group_modify = (group_mask & PERM_MODIFY) ? TRUE : FALSE;
  453. BOOL is_group_move = (group_mask & PERM_MOVE) ? TRUE : FALSE;
  454. if (is_group_copy && is_group_modify && is_group_move)
  455. {
  456. childSetValue("CheckShareWithGroup",LLSD((BOOL)TRUE));
  457. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  458. if(ctl)
  459. {
  460. ctl->setTentative(FALSE);
  461. }
  462. }
  463. else if (!is_group_copy && !is_group_modify && !is_group_move)
  464. {
  465. childSetValue("CheckShareWithGroup",LLSD((BOOL)FALSE));
  466. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  467. if(ctl)
  468. {
  469. ctl->setTentative(FALSE);
  470. }
  471. }
  472. else
  473. {
  474. LLCheckBoxCtrl* ctl = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  475. if(ctl)
  476. {
  477. ctl->setTentative(TRUE);
  478. ctl->set(TRUE);
  479. }
  480. }
  481. childSetValue("CheckEveryoneCopy",LLSD((BOOL)(everyone_mask & PERM_COPY)));
  482. ///////////////
  483. // SALE INFO //
  484. ///////////////
  485. const LLSaleInfo& sale_info = item->getSaleInfo();
  486. BOOL is_for_sale = sale_info.isForSale();
  487. // Check for ability to change values.
  488. if (is_obj_modify && can_agent_sell 
  489. && gAgent.allowOperation(PERM_TRANSFER, perm, GP_OBJECT_MANIPULATE))
  490. {
  491. childSetEnabled("SaleLabel",is_complete);
  492. childSetEnabled("CheckPurchase",is_complete);
  493. childSetEnabled("NextOwnerLabel",TRUE);
  494. childSetEnabled("CheckNextOwnerModify",(base_mask & PERM_MODIFY) && !cannot_restrict_permissions);
  495. childSetEnabled("CheckNextOwnerCopy",(base_mask & PERM_COPY) && !cannot_restrict_permissions);
  496. childSetEnabled("CheckNextOwnerTransfer",(next_owner_mask & PERM_COPY) && !cannot_restrict_permissions);
  497. childSetEnabled("RadioSaleType",is_complete && is_for_sale);
  498. childSetEnabled("TextPrice",is_complete && is_for_sale);
  499. childSetEnabled("Edit Cost",is_complete && is_for_sale);
  500. }
  501. else
  502. {
  503. childSetEnabled("SaleLabel",FALSE);
  504. childSetEnabled("CheckPurchase",FALSE);
  505. childSetEnabled("NextOwnerLabel",FALSE);
  506. childSetEnabled("CheckNextOwnerModify",FALSE);
  507. childSetEnabled("CheckNextOwnerCopy",FALSE);
  508. childSetEnabled("CheckNextOwnerTransfer",FALSE);
  509. childSetEnabled("RadioSaleType",FALSE);
  510. childSetEnabled("TextPrice",FALSE);
  511. childSetEnabled("Edit Cost",FALSE);
  512. }
  513. // Set values.
  514. childSetValue("CheckPurchase", is_for_sale);
  515. childSetEnabled("combobox sale copy", is_for_sale);
  516. childSetEnabled("Edit Cost", is_for_sale);
  517. childSetValue("CheckNextOwnerModify",LLSD(BOOL(next_owner_mask & PERM_MODIFY)));
  518. childSetValue("CheckNextOwnerCopy",LLSD(BOOL(next_owner_mask & PERM_COPY)));
  519. childSetValue("CheckNextOwnerTransfer",LLSD(BOOL(next_owner_mask & PERM_TRANSFER)));
  520. LLRadioGroup* radioSaleType = getChild<LLRadioGroup>("RadioSaleType");
  521. if (is_for_sale)
  522. {
  523. radioSaleType->setSelectedIndex((S32)sale_info.getSaleType() - 1);
  524. S32 numerical_price;
  525. numerical_price = sale_info.getSalePrice();
  526. childSetText("Edit Cost",llformat("%d",numerical_price));
  527. }
  528. else
  529. {
  530. radioSaleType->setSelectedIndex(-1);
  531. childSetText("Edit Cost",llformat("%d",0));
  532. }
  533. }
  534. void LLSidepanelItemInfo::onClickCreator()
  535. {
  536. LLViewerInventoryItem* item = findItem();
  537. if(!item) return;
  538. if(!item->getCreatorUUID().isNull())
  539. {
  540. LLAvatarActions::showProfile(item->getCreatorUUID());
  541. }
  542. }
  543. // static
  544. void LLSidepanelItemInfo::onClickOwner()
  545. {
  546. LLViewerInventoryItem* item = findItem();
  547. if(!item) return;
  548. if(item->getPermissions().isGroupOwned())
  549. {
  550. LLGroupActions::show(item->getPermissions().getGroup());
  551. }
  552. else
  553. {
  554. LLAvatarActions::showProfile(item->getPermissions().getOwner());
  555. }
  556. }
  557. // static
  558. void LLSidepanelItemInfo::onCommitName()
  559. {
  560. //llinfos << "LLSidepanelItemInfo::onCommitName()" << llendl;
  561. LLViewerInventoryItem* item = findItem();
  562. if(!item)
  563. {
  564. return;
  565. }
  566. LLLineEditor* labelItemName = getChild<LLLineEditor>("LabelItemName");
  567. if(labelItemName&&
  568.    (item->getName() != labelItemName->getText()) && 
  569.    (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)) )
  570. {
  571. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  572. new_item->rename(labelItemName->getText());
  573. if(mObjectID.isNull())
  574. {
  575. new_item->updateServer(FALSE);
  576. gInventory.updateItem(new_item);
  577. gInventory.notifyObservers();
  578. }
  579. else
  580. {
  581. LLViewerObject* object = gObjectList.findObject(mObjectID);
  582. if(object)
  583. {
  584. object->updateInventory(
  585. new_item,
  586. TASK_INVENTORY_ITEM_KEY,
  587. false);
  588. }
  589. }
  590. }
  591. }
  592. void LLSidepanelItemInfo::onCommitDescription()
  593. {
  594. //llinfos << "LLSidepanelItemInfo::onCommitDescription()" << llendl;
  595. LLViewerInventoryItem* item = findItem();
  596. if(!item) return;
  597. LLLineEditor* labelItemDesc = getChild<LLLineEditor>("LabelItemDesc");
  598. if(!labelItemDesc)
  599. {
  600. return;
  601. }
  602. if((item->getDescription() != labelItemDesc->getText()) && 
  603.    (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE)))
  604. {
  605. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  606. new_item->setDescription(labelItemDesc->getText());
  607. if(mObjectID.isNull())
  608. {
  609. new_item->updateServer(FALSE);
  610. gInventory.updateItem(new_item);
  611. gInventory.notifyObservers();
  612. }
  613. else
  614. {
  615. LLViewerObject* object = gObjectList.findObject(mObjectID);
  616. if(object)
  617. {
  618. object->updateInventory(
  619. new_item,
  620. TASK_INVENTORY_ITEM_KEY,
  621. false);
  622. }
  623. }
  624. }
  625. }
  626. // static
  627. void LLSidepanelItemInfo::onCommitPermissions()
  628. {
  629. //llinfos << "LLSidepanelItemInfo::onCommitPermissions()" << llendl;
  630. LLViewerInventoryItem* item = findItem();
  631. if(!item) return;
  632. LLPermissions perm(item->getPermissions());
  633. LLCheckBoxCtrl* CheckShareWithGroup = getChild<LLCheckBoxCtrl>("CheckShareWithGroup");
  634. if(CheckShareWithGroup)
  635. {
  636. perm.setGroupBits(gAgent.getID(), gAgent.getGroupID(),
  637. CheckShareWithGroup->get(),
  638. PERM_MODIFY | PERM_MOVE | PERM_COPY);
  639. }
  640. LLCheckBoxCtrl* CheckEveryoneCopy = getChild<LLCheckBoxCtrl>("CheckEveryoneCopy");
  641. if(CheckEveryoneCopy)
  642. {
  643. perm.setEveryoneBits(gAgent.getID(), gAgent.getGroupID(),
  644.  CheckEveryoneCopy->get(), PERM_COPY);
  645. }
  646. LLCheckBoxCtrl* CheckNextOwnerModify = getChild<LLCheckBoxCtrl>("CheckNextOwnerModify");
  647. if(CheckNextOwnerModify)
  648. {
  649. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  650. CheckNextOwnerModify->get(), PERM_MODIFY);
  651. }
  652. LLCheckBoxCtrl* CheckNextOwnerCopy = getChild<LLCheckBoxCtrl>("CheckNextOwnerCopy");
  653. if(CheckNextOwnerCopy)
  654. {
  655. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  656. CheckNextOwnerCopy->get(), PERM_COPY);
  657. }
  658. LLCheckBoxCtrl* CheckNextOwnerTransfer = getChild<LLCheckBoxCtrl>("CheckNextOwnerTransfer");
  659. if(CheckNextOwnerTransfer)
  660. {
  661. perm.setNextOwnerBits(gAgent.getID(), gAgent.getGroupID(),
  662. CheckNextOwnerTransfer->get(), PERM_TRANSFER);
  663. }
  664. if(perm != item->getPermissions()
  665. && item->isComplete())
  666. {
  667. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  668. new_item->setPermissions(perm);
  669. U32 flags = new_item->getFlags();
  670. // If next owner permissions have changed (and this is an object)
  671. // then set the slam permissions flag so that they are applied on rez.
  672. if((perm.getMaskNextOwner()!=item->getPermissions().getMaskNextOwner())
  673.    && (item->getType() == LLAssetType::AT_OBJECT))
  674. {
  675. flags |= LLInventoryItem::II_FLAGS_OBJECT_SLAM_PERM;
  676. }
  677. // If everyone permissions have changed (and this is an object)
  678. // then set the overwrite everyone permissions flag so they
  679. // are applied on rez.
  680. if ((perm.getMaskEveryone()!=item->getPermissions().getMaskEveryone())
  681. && (item->getType() == LLAssetType::AT_OBJECT))
  682. {
  683. flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_EVERYONE;
  684. }
  685. // If group permissions have changed (and this is an object)
  686. // then set the overwrite group permissions flag so they
  687. // are applied on rez.
  688. if ((perm.getMaskGroup()!=item->getPermissions().getMaskGroup())
  689. && (item->getType() == LLAssetType::AT_OBJECT))
  690. {
  691. flags |= LLInventoryItem::II_FLAGS_OBJECT_PERM_OVERWRITE_GROUP;
  692. }
  693. new_item->setFlags(flags);
  694. if(mObjectID.isNull())
  695. {
  696. new_item->updateServer(FALSE);
  697. gInventory.updateItem(new_item);
  698. gInventory.notifyObservers();
  699. }
  700. else
  701. {
  702. LLViewerObject* object = gObjectList.findObject(mObjectID);
  703. if(object)
  704. {
  705. object->updateInventory(
  706. new_item,
  707. TASK_INVENTORY_ITEM_KEY,
  708. false);
  709. }
  710. }
  711. }
  712. else
  713. {
  714. // need to make sure we don't just follow the click
  715. refresh();
  716. }
  717. }
  718. // static
  719. void LLSidepanelItemInfo::onCommitSaleInfo()
  720. {
  721. //llinfos << "LLSidepanelItemInfo::onCommitSaleInfo()" << llendl;
  722. updateSaleInfo();
  723. }
  724. // static
  725. void LLSidepanelItemInfo::onCommitSaleType()
  726. {
  727. //llinfos << "LLSidepanelItemInfo::onCommitSaleType()" << llendl;
  728. updateSaleInfo();
  729. }
  730. void LLSidepanelItemInfo::updateSaleInfo()
  731. {
  732. LLViewerInventoryItem* item = findItem();
  733. if(!item) return;
  734. LLSaleInfo sale_info(item->getSaleInfo());
  735. if(!gAgent.allowOperation(PERM_TRANSFER, item->getPermissions(), GP_OBJECT_SET_SALE))
  736. {
  737. childSetValue("CheckPurchase",LLSD((BOOL)FALSE));
  738. }
  739. if((BOOL)childGetValue("CheckPurchase"))
  740. {
  741. // turn on sale info
  742. LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_COPY;
  743. LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("RadioSaleType");
  744. if(RadioSaleType)
  745. {
  746. switch (RadioSaleType->getSelectedIndex())
  747. {
  748. case 0:
  749. sale_type = LLSaleInfo::FS_ORIGINAL;
  750. break;
  751. case 1:
  752. sale_type = LLSaleInfo::FS_COPY;
  753. break;
  754. case 2:
  755. sale_type = LLSaleInfo::FS_CONTENTS;
  756. break;
  757. default:
  758. sale_type = LLSaleInfo::FS_COPY;
  759. break;
  760. }
  761. }
  762. if (sale_type == LLSaleInfo::FS_COPY 
  763. && !gAgent.allowOperation(PERM_COPY, item->getPermissions(), 
  764.   GP_OBJECT_SET_SALE))
  765. {
  766. sale_type = LLSaleInfo::FS_ORIGINAL;
  767. }
  768.      
  769. S32 price = -1;
  770. price =  getChild<LLUICtrl>("Edit Cost")->getValue().asInteger();;
  771. // Invalid data - turn off the sale
  772. if (price < 0)
  773. {
  774. sale_type = LLSaleInfo::FS_NOT;
  775. price = 0;
  776. }
  777. sale_info.setSaleType(sale_type);
  778. sale_info.setSalePrice(price);
  779. }
  780. else
  781. {
  782. sale_info.setSaleType(LLSaleInfo::FS_NOT);
  783. }
  784. if(sale_info != item->getSaleInfo()
  785. && item->isComplete())
  786. {
  787. LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
  788. // Force an update on the sale price at rez
  789. if (item->getType() == LLAssetType::AT_OBJECT)
  790. {
  791. U32 flags = new_item->getFlags();
  792. flags |= LLInventoryItem::II_FLAGS_OBJECT_SLAM_SALE;
  793. new_item->setFlags(flags);
  794. }
  795. new_item->setSaleInfo(sale_info);
  796. if(mObjectID.isNull())
  797. {
  798. // This is in the agent's inventory.
  799. new_item->updateServer(FALSE);
  800. gInventory.updateItem(new_item);
  801. gInventory.notifyObservers();
  802. }
  803. else
  804. {
  805. // This is in an object's contents.
  806. LLViewerObject* object = gObjectList.findObject(mObjectID);
  807. if(object)
  808. {
  809. object->updateInventory(
  810. new_item,
  811. TASK_INVENTORY_ITEM_KEY,
  812. false);
  813. }
  814. }
  815. }
  816. else
  817. {
  818. // need to make sure we don't just follow the click
  819. refresh();
  820. }
  821. }
  822. LLViewerInventoryItem* LLSidepanelItemInfo::findItem() const
  823. {
  824. LLViewerInventoryItem* item = NULL;
  825. if(mObjectID.isNull())
  826. {
  827. // it is in agent inventory
  828. item = gInventory.getItem(mItemID);
  829. }
  830. else
  831. {
  832. LLViewerObject* object = gObjectList.findObject(mObjectID);
  833. if(object)
  834. {
  835. item = static_cast<LLViewerInventoryItem*>(object->getInventoryObject(mItemID));
  836. }
  837. }
  838. return item;
  839. }
  840. // virtual
  841. void LLSidepanelItemInfo::save()
  842. {
  843. onCommitName();
  844. onCommitDescription();
  845. onCommitPermissions();
  846. onCommitSaleInfo();
  847. onCommitSaleType();
  848. }