Skip to content

Commit

Permalink
[processing] Show tooltips in modeler when hovering over model component
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 1, 2019
1 parent b5146db commit 93de4d1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions python/plugins/processing/modeler/ModelerGraphicItem.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93de4d1

Please sign in to comment.