MCPcopy Create free account
hub / github.com/Simsys/qhexedit2 / keyPressEvent

Method keyPressEvent

src/qhexedit.cpp:463–808  ·  view source on GitHub ↗

Handle events

Source from the content-addressed store, hash-verified

461
462// ********************************************************************** Handle events
463void QHexEdit::keyPressEvent(QKeyEvent *event)
464{
465 // Cursor movements
466 if (event->matches(QKeySequence::MoveToNextChar))
467 {
468 qint64 pos = _cursorPosition + 1;
469 if (_editAreaIsAscii)
470 pos += 1;
471 setCursorPosition(pos);
472 resetSelection(pos);
473 }
474 if (event->matches(QKeySequence::MoveToPreviousChar))
475 {
476 qint64 pos = _cursorPosition - 1;
477 if (_editAreaIsAscii)
478 pos -= 1;
479 setCursorPosition(pos);
480 resetSelection(pos);
481 }
482 if (event->matches(QKeySequence::MoveToEndOfLine))
483 {
484 qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)) + (2 * _bytesPerLine) - 1;
485 setCursorPosition(pos);
486 resetSelection(_cursorPosition);
487 }
488 if (event->matches(QKeySequence::MoveToStartOfLine))
489 {
490 qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine));
491 setCursorPosition(pos);
492 resetSelection(_cursorPosition);
493 }
494 if (event->matches(QKeySequence::MoveToPreviousLine))
495 {
496 setCursorPosition(_cursorPosition - (2 * _bytesPerLine));
497 resetSelection(_cursorPosition);
498 }
499 if (event->matches(QKeySequence::MoveToNextLine))
500 {
501 setCursorPosition(_cursorPosition + (2 * _bytesPerLine));
502 resetSelection(_cursorPosition);
503 }
504 if (event->matches(QKeySequence::MoveToNextPage))
505 {
506 setCursorPosition(_cursorPosition + (((_rowsShown - 1) * 2 * _bytesPerLine)));
507 resetSelection(_cursorPosition);
508 }
509 if (event->matches(QKeySequence::MoveToPreviousPage))
510 {
511 setCursorPosition(_cursorPosition - (((_rowsShown - 1) * 2 * _bytesPerLine)));
512 resetSelection(_cursorPosition);
513 }
514 if (event->matches(QKeySequence::MoveToEndOfDocument))
515 {
516 setCursorPosition(_chunks->size() * 2 );
517 resetSelection(_cursorPosition);
518 }
519 if (event->matches(QKeySequence::MoveToStartOfDocument))
520 {

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
dataMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected