main: preload recursive navigation only one layer at a time
This commit is contained in:
parent
a817e5fa21
commit
7e5d17100d
28
main.go
28
main.go
@ -319,6 +319,29 @@ func (f *TMainForm) OnNavExpanding(sender vcl.IObject, node *vcl.TTreeNode, allo
|
|||||||
}
|
}
|
||||||
|
|
||||||
*allowExpansion = node.HasChildren()
|
*allowExpansion = node.HasChildren()
|
||||||
|
|
||||||
|
// While we're here - preload one single level deep (not any deeper)
|
||||||
|
|
||||||
|
if node.HasChildren() {
|
||||||
|
|
||||||
|
// This node has children that we haven't processed. Process them now
|
||||||
|
cc := node.GetFirstChild()
|
||||||
|
|
||||||
|
for {
|
||||||
|
ndataChild := (*navData)(cc.Data())
|
||||||
|
if ndataChild.childrenLoaded {
|
||||||
|
break // We always do them together, so if one's done, no need to keep looking
|
||||||
|
}
|
||||||
|
|
||||||
|
f.NavLoadChildren(cc, ndataChild)
|
||||||
|
|
||||||
|
cc = cc.GetNextSibling()
|
||||||
|
if cc == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TMainForm) NavLoadChildren(node *vcl.TTreeNode, ndata *navData) error {
|
func (f *TMainForm) NavLoadChildren(node *vcl.TTreeNode, ndata *navData) error {
|
||||||
@ -345,7 +368,7 @@ func (f *TMainForm) NavLoadChildren(node *vcl.TTreeNode, ndata *navData) error {
|
|||||||
for _, bucketName := range nextBucketNames {
|
for _, bucketName := range nextBucketNames {
|
||||||
|
|
||||||
node := f.Buckets.Items().AddChild(node, formatUtf8([]byte(bucketName)))
|
node := f.Buckets.Items().AddChild(node, formatUtf8([]byte(bucketName)))
|
||||||
// node.SetHasChildren(true) // dynamically populate in OnNavExpanding
|
node.SetHasChildren(true) // dynamically populate in OnNavExpanding
|
||||||
node.SetImageIndex(imgTable)
|
node.SetImageIndex(imgTable)
|
||||||
node.SetSelectedIndex(imgTable)
|
node.SetSelectedIndex(imgTable)
|
||||||
navData := &navData{
|
navData := &navData{
|
||||||
@ -358,9 +381,6 @@ func (f *TMainForm) NavLoadChildren(node *vcl.TTreeNode, ndata *navData) error {
|
|||||||
node.SetData(unsafe.Pointer(navData))
|
node.SetData(unsafe.Pointer(navData))
|
||||||
|
|
||||||
ndata.ld.Keepalive(navData)
|
ndata.ld.Keepalive(navData)
|
||||||
|
|
||||||
// Recurse to see if it has any children of its own
|
|
||||||
f.NavLoadChildren(node, ndata)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user