def hoverMoveEvent(self, event): """ Tracks whether or not this item is being hovered. :param event | <QEvent> """ point = event.pos() found_key = '' found = None for key, value, subpath in self._subpaths: if subpath.contains(point): found = subpath found_key = key break if found: # update the tooltip tip = self.keyToolTip(found_key) if (tip): widget = self.scene().chartWidget() anchor = XPopupWidget.Anchor.RightCenter # show the popup widget XPopupWidget.showToolTip(tip, anchor=anchor, parent=widget, foreground=self.color().darker(120), background=self.alternateColor()) if (found != self._hoveredPath): self._hoveredPath = found self.update()
def rebuild( self, gridRect ): """ Rebuilds the tracker item. """ scene = self.scene() if ( not scene ): return self.setVisible(gridRect.contains(self.pos())) self.setZValue(100) path = QPainterPath() path.moveTo(0, 0) path.lineTo(0, gridRect.height()) tip = '' tip_point = None self._ellipses = [] items = scene.collidingItems(self) self._basePath = QPainterPath(path) for item in items: item_path = item.path() found = None for y in range(int(gridRect.top()), int(gridRect.bottom())): point = QPointF(self.pos().x(), y) if ( item_path.contains(point) ): found = QPointF(0, y - self.pos().y()) break if ( found ): path.addEllipse(found, 6, 6) self._ellipses.append(found) # update the value information value = scene.valueAt(self.mapToScene(found)) tip_point = self.mapToScene(found) hruler = scene.horizontalRuler() vruler = scene.verticalRuler() x_value = hruler.formatValue(value[0]) y_value = vruler.formatValue(value[1]) tip = '<b>x:</b> %s<br/><b>y:</b> %s' % (x_value, y_value) self.setPath(path) self.setVisible(True) # show the popup widget if ( tip ): anchor = XPopupWidget.Anchor.RightCenter widget = self.scene().chartWidget() tip_point = widget.mapToGlobal(widget.mapFromScene(tip_point)) XPopupWidget.showToolTip(tip, anchor = anchor, parent = widget, point = tip_point, foreground = QColor('blue'), background = QColor(148, 148, 255))
def hoverMoveEvent( self, event ): """ Tracks whether or not this item is being hovered. :param event | <QEvent> """ point = event.pos() found_key = '' found = None for key, value, subpath in self._subpaths: if subpath.contains(point): found = subpath found_key = key break if found: # update the tooltip tip = self.keyToolTip(found_key) if ( tip ): widget = self.scene().chartWidget() anchor = XPopupWidget.Anchor.RightCenter # show the popup widget XPopupWidget.showToolTip(tip, anchor = anchor, parent = widget, foreground = self.color().darker(120), background = self.alternateColor()) if ( found != self._hoveredPath ): self._hoveredPath = found self.update()
def helpEvent( self, event ): """ Displays a tool tip for the given help event. :param event | <QHelpEvent> """ item = self.itemAt(event.scenePos()) if ( item and item and item.toolTip() ): parent = self.parent() rect = item.path().boundingRect() point = event.scenePos() point.setY(item.pos().y() + rect.bottom()) point = parent.mapFromScene(point) point = parent.mapToGlobal(point) XPopupWidget.showToolTip(item.toolTip(), point = point, parent = parent) event.accept() else: super(XCalendarScene, self).helpEvent(event)