Skip to content
Permalink
Browse files

[processing] Show tooltips in modeler when hovering over model component

  • Loading branch information
nyalldawson committed Mar 1, 2019
1 parent b5146db commit 93de4d15a66a47907a93884edd81fce887ce59b5
Showing with 18 additions and 2 deletions.
  1. +18 −2 python/plugins/processing/modeler/ModelerGraphicItem.py
@@ -51,6 +51,7 @@ class ModelerGraphicItem(QGraphicsItem):

def __init__(self, element, model, controls, scene=None):
super(ModelerGraphicItem, self).__init__(None)
self.setAcceptHoverEvents(True)
self.controls = controls
self.model = model
self.scene = scene
@@ -175,6 +176,18 @@ def boundingRect(self):
def mouseDoubleClickEvent(self, event):
self.editElement()

def hoverEnterEvent(self, event):
self.updateToolTip(event)

def hoverMoveEvent(self, event):
self.updateToolTip(event)

def updateToolTip(self, event):
if self.itemRect().contains(event.pos()):
self.setToolTip(self.text)
else:
self.setToolTip('')

def contextMenuEvent(self, event):
if isinstance(self.element, QgsProcessingModelOutput):
return
@@ -291,12 +304,15 @@ def getAdjustedText(self, text):
w = fm.width(text)
return text

def paint(self, painter, option, widget=None):
rect = QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2.0,
def itemRect(self):
return QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2.0,
-(ModelerGraphicItem.BOX_HEIGHT + 2) / 2.0,
ModelerGraphicItem.BOX_WIDTH + 2,
ModelerGraphicItem.BOX_HEIGHT + 2)

def paint(self, painter, option, widget=None):
rect = self.itemRect()

if isinstance(self.element, QgsProcessingModelParameter):
color = QColor(238, 242, 131)
stroke = QColor(234, 226, 118)

0 comments on commit 93de4d1

Please sign in to comment.
You can’t perform that action at this time.