MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / eventFilter

Method eventFilter

MiniZincIDE/codeeditor.cpp:695–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695bool CodeEditor::eventFilter(QObject *, QEvent *ev)
696{
697 if (ev->type() == QEvent::KeyPress) {
698 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
699 if (keyEvent == QKeySequence::Copy) {
700 copy();
701 return true;
702 } else if (keyEvent == QKeySequence::Cut) {
703 cut();
704 return true;
705 }
706 } else if (ev->type() == QEvent::ToolTip) {
707 QHelpEvent* helpEvent = static_cast<QHelpEvent*>(ev);
708 QPoint evPos = helpEvent->pos();
709 evPos = QPoint(evPos.x()-lineNumbersWidth(),evPos.y());
710 if (evPos.x() >= 0) {
711 QTextCursor cursor = cursorForPosition(evPos);
712 bool foundError = false;
713 foreach (CodeEditorError cee, errors) {
714 if (cursor.position() >= cee.startPos && cursor.position() <= cee.endPos) {
715 QToolTip::showText(helpEvent->globalPos(), cee.msg);
716 foundError = true;
717 break;
718 }
719 }
720 if (!foundError) {
721 cursor.select(QTextCursor::WordUnderCursor);
722 QString loc(filename+":");
723 loc += QString().number(cursor.block().blockNumber()+1);
724 loc += ".";
725 loc += QString().number(cursor.selectionStart()-cursor.block().position()+1);
726 QHash<QString,QString>::iterator idMapIt = idMap.find(loc);
727 if (idMapIt != idMap.end()) {
728 QToolTip::showText(helpEvent->globalPos(), idMapIt.value());
729 } else {
730 QToolTip::hideText();
731 }
732 }
733 } else {
734 QToolTip::hideText();
735 }
736 return true;
737 }
738 return false;
739}
740
741void CodeEditor::copy()
742{

Callers

nothing calls this directly

Calls 4

typeMethod · 0.80
findMethod · 0.80
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected