| 220 | } |
| 221 | |
| 222 | void RDTreeView::mouseMoveEvent(QMouseEvent *e) |
| 223 | { |
| 224 | QModelIndex oldHoverIndex = m_currentHoverIndex; |
| 225 | |
| 226 | if(m_CurrentTooltipElided && m_TooltipLabel->isVisible() && |
| 227 | !m_TooltipLabel->geometry().contains(QCursor::pos())) |
| 228 | m_Tooltip->hideTip(); |
| 229 | |
| 230 | m_currentHoverIndex = indexAt(e->pos()); |
| 231 | |
| 232 | if(m_delegate->linkHover(e, font(), m_currentHoverIndex)) |
| 233 | { |
| 234 | if(cursor().shape() != Qt::PointingHandCursor) |
| 235 | { |
| 236 | viewport()->update(visualRect(m_currentHoverIndex)); |
| 237 | setCursor(QCursor(Qt::PointingHandCursor)); |
| 238 | } |
| 239 | } |
| 240 | else if(cursor().shape() == Qt::PointingHandCursor) |
| 241 | { |
| 242 | viewport()->update(visualRect(m_currentHoverIndex)); |
| 243 | unsetCursor(); |
| 244 | } |
| 245 | |
| 246 | if(oldHoverIndex != m_currentHoverIndex) |
| 247 | { |
| 248 | if(m_instantTooltips) |
| 249 | { |
| 250 | m_Tooltip->hideTip(); |
| 251 | |
| 252 | if(m_currentHoverIndex.isValid()) |
| 253 | { |
| 254 | QString tooltip = m_currentHoverIndex.data(Qt::ToolTipRole).toString(); |
| 255 | |
| 256 | if(!tooltip.isEmpty() || m_Tooltip->forceTip(this, m_currentHoverIndex)) |
| 257 | { |
| 258 | // We don't use QToolTip since we have a custom tooltip for showing elided results, and we |
| 259 | // use that for consistency. This also makes it easier to slot in a custom tooltip widget |
| 260 | // externally. |
| 261 | QPoint p = QCursor::pos(); |
| 262 | |
| 263 | // estimate, as this is not easily queryable |
| 264 | const QPoint cursorSize(16, 16); |
| 265 | const QRect screenAvailGeom = QApplication::desktop()->availableGeometry(p); |
| 266 | |
| 267 | // start with the tooltip placed bottom-right of the cursor, as the default |
| 268 | QRect tooltipRect; |
| 269 | tooltipRect.setTopLeft(p + cursorSize); |
| 270 | tooltipRect.setSize(m_Tooltip->configureTip(this, m_currentHoverIndex, tooltip)); |
| 271 | |
| 272 | // clip by the available geometry in x |
| 273 | if(tooltipRect.right() > screenAvailGeom.right()) |
| 274 | tooltipRect.moveRight(screenAvailGeom.right()); |
| 275 | |
| 276 | // if we'd go out of bounds in y, place the tooltip above the cursor. Don't just clip like |
| 277 | // in x, because that could place the tooltip over the cursor. |
| 278 | if(tooltipRect.bottom() > screenAvailGeom.bottom()) |
| 279 | tooltipRect.moveBottom(p.y() - cursorSize.y()); |
nothing calls this directly
no test coverage detected