MCPcopy Create free account
hub / github.com/cogentcore/core / Duplicate

Method Duplicate

core/treesync.go:297–324  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

295// the tree, and inserts the duplicate after this node (as a new sibling).
296// If SyncNode is set, operates on Sync Tree.
297func (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
326func (tr *Tree) duplicateSync() {
327 sn := tr.SyncNode

Callers 3

InitMethod · 0.95
duplicateFileMethod · 0.45
makeFilesRowMethod · 0.45

Calls 11

IsRootMethod · 0.95
duplicateSyncMethod · 0.95
UnselectMethod · 0.95
AsTreeFunction · 0.85
IndexInParentMethod · 0.80
InsertChildMethod · 0.80
treeChangedMethod · 0.80
CloneMethod · 0.65
SetNameMethod · 0.65
AsTreeMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected