本文整理汇总了C++中LLViewerInventoryCategory::rename方法的典型用法代码示例。如果您正苦于以下问题:C++ LLViewerInventoryCategory::rename方法的具体用法?C++ LLViewerInventoryCategory::rename怎么用?C++ LLViewerInventoryCategory::rename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLViewerInventoryCategory
的用法示例。
在下文中一共展示了LLViewerInventoryCategory::rename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadInvCache
//static
void LLLocalInventory::loadInvCache(std::string filename)
{
std::string extension = gDirUtilp->getExtension(filename);
std::string inv_filename = filename;
if(extension == "gz")
{
LLUUID random;
random.generate();
inv_filename = filename.substr(0, filename.length() - 3) + "." + random.asString();
if(!gunzip_file(filename, inv_filename))
{
// failure... message?
return;
}
}
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
bool is_cache_obsolete = false;
if(LLInventoryModel::loadFromFile(inv_filename, cats, items, is_cache_obsolete))
{
// create a container category for everything
LLViewerInventoryCategory* container = new LLViewerInventoryCategory(gAgent.getID());
container->rename(gDirUtilp->getBaseFileName(filename, false));
LLUUID container_id;
container_id.generate();
container->setUUID(container_id);
container->setParent(gSystemFolderRoot);
container->setPreferredType(LLFolderType::FT_NONE);
LLInventoryModel::update_map_t container_update;
++container_update[container->getParentUUID()];
gInventory.accountForUpdate(container_update);
gInventory.updateCategory(container);
gInventory.notifyObservers();
LLViewerInventoryCategory* orphaned_items = new LLViewerInventoryCategory(gAgent.getID());
orphaned_items->rename("Orphaned Items");
LLUUID orphaned_items_id;
orphaned_items_id.generate();
orphaned_items->setUUID(orphaned_items_id);
orphaned_items->setParent(container_id);
orphaned_items->setPreferredType(LLFolderType::FT_NONE);
LLInventoryModel::update_map_t orphaned_items_update;
++orphaned_items_update[orphaned_items->getParentUUID()];
gInventory.accountForUpdate(orphaned_items_update);
gInventory.updateCategory(orphaned_items);
gInventory.notifyObservers();
//conflict handling
std::map<LLUUID,LLUUID> conflicting_cats;
int dropped_cats = 0;
int dropped_items = 0;
// Add all categories
LLInventoryModel::cat_array_t::iterator cat_iter = cats.begin();
LLInventoryModel::cat_array_t::iterator cat_end = cats.end();
for(; cat_iter != cat_end; ++cat_iter)
{
// Conditionally change its parent
// Note: Should I search for missing parent id's?
//if the parent is null, it goes in the very root of the tree!
if((*cat_iter)->getParentUUID().isNull())
{
(*cat_iter)->setParent(container_id);
}
// If the parent exists and outside of pretend inventory, generate a new uuid
else if(gInventory.getCategory((*cat_iter)->getParentUUID()))
{
if(!gInventory.isObjectDescendentOf((*cat_iter)->getParentUUID(), gSystemFolderRoot, TRUE))
{
std::map<LLUUID,LLUUID>::iterator itr = conflicting_cats.find((*cat_iter)->getParentUUID());
if(itr == conflicting_cats.end())
{
dropped_cats++;
continue;
}
(*cat_iter)->setParent(itr->second);
}
} else {
//well balls, this is orphaned.
(*cat_iter)->setParent(orphaned_items_id);
}
// If this category already exists, generate a new uuid
if(gInventory.getCategory((*cat_iter)->getUUID()))
{
LLUUID cat_random;
cat_random.generate();
conflicting_cats[(*cat_iter)->getUUID()] = cat_random;
(*cat_iter)->setUUID(cat_random);
}
LLInventoryModel::update_map_t update;
++update[(*cat_iter)->getParentUUID()];
gInventory.accountForUpdate(update);
gInventory.updateCategory(*cat_iter);
//.........这里部分代码省略.........
示例2: doneIdle
// Checked: 2010-03-14 (RLVa-1.1.3a) | Added: RLVa-1.2.0a
void RlvRenameOnWearObserver::doneIdle()
{
const LLViewerInventoryCategory* pRlvRoot = NULL; LLVOAvatar* pAvatar = gAgentAvatarp;
if ( (RlvSettings::getEnableSharedWear()) || (!RlvSettings::getSharedInvAutoRename()) || (LLStartUp::getStartupState() < STATE_STARTED) ||
(!pAvatar) || ((pRlvRoot = RlvInventory::instance().getSharedRoot()) == NULL) )
{
delete this;
return;
}
const LLViewerJointAttachment* pAttachPt = NULL; S32 idxAttachPt = 0;
// RLV_ASSERT(mComplete.size() > 0); // Catch instances where we forgot to call startFetch()
for (uuid_vec_t::const_iterator itItem = mComplete.begin(); itItem != mComplete.end(); ++itItem)
{
const LLUUID& idAttachItem = *itItem;
// If the item resides under #RLV we'll rename it directly; otherwise settle for "renaming" all of its links residing under #RLV
LLInventoryModel::item_array_t items;
if (gInventory.isObjectDescendentOf(idAttachItem, pRlvRoot->getUUID()))
items.push_back(gInventory.getItem(idAttachItem));
else
items = gInventory.collectLinkedItems(idAttachItem, pRlvRoot->getUUID());
if (items.empty())
continue;
if ( ((pAttachPt = pAvatar->getWornAttachmentPoint(idAttachItem)) == NULL) ||
((idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachPt)) == 0) )
{
// RLV_ASSERT(false);
continue;
}
static const std::string &new_category_name = LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_NONE);
for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++)
{
LLViewerInventoryItem* pItem = items.get(idxItem);
if (!pItem)
continue;
S32 idxAttachPtItem = RlvAttachPtLookup::getAttachPointIndex(pItem);
if ( (idxAttachPt == idxAttachPtItem) || (idxAttachPtItem) )
continue;
std::string strAttachPt = pAttachPt->getName();
LLStringUtil::toLower(strAttachPt);
// If we can modify the item then we rename it directly, otherwise we create a new folder and move it
if (pItem->getPermissions().allowModifyBy(gAgent.getID()))
{
std::string strName = pItem->getName();
LLStringUtil::truncate(strName, DB_INV_ITEM_NAME_STR_LEN - strAttachPt.length() - 3);
strName += " (" + strAttachPt + ")";
pItem->rename(strName);
pItem->updateServer(FALSE);
gInventory.addChangedMask(LLInventoryObserver::LABEL, pItem->getUUID());
}
else
{
// Don't do anything if the item is a direct descendant of the shared root, or a folded folder
LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID());
if ( (pFolder) && (pFolder->getUUID() != pRlvRoot->getUUID()) && (!RlvInventory::isFoldedFolder(pFolder, false)) )
{
std::string strFolderName = ".(" + strAttachPt + ")";
// Rename the item's parent folder if it's called "New Folder", isn't directly under #RLV and contains exactly 1 object
if ( (new_category_name == pFolder->getName()) &&
(pFolder->getParentUUID() != pRlvRoot->getUUID()) &&
(1 == RlvInventory::getDirectDescendentsCount(pFolder, LLAssetType::AT_OBJECT)) )
{
pFolder->rename(strFolderName);
pFolder->updateServer(FALSE);
gInventory.addChangedMask(LLInventoryObserver::LABEL, pFolder->getUUID());
}
else
{
// "No modify" item with a non-renameable parent: create a new folder named and move the item into it
LLUUID idAttachFolder = gInventory.createNewCategory(pFolder->getUUID(), LLFolderType::FT_NONE, strFolderName);
move_inventory_item(gAgent.getID(), gAgent.getSessionID(), pItem->getUUID(), idAttachFolder, std::string(), NULL);
}
}
}
}
}
gInventory.notifyObservers();
delete this;
}