/** * Checks if a tool tip is required for the given position. * NOTE: We currently return a tool tip for edges only * @param ptPos The position to query * @param rc Holds the tip's rectangle, upon return * @return The tip's text, or QString::null if no tip is required */ QString GraphWidget::getTip(const QPoint& ptPos, QRect& rc) { QPoint ptRealPos, ptTopLeft, ptBottomRight; QCanvasItemList il; QCanvasItemList::Iterator itr; GraphEdge* pEdge; QString sText, sFile, sLine; ptRealPos = viewportToContents(ptPos); ptRealPos /= m_dZoom; pEdge = NULL; // Check if there is an edge at this position il = canvas()->collisions(ptRealPos); for (itr = il.begin(); itr != il.end(); ++itr) { pEdge = dynamic_cast<GraphEdge*>(*itr); if (pEdge != NULL) break; } // No tip if no edge was found if (pEdge == NULL) return QString::null; // Set the rectangle for the tip (the tip is closed when the mouse leaves // this area) rc = pEdge->tipRect(); ptTopLeft = rc.topLeft(); ptBottomRight = rc.bottomRight(); ptTopLeft *= m_dZoom; ptBottomRight *= m_dZoom; ptTopLeft = contentsToViewport(ptTopLeft); ptBottomRight = contentsToViewport(ptBottomRight); rc = QRect(ptTopLeft, ptBottomRight); // Create a tip for this edge return pEdge->getTip(); }