gui: implement nav refresh

This commit is contained in:
mappu 2024-06-28 12:04:39 +12:00
parent ef70e5825a
commit e2111017eb

23
main.go
View File

@ -303,7 +303,6 @@ func (f *TMainForm) OnMnuFileBadgerOpenClick(sender vcl.IObject) {
func (f *TMainForm) OnMnuFileBadgerMemoryClick(sender vcl.IObject) { func (f *TMainForm) OnMnuFileBadgerMemoryClick(sender vcl.IObject) {
f.badgerAddDatabaseFromMemory() f.badgerAddDatabaseFromMemory()
} }
func (f *TMainForm) OnMnuFilePebbleOpenClick(sender vcl.IObject) { func (f *TMainForm) OnMnuFilePebbleOpenClick(sender vcl.IObject) {
@ -386,17 +385,18 @@ func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint,
return return
} }
ndata := (*navData)(curItem.Data())
mnu := vcl.NewPopupMenu(f.Buckets) mnu := vcl.NewPopupMenu(f.Buckets)
mnu.SetImages(f.ImageList) mnu.SetImages(f.ImageList)
mnuRefresh := vcl.NewMenuItem(mnu) mnuRefresh := vcl.NewMenuItem(mnu)
mnuRefresh.SetCaption("Refresh") mnuRefresh.SetCaption("Refresh")
mnuRefresh.SetImageIndex(imgArrowRefresh) mnuRefresh.SetImageIndex(imgArrowRefresh)
mnuRefresh.SetOnClick(f.OnNavContextRefresh) mnuRefresh.SetOnClick(func(sender vcl.IObject) { f.OnNavContextRefresh(curItem, ndata) })
mnu.Items().Add(mnuRefresh) mnu.Items().Add(mnuRefresh)
// Check what custom actions the ndata->db itself wants to add // Check what custom actions the ndata->db itself wants to add
ndata := (*navData)(curItem.Data())
actions, err := ndata.ld.NavContext(ndata) actions, err := ndata.ld.NavContext(ndata)
if err != nil { if err != nil {
vcl.ShowMessage(err.Error()) vcl.ShowMessage(err.Error())
@ -434,9 +434,20 @@ func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint,
mnu.Popup2() mnu.Popup2()
} }
func (f *TMainForm) OnNavContextRefresh(sender vcl.IObject) { func (f *TMainForm) OnNavContextRefresh(item *vcl.TTreeNode, ndata *navData) {
vcl.ShowMessage("TODO") isExpanded := item.Expanded()
// TODO
// 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) { func (f *TMainForm) OnNavContextClose(sender vcl.IObject) {