Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions gui/wxpython/datacatalog/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ def __init__(
)
self.startEdit.connect(self.OnStartEditLabel)
self.endEdit.connect(self.OnEditLabel)

self._hoveredDb = False
self.Bind(wx.EVT_MOTION, self.OnMotion)

self.EnableWatchingMapset()

def _resetSelectVariables(self):
Expand Down Expand Up @@ -1306,6 +1310,30 @@ def OnGetItemFont(self, index):
font.SetWeight(wx.FONTWEIGHT_NORMAL)
return font

def OnMotion(self, event):
"""Show full path of a database the mouse points at in a tooltip.

Long paths are shortened and a database can have a user defined label,
so the full path is often not visible in the tree itself. The tooltip
is set through CallAfter because the tree control overwrites it with
the item label while handling the same event, which is what shows up
when the label does not fit in the window.
"""
path = None
item = self.HitTest(event.GetPosition())[0]
# Databases are the top level items. Checking the parent first avoids
# looking up the node for every map the mouse passes over.
if item and self.GetItemParent(item) == self.GetRootItem():
node = self._model.GetNodeByIndex(self.GetIndexOfItem(item))
if node.data["type"] == "grassdb":
path = node.data["name"]
if path:
wx.CallAfter(self.SetToolTip, path)
elif self._hoveredDb:
wx.CallAfter(self.UnsetToolTip)
self._hoveredDb = bool(path)
event.Skip()

def ExpandCurrentMapset(self, recursive=False):
Comment thread
saket0187 marked this conversation as resolved.
"""Expand current mapset

Expand Down
Loading