MCPcopy Create free account
hub / github.com/KDE/kdevelop / textHint

Method textHint

kdevplatform/debugger/variable/variablecollection.cpp:522–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520}
521
522QString VariableProvider::textHint(KTextEditor::View* view, const KTextEditor::Cursor& cursor)
523{
524 if (!hasStartedSession())
525 return QString();
526
527 if (ICore::self()->uiController()->activeArea()->objectName() != QLatin1String("debug"))
528 return QString();
529
530 //TODO: These keyboardModifiers should also hide already opened tooltip, and show another one for code area.
531 if (QApplication::keyboardModifiers() == Qt::ControlModifier ||
532 QApplication::keyboardModifiers() == Qt::AltModifier){
533 return QString();
534 }
535
536 KTextEditor::Document* doc = view->document();
537
538 KTextEditor::Range expressionRange = currentSession()->variableController()->expressionRangeUnderCursor(doc, cursor);
539
540 if (!expressionRange.isValid())
541 return QString();
542 QString expression = doc->text(expressionRange).trimmed();
543
544 // Don't do anything if there's already an open tooltip with matching range
545 if (m_collection->m_activeTooltip && m_collection->m_activeTooltip->variable()->expression() == expression)
546 return QString();
547 if (expression.isEmpty())
548 return QString();
549
550 QPoint local = view->cursorToCoordinate(cursor);
551 QPoint global = view->mapToGlobal(local);
552 QWidget* w = view->childAt(local);
553 if (!w)
554 w = view;
555
556 m_collection->m_activeTooltip = new VariableToolTip(w, global+QPoint(30,30), expression);
557 m_collection->m_activeTooltip->setHandleRect(KTextEditorHelpers::itemBoundingRect(view, expressionRange));
558 return QString();
559}
560
561}
562

Callers

nothing calls this directly

Calls 15

hasStartedSessionFunction · 0.85
currentSessionFunction · 0.85
activeAreaMethod · 0.80
uiControllerMethod · 0.80
variableMethod · 0.80
childAtMethod · 0.80
setHandleRectMethod · 0.80
QStringClass · 0.70
QPointClass · 0.50
documentMethod · 0.45
variableControllerMethod · 0.45

Tested by

no test coverage detected