本文整理汇总了C++中ItemPtr::addChildItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr::addChildItem方法的具体用法?C++ ItemPtr::addChildItem怎么用?C++ ItemPtr::addChildItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemPtr
的用法示例。
在下文中一共展示了ItemPtr::addChildItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copySelectedItemsSub
void ItemTreeViewImpl::copySelectedItemsSub(Item* item, ItemPtr& duplicated, set<Item*>& items)
{
for(Item* childItem = item->childItem(); childItem; childItem = childItem->nextItem()){
set<Item*>::iterator p = items.find(childItem);
if(p != items.end()){
ItemPtr duplicatedChild;
if(childItem->isSubItem()){
duplicatedChild = duplicated->findItem(childItem->name());
} else {
duplicatedChild = childItem->duplicate();
if(duplicatedChild){
duplicated->addChildItem(duplicatedChild);
}
}
if(duplicatedChild){
copySelectedItemsSub(childItem, duplicatedChild, items);
}
}
}
}
示例2: pasteItems
void ItemTreeViewImpl::pasteItems()
{
if(!copiedItemList.empty()){
ItemPtr parentItem;
if(selectedItemList.empty()){
parentItem = rootItem;
} else if(selectedItemList.size() == 1){
parentItem = selectedItemList.front();
}
if(parentItem){
for(size_t i=0; i < copiedItemList.size(); ++i){
ItemPtr org = copiedItemList[i];
ItemPtr duplicated = org->duplicateAll();
if(duplicated){
copiedItemList[i] = duplicated;
}
parentItem->addChildItem(org, true); // paste the original items
}
}
}
}
示例3: restoreItemIter
bool ItemTreeArchiver::restoreItemIter(Archive* archive, ItemPtr& parentItem)
{
ItemPtr item;
string pluginName;
string className;
if(!(archive->read("plugin", pluginName) && archive->read("class", className))) {
messageView->putln(_("Archive is broken."));
return false;
}
const char* actualPluginName = PluginManager::instance()->guessActualPluginName(pluginName);
if(actualPluginName) {
item = ItemManager::create(actualPluginName, className);
}
if(!item) {
messageView->putln(
format(_("Item type %1% of %2% cannot be restored. It's not a registered type."))
% className % pluginName);
} else {
bool restored = false;
string name;
if(archive->read("name", name)) {
item->setName(name);
bool isRootItem = dynamic_pointer_cast<RootItem>(item);
if(isRootItem) {
item = parentItem;
restored = true;
} else {
messageView->putln(format(_("Restoring %1% \"%2%\"")) % className % name);
messageView->flush();
YamlNodePtr dataNode = archive->find("data");
if(!dataNode->isValid()) {
restored = true;
} else if(dataNode->type() == YAML_MAPPING) {
Archive* dataArchive = static_cast<Archive*>(dataNode->toMapping());
dataArchive->inheritSharedInfoFrom(archive);
dataArchive->setCurrentParentItem(parentItem.get());
restored = item->restore(*dataArchive);
}
if(restored) {
parentItem->addChildItem(item);
}
}
if(!restored) {
messageView->putln(format(_("%1% \"%2%\" cannot be restored.")) % className % name);
item = 0;
} else {
int id;
if(archive->read("id", id) && (id >= 0)) {
archive->registerItemId(item.get(), id);
}
YamlSequencePtr children = archive->findSequence("children");
if(children->isValid()) {
for(int i=0; i < children->size(); ++i) {
Archive* childArchive = dynamic_cast<Archive*>(children->get(i).toMapping());
childArchive->inheritSharedInfoFrom(archive);
restoreItemIter(childArchive, item);
}
}
}
}
}
return (item);
}