On Thursday, May 7, 2020 at 8:55:31 PM UTC+2, Thomas Passin wrote:
>
> Do you think it would be feasible to simply copy the root of the tree to 
> be operated on?   Then the undo would entail pointing the tree's original 
> parent to the copy and then redrawing.  I don't know about copy performance 
> (I suppose that a deep copy would be needed) on Leo nodes, but as a naive 
> idea it seems simple.
>
>
QTreeWidgetItem class has a clone method which runs quite fast. Cloning 
entire tree using this method is not problem at all. The problem is that if 
a script changes vnodes we need to synchronize them after script has 
finished. This synchronization can drop some items that are required for 
undoing earlier operations. To avoid this Leo should add to the undo list a 
new step which contains the copy of the tree items before executing script. 
All these operations are pretty cheap. The time will be spent in the 
redrawing tree from scratch after the script execution.

As I write this I've just realize that it would be possible to use diffing 
algorithm to update tree after the script. The only thing that is necessary 
is to make execute script undoable. Updating the tree using the diff 
algorithm will have exactly the same tree items as they were before the 
script. Nothing would be lost. All changes that must be made can be easily 
recorded in the undo bead for later undo/redo. This has a chance to make 
things a lot faster.

Vitalije

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/55ae6e96-1e5a-4863-8d1f-48aea3c63dc3%40googlegroups.com.

Reply via email to