Duplicate duplicates the sync node corresponding to this view node in the tree, and inserts the duplicate after this node (as a new sibling). If SyncNode is set, operates on Sync Tree.
()
| 295 | // the tree, and inserts the duplicate after this node (as a new sibling). |
| 296 | // If SyncNode is set, operates on Sync Tree. |
| 297 | func (tr *Tree) Duplicate() { //types:add |
| 298 | ttl := "Duplicate" |
| 299 | if tr.IsRoot(ttl) { |
| 300 | return |
| 301 | } |
| 302 | if tr.Parent == nil { |
| 303 | return |
| 304 | } |
| 305 | if tr.SyncNode != nil { |
| 306 | tr.duplicateSync() |
| 307 | return |
| 308 | } |
| 309 | parent := AsTree(tr.Parent) |
| 310 | myidx := tr.IndexInParent() |
| 311 | if myidx < 0 { |
| 312 | return |
| 313 | } |
| 314 | nm := fmt.Sprintf("%v_Copy", tr.Name) |
| 315 | tr.Unselect() |
| 316 | nwkid := tr.Clone() |
| 317 | nwkid.AsTree().SetName(nm) |
| 318 | ntv := AsTree(nwkid) |
| 319 | parent.InsertChild(nwkid, myidx+1) |
| 320 | ntv.Update() |
| 321 | parent.Update() |
| 322 | parent.treeChanged(nil) |
| 323 | // ntv.SelectEvent(events.SelectOne) |
| 324 | } |
| 325 | |
| 326 | func (tr *Tree) duplicateSync() { |
| 327 | sn := tr.SyncNode |
no test coverage detected