Fix #8003 - undo code
[roobuilder] / src / JsRender / Node.vala
index 324f048..2db715f 100644 (file)
@@ -99,9 +99,9 @@ public class JsRender.Node : GLib.Object {
        private Gee.ArrayList<Node> items; // child items..
        public GLib.ListStore  childstore; // must be kept in sync with items
        public GLib.ListStore?  propstore; // must be kept in sync with items
-       public string  xvala_cls;
-       public string xvala_xcls; // 'Xcls_' + id;
-       public string xvala_id; // item id or ""
+       public string  xvala_cls; // set by node to vala
+       public string xvala_xcls; // 'Xcls_' + id; // set by nodetoVala
+       public string xvala_id; // item id or "" // set by nodetovala
        
        // line markers..
        public int line_start;
@@ -111,6 +111,9 @@ public class JsRender.Node : GLib.Object {
        public Gee.ArrayList<int> node_lines; 
        public Gee.HashMap<int,Node> node_lines_map; // store of l:xxx or p:....
        
+       
+       public string node_pad = "";
+       
        private int _updated_count = 0;
        public int updated_count { 
                get {
@@ -119,11 +122,25 @@ public class JsRender.Node : GLib.Object {
                set  {
                        this.nodeTitleProp = ""; // ?? should trigger set?
                        this.iconFilename = "";
-                       this. _updated_count = value;
+                       this._updated_count = value;
+                               
+                       //GLib.debug("Update Node %d p%d - rev %d", this.oid, this.parent != null ? this.parent.oid : -1, value);
+                       if (this.parent != null) {
+                               this.parent.updated_count++;
+                       }  else {
+                               //GLib.debug("UNDO top node is %d", value);
+                               this.version_changed();
+                       }
                }
  
        } // changes to this trigger updates on the tree..
-
+       
+       public string as_source = "";
+       public int as_source_version = -1;
+       
+       public signal void  version_changed();
+       
        public Node()
        {
                this.items = new Gee.ArrayList<Node>();
@@ -145,6 +162,20 @@ public class JsRender.Node : GLib.Object {
                
        }
        
+       public bool has_parent(Node n) 
+       {
+               if (this.parent == null) {
+                       return false;
+               }
+               if (this.parent.oid == n.oid) {
+                       return true;
+               }
+               
+
+               return this.parent.has_parent(n);
+       }
+       
+       
        public  Gee.ArrayList<Node> readItems()
        {
                return this.items; // note should not modify add/remove from this directly..
@@ -206,6 +237,7 @@ public class JsRender.Node : GLib.Object {
                
                
                
+               
                //GLib.debug("setLine %d, %s", line, type + ":" + prop);
        }
        public void sortLines() {
@@ -342,7 +374,10 @@ public class JsRender.Node : GLib.Object {
                owned get { return this.fqn(); }
                private set  {}
        }
-       
+       public string NS { // for sorting
+               owned get { return this.props.has_key("xns") ? this.props.get("xns").val  : ""; }
+               private set  {}
+       }
        public string fqn()
        {
                if (!this.hasXnsType ()) {
@@ -418,7 +453,7 @@ public class JsRender.Node : GLib.Object {
                if ( this.parent.childstore.find(this, out pos)) {
                        this.parent.childstore.remove(pos);
                } 
-               
+               this.parent.updated_count++;
                this.parent.items = nlist;
                this.parent = null;