Skip to content

Commit

Permalink
Show function values as tooltip when holding Ctrl
Browse files Browse the repository at this point in the history
gui/pipeline_view.py:
 - QGraphicsModuleItem.__init__:
   call setAcceptHoverEvents
   New attribute function_overview
 - QGraphicsModuleItem.updateFunctionPorts:
   Create a html tooltip showing function values
 - QGraphicsModuleItem.hoverEnterEvent: *new
   Show function_overview as tooltip
   Note that this overwrites errorTrace tooltips
  • Loading branch information
rexissimus committed Oct 1, 2014
1 parent 756f8e1 commit 0171f96
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions vistrails/gui/pipeline_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ def __init__(self, parent=None, scene=None):
else:
self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable |
QtGui.QGraphicsItem.ItemIsMovable)
self.setAcceptHoverEvents(True)
self.setZValue(0)
self.labelFont = CurrentTheme.MODULE_FONT
self.labelFontMetric = CurrentTheme.MODULE_FONT_METRIC
Expand Down Expand Up @@ -1069,6 +1070,7 @@ def __init__(self, parent=None, scene=None):
self.progressBrush = CurrentTheme.SUCCESS_MODULE_BRUSH
self.connectionItems = {}
self._cur_function_names = set()
self.function_overview = 'No functions set'
self.handlePositionChanges = True

def moduleHasChanged(self, core_module):
Expand Down Expand Up @@ -1165,6 +1167,24 @@ def update_function_ports(self, core_module=None):
if item is not None:
item.connect()

if core_module.functions:
function_overview = []
for f in core_module.functions:
if len(f.params)>1:
params = ', '.join([p.strValue for p in f.params])
elif len(f.params)>0:
params = f.params[0].strValue
else:
params = ''
if len(params)>100:
params = params[:97] + '...'
function_template = "<b>%s(</b>%s<b>)</b>"
function_overview.append(function_template % (f.name, params))
template = '<html>%s</html>'
self.function_overview = template % '<br/>'.join(function_overview)
else:
self.function_overview = 'No functions set'

self.module = core_module

def setProgress(self, progress):
Expand Down Expand Up @@ -1762,6 +1782,13 @@ def mouseReleaseEvent(self, event):
if not self.controller.changed and self.controller.has_move_actions():
self.controller.set_changed(True)

def hoverEnterEvent(self, event):
if QtGui.QApplication.keyboardModifiers() == QtCore.Qt.ControlModifier:
QtGui.QToolTip.hideText()
QtGui.QToolTip.showText(event.screenPos(), self.function_overview)
self.setToolTip(self.function_overview)
return QtGui.QGraphicsItem.hoverEnterEvent(self, event)

def itemChange(self, change, value):
""" itemChange(change: GraphicsItemChange, value: value) -> value
Capture move event to also move the connections. Also unselect any
Expand Down

0 comments on commit 0171f96

Please sign in to comment.