void Editor::keyPressEvent (QKeyEvent *e) { switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: if(autoIndent() == 0) QPlainTextEdit::keyPressEvent(e); break; case Qt::Key_Period: if(isSpin) { if (propDialog->getAutoCompleteEnable()) { if(!spinAutoComplete()) QPlainTextEdit::keyPressEvent(e); } else QPlainTextEdit::keyPressEvent(e); } else { QPlainTextEdit::keyPressEvent(e); } break; case Qt::Key_Tab: case Qt::Key_Backtab: tabBlockShift(); break; default: QPlainTextEdit::keyPressEvent(e); } }
void EditorView::keyPressEvent(QKeyEvent * e) { QTextCursor cursor = textCursor(); if (e->modifiers() & Qt::ControlModifier) { switch (e->key()) { case Qt::Key_Home: cursor.movePosition(QTextCursor::Start); setTextCursor(cursor); break; case Qt::Key_End: cursor.movePosition(QTextCursor::End); setTextCursor(cursor); break; default: QPlainTextEdit::keyPressEvent(e); } } else { switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: if (smartIndent) { if(autoIndent() == 0) { QPlainTextEdit::keyPressEvent(e); } } else QPlainTextEdit::keyPressEvent(e); break; case Qt::Key_Period: if(!handleAutoComplete('.')) QPlainTextEdit::keyPressEvent(e); break; case Qt::Key_NumberSign: if(!handleAutoComplete('#')) QPlainTextEdit::keyPressEvent(e); break; case Qt::Key_Tab: tabOn = true; if (textCursor().hasSelection()) tabBlockShift(); else indent(); break; case Qt::Key_Backtab: tabOn = true; tabBlockShift(); break; case Qt::Key_Backspace: if (tabOn) dedent(); else QPlainTextEdit::keyPressEvent(e); break; case Qt::Key_Space: tabOn = false; QPlainTextEdit::keyPressEvent(e); break; default: QPlainTextEdit::keyPressEvent(e); } } }