diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index be945c081..044d24280 100644 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -59,6 +59,10 @@ #include "lluictrlfactory.h" +// +#include "llclipboard.h" +// + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLPropertiesObserver @@ -156,6 +160,9 @@ LLFloaterProperties::LLFloaterProperties(const std::string& name, const LLRect& mItemID(item_id), mObjectID(object_id), mDirty(TRUE) + // + , mExpanded(FALSE) + // { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_inventory_item_properties.xml"); @@ -194,6 +201,13 @@ LLFloaterProperties::LLFloaterProperties(const std::string& name, const LLRect& childSetCommitCallback("RadioSaleType",&onCommitSaleType, this); // "Price" label for edit childSetCommitCallback("EditPrice",&onCommitSaleInfo, this); + // + childSetAction("more_btn", &onClickMore, this); + childSetAction("less_btn", &onClickLess, this); + childSetAction("copy_btn", &onClickCopy, this); + childSetAction("update_btn", &onClickUpdate, this); + setExpanded(mExpanded); + // // The UI has been built, now fill in all the values refresh(); } @@ -280,6 +294,28 @@ void LLFloaterProperties::draw() void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) { + // + childSetText("EditItemID", item->getUUID().asString()); + childSetText("EditFolderID", item->getParentUUID().asString()); + childSetText("EditGroup", item->getPermissions().getGroup().asString()); + childSetText("EditAssetID", item->getAssetUUID().asString()); + + std::string type_str = LLAssetType::lookup(item->getType()); + if(type_str.c_str() == NULL) type_str = llformat("%d", item->getType()); + childSetText("EditType", type_str); + + std::string invtype_str = LLInventoryType::lookup(item->getInventoryType()); + if(invtype_str.c_str() == NULL) invtype_str = llformat("%d", item->getInventoryType()); + childSetText("EditInvType", invtype_str); + childSetText("EditFlags", llformat("%d", item->getFlags())); + + std::ostringstream strm; + item->exportLegacyStream(strm, TRUE); + std::string str(strm.str()); + LLStringUtil::replaceTabsWithSpaces(str, 4); + childSetText("item_text", str); + // + //////////////////////// // PERMISSIONS LOOKUP // //////////////////////// @@ -944,14 +980,163 @@ void LLFloaterProperties::closeByID(const LLUUID& item_id, const LLUUID &object_ } } +// +void LLFloaterProperties::onClickMore(void* user_data) +{ + LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data; + if(floaterp) + { + LLMultiProperties* host = (LLMultiProperties*)floaterp->getHost(); + if(host) + host->setExpanded(TRUE); + else + floaterp->setExpanded(TRUE); + } +} + +void LLFloaterProperties::onClickLess(void* user_data) +{ + LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data; + if(floaterp) + { + LLMultiProperties* host = (LLMultiProperties*)floaterp->getHost(); + if(host) + host->setExpanded(FALSE); + else + floaterp->setExpanded(FALSE); + } +} + +void LLFloaterProperties::setExpanded(BOOL expanded) +{ + mExpanded = expanded; + LLRect rect = getRect(); + if(expanded) + rect.setOriginAndSize(rect.mLeft, rect.mBottom, 800, rect.getHeight()); + else + rect.setOriginAndSize(rect.mLeft, rect.mBottom, 350, rect.getHeight()); + setRect(rect); + childSetVisible("more_btn", !mExpanded); + childSetVisible("less_btn", mExpanded); + childSetVisible("item_text", mExpanded); + childSetVisible("copy_btn", mExpanded); + childSetVisible("update_btn", mExpanded); + if(getHost()) + setCanTearOff(!expanded); // idk why it comes out ugly if expanded +} + +// static +void LLFloaterProperties::onClickCopy(void* user_data) +{ + LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data; + if(floaterp) + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)floaterp->findItem(); + if(item) + { + std::string str(floaterp->childGetValue("item_text").asString()); + std::string::size_type pos; + while((pos = str.find(" ")) != std::string::npos) + { + str.replace(pos, 4, "\t"); + } + + std::istringstream strm(str); + LLViewerInventoryItem* temp = new LLViewerInventoryItem(); + temp->importLegacyStream(strm); + std::ostringstream strm2; + temp->exportLegacyStream(strm2, TRUE); + LLWString wstr(utf8str_to_wstring(strm2.str())); + + gClipboard.copyFromSubstring(wstr, 0, wstr.length()); + + //delete temp; + } + } +} + +// static +void LLFloaterProperties::onClickUpdate(void* user_data) +{ + LLFloaterProperties* floaterp = (LLFloaterProperties*)user_data; + if(floaterp) + { + LLViewerInventoryItem* item = (LLViewerInventoryItem*)floaterp->findItem(); + if(item) + { + std::string str(floaterp->childGetValue("item_text").asString()); + std::string::size_type pos; + while((pos = str.find(" ")) != std::string::npos) + { + str.replace(pos, 4, "\t"); + } + + std::istringstream strm(str); + item->importLegacyStream(strm); + + if(floaterp->mObjectID.isNull()) + { + // This is in the agent's inventory. + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + + item->setComplete(FALSE); + item->fetchFromServer(); + } + else + { + // This is in an object's contents. + LLViewerObject* object = gObjectList.findObject(floaterp->mObjectID); + if(object) + { + object->updateInventory( + item, + TASK_INVENTORY_ITEM_KEY, + false); + object->fetchInventoryFromServer(); + } + } + } + } +} +// + ///---------------------------------------------------------------------------- /// LLMultiProperties ///---------------------------------------------------------------------------- LLMultiProperties::LLMultiProperties(const LLRect &rect) : LLMultiFloater(std::string("Properties"), rect) +// +, mExpanded(FALSE) +// { } +void LLMultiProperties::setExpanded(BOOL expanded) +{ + mExpanded = expanded; + LLRect rect = getRect(); + LLRect tab_rect = mTabContainer->getRect(); + if(expanded) + { + rect.setOriginAndSize(rect.mLeft, rect.mBottom, 800, rect.getHeight()); + tab_rect.setOriginAndSize(tab_rect.mLeft, tab_rect.mBottom, 800, tab_rect.getHeight()); + } + else + { + rect.setOriginAndSize(rect.mLeft, rect.mBottom, 350, rect.getHeight()); + tab_rect.setOriginAndSize(tab_rect.mLeft, tab_rect.mBottom, 350, tab_rect.getHeight()); + } + setRect(rect); + mTabContainer->setRect(tab_rect); + for (S32 i = 0; i < mTabContainer->getTabCount(); i++) + { + LLFloaterProperties* floaterp = (LLFloaterProperties*)mTabContainer->getPanelByIndex(i); + floaterp->setExpanded(expanded); + } +} + ///---------------------------------------------------------------------------- /// Local function definitions ///---------------------------------------------------------------------------- diff --git a/indra/newview/llfloaterproperties.h b/indra/newview/llfloaterproperties.h index 2f5d97d38..f14692a37 100644 --- a/indra/newview/llfloaterproperties.h +++ b/indra/newview/llfloaterproperties.h @@ -61,6 +61,14 @@ public: static void closeByID(const LLUUID& item_id, const LLUUID& object_id); + // + static void onClickMore(void* user_data); + static void onClickLess(void* user_data); + static void onClickCopy(void* user_data); + static void onClickUpdate(void* user_data); + void setExpanded(BOOL expanded); + // + LLFloaterProperties(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_id, const LLUUID& object_id); virtual ~LLFloaterProperties(); @@ -94,6 +102,9 @@ protected: LLUUID mObjectID; BOOL mDirty; + // + BOOL mExpanded; + // typedef std::map instance_map; static instance_map sInstances; @@ -105,6 +116,11 @@ class LLMultiProperties : public LLMultiFloater { public: LLMultiProperties(const LLRect& rect); + // + void setExpanded(BOOL expanded); +protected: + BOOL mExpanded; + // }; #endif // LL_LLFLOATERPROPERTIES_H diff --git a/indra/newview/skins/default/xui/en-us/floater_inventory_item_properties.xml b/indra/newview/skins/default/xui/en-us/floater_inventory_item_properties.xml index ce0679c31..fb4fc65e0 100644 --- a/indra/newview/skins/default/xui/en-us/floater_inventory_item_properties.xml +++ b/indra/newview/skins/default/xui/en-us/floater_inventory_item_properties.xml @@ -1,6 +1,6 @@ + + + ItemID: + + + + FolderID: + + + + Group: + + + + AssetID: + + + + Type: + + + + InvType: + + + + Flags: + + +