gui: implement nav refresh
This commit is contained in:
parent
ef70e5825a
commit
e2111017eb
23
main.go
23
main.go
@ -303,7 +303,6 @@ func (f *TMainForm) OnMnuFileBadgerOpenClick(sender vcl.IObject) {
|
||||
|
||||
func (f *TMainForm) OnMnuFileBadgerMemoryClick(sender vcl.IObject) {
|
||||
f.badgerAddDatabaseFromMemory()
|
||||
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnMnuFilePebbleOpenClick(sender vcl.IObject) {
|
||||
@ -386,17 +385,18 @@ func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint,
|
||||
return
|
||||
}
|
||||
|
||||
ndata := (*navData)(curItem.Data())
|
||||
|
||||
mnu := vcl.NewPopupMenu(f.Buckets)
|
||||
mnu.SetImages(f.ImageList)
|
||||
|
||||
mnuRefresh := vcl.NewMenuItem(mnu)
|
||||
mnuRefresh.SetCaption("Refresh")
|
||||
mnuRefresh.SetImageIndex(imgArrowRefresh)
|
||||
mnuRefresh.SetOnClick(f.OnNavContextRefresh)
|
||||
mnuRefresh.SetOnClick(func(sender vcl.IObject) { f.OnNavContextRefresh(curItem, ndata) })
|
||||
mnu.Items().Add(mnuRefresh)
|
||||
|
||||
// Check what custom actions the ndata->db itself wants to add
|
||||
ndata := (*navData)(curItem.Data())
|
||||
actions, err := ndata.ld.NavContext(ndata)
|
||||
if err != nil {
|
||||
vcl.ShowMessage(err.Error())
|
||||
@ -434,9 +434,20 @@ func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint,
|
||||
mnu.Popup2()
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnNavContextRefresh(sender vcl.IObject) {
|
||||
vcl.ShowMessage("TODO")
|
||||
// TODO
|
||||
func (f *TMainForm) OnNavContextRefresh(item *vcl.TTreeNode, ndata *navData) {
|
||||
isExpanded := item.Expanded()
|
||||
|
||||
// Reset nav node to 'unloaded' state
|
||||
item.Collapse(true)
|
||||
item.DeleteChildren()
|
||||
item.SetHasChildren(true)
|
||||
ndata.childrenLoaded = false
|
||||
|
||||
// Trigger a virtual reload
|
||||
item.Expand(false) // Calls OnNavExpanding to dynamically detect children
|
||||
|
||||
// Restore previous gui state
|
||||
item.SetExpanded(isExpanded)
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnNavContextClose(sender vcl.IObject) {
|
||||
|
Loading…
Reference in New Issue
Block a user