| 520 | } |
| 521 | |
| 522 | QString 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 |
nothing calls this directly
no test coverage detected