@@ -51,6 +51,7 @@ class ModelerGraphicItem(QGraphicsItem):
51
51
52
52
def __init__ (self , element , model , controls , scene = None ):
53
53
super (ModelerGraphicItem , self ).__init__ (None )
54
+ self .setAcceptHoverEvents (True )
54
55
self .controls = controls
55
56
self .model = model
56
57
self .scene = scene
@@ -175,6 +176,18 @@ def boundingRect(self):
175
176
def mouseDoubleClickEvent (self , event ):
176
177
self .editElement ()
177
178
179
+ def hoverEnterEvent (self , event ):
180
+ self .updateToolTip (event )
181
+
182
+ def hoverMoveEvent (self , event ):
183
+ self .updateToolTip (event )
184
+
185
+ def updateToolTip (self , event ):
186
+ if self .itemRect ().contains (event .pos ()):
187
+ self .setToolTip (self .text )
188
+ else :
189
+ self .setToolTip ('' )
190
+
178
191
def contextMenuEvent (self , event ):
179
192
if isinstance (self .element , QgsProcessingModelOutput ):
180
193
return
@@ -291,12 +304,15 @@ def getAdjustedText(self, text):
291
304
w = fm .width (text )
292
305
return text
293
306
294
- def paint (self , painter , option , widget = None ):
295
- rect = QRectF (- (ModelerGraphicItem .BOX_WIDTH + 2 ) / 2.0 ,
307
+ def itemRect (self ):
308
+ return QRectF (- (ModelerGraphicItem .BOX_WIDTH + 2 ) / 2.0 ,
296
309
- (ModelerGraphicItem .BOX_HEIGHT + 2 ) / 2.0 ,
297
310
ModelerGraphicItem .BOX_WIDTH + 2 ,
298
311
ModelerGraphicItem .BOX_HEIGHT + 2 )
299
312
313
+ def paint (self , painter , option , widget = None ):
314
+ rect = self .itemRect ()
315
+
300
316
if isinstance (self .element , QgsProcessingModelParameter ):
301
317
color = QColor (238 , 242 , 131 )
302
318
stroke = QColor (234 , 226 , 118 )
0 commit comments