本文整理汇总了C++中ObjList::DescendForUndo方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjList::DescendForUndo方法的具体用法?C++ ObjList::DescendForUndo怎么用?C++ ObjList::DescendForUndo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjList
的用法示例。
在下文中一共展示了ObjList::DescendForUndo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintTree
void UndoEngine::PrintTree(HeeksObj *tree, std::stringstream &cstr,int level)
{
tab(cstr,level);
cstr << "ID: " << tree->m_id << endl;
tab(cstr,level);
cstr << "Type: " << wxString(tree->GetTypeString()).mb_str() << endl;
tab(cstr,level);
cstr << "Location: " << tree << endl;
if(tree->IsList())
{
ObjList* list = (ObjList*)tree;
if(list->DescendForUndo())
{
HeeksObj* child = list->GetFirstChild();
while(child)
{
PrintTree(child,cstr,level+1);
child = list->GetNextChild();
}
}
}
}
示例2: GetModificationsRecursive
void UndoEngine::GetModificationsRecursive(std::vector<UndoEvent> &ret,ObjList* newtree, ObjList* oldtree)
{
std::set<HeeksObjId> new_children;
std::set<HeeksObjId> old_children;
std::map<HeeksObjId,HeeksObj*> new_children_map;
std::map<HeeksObjId,HeeksObj*> old_children_map;
HeeksObj *new_obj = newtree->GetFirstChild();
while(new_obj)
{
HeeksObjId id = GetHeeksObjId(new_obj);
new_children.insert(id);
new_children_map[id] = new_obj;
new_obj = newtree->GetNextChild();
}
HeeksObj *old_obj = oldtree->GetFirstChild();
while(old_obj)
{
HeeksObjId id = GetHeeksObjId(old_obj);
old_children.insert(id);
old_children_map[id] = old_obj;
old_obj = oldtree->GetNextChild();
}
std::set<HeeksObjId>::iterator it;
for(it = new_children.begin(); it != new_children.end(); it++)
{
HeeksObj* obj = new_children_map[*it];
m_tree.m_treemap[*it] = obj;
if(old_children.find(*it) == old_children.end())
{
//TODO, this is actually tricky, when an item is added, it may be added in multiple places in the tree
//we must make sure that multiple pointers get setup to this object, we also must deep copy
HeeksObj* copy = obj->MakeACopyWithID();
ret.push_back(UndoEvent(EventTypeAdd,newtree,copy));
m_oldtree.m_treemap[*it] = copy;
}
else
{
//TODO: check if item is modified, if it is an objlist, descend
if(!obj->GetSkipForUndo() && obj->IsDifferent(old_children_map[*it]))
{
HeeksObj* copy = obj->MakeACopyWithID();
ret.push_back(UndoEvent(EventTypeModified,newtree,copy,old_children_map[*it]));
m_oldtree.m_treemap[*it] = copy;
}
else
{
if(obj->IsList())
{
ObjList* newlist = (ObjList*)obj;
ObjList* oldlist = (ObjList*)old_children_map[*it];
if(newlist->DescendForUndo())
{
GetModificationsRecursive(ret,newlist,oldlist);
}
}
}
}
}
for(it = old_children.begin(); it != old_children.end(); it++)
{
HeeksObj* obj = old_children_map[*it];
if(new_children.find(*it) == new_children.end())
ret.push_back(UndoEvent(EventTypeRemove,newtree,obj->MakeACopyWithID()));
m_oldtree.m_treemap[*it] = obj;
}
//DealWithTransients();
wxGetApp().ClearTransients();
}