TextEditor: Improve column selection

Add the possibility to more efficient column selection for large
documents using keyboard shortcuts Alt+Shift+PageUp/PageDown/Home/End.

Change-Id: Iaa2d9aeee587f1317dd82d7fef0b01fd5f5f7a55
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Viacheslav Tertychnyi
2020-04-01 14:46:39 +03:00
parent 51e8afa4f6
commit 4880694df4
2 changed files with 28 additions and 3 deletions

View File

@@ -153,9 +153,14 @@
\section1 Column Editing
To apply a change to several rows in a column simultaneously, press
\key Alt, select the rows, and enter or remove text. The changes are made
simultaneously at the cursor position on all the selected rows.
To apply a change to several rows in a column simultaneously, hold
\key Alt, select the rows using the mouse, and enter or remove text.
The changes are made simultaneously at the cursor position on all the
selected rows.
On Windows and Linux, you can also hold \key {Alt+Shift} and select
the rows using the arrow keys and the \key PageUp, \key PageDown,
\key Home, \key End keys.
\section1 Applying Refactoring Actions

View File

@@ -2496,6 +2496,10 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
case Qt::Key_Down:
case Qt::Key_Right:
case Qt::Key_Left:
case Qt::Key_PageUp:
case Qt::Key_PageDown:
case Qt::Key_Home:
case Qt::Key_End:
if (HostOsInfo::isMacHost())
break;
if ((e->modifiers()
@@ -2518,6 +2522,22 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
case Qt::Key_Right:
++d->m_blockSelection.positionColumn;
break;
case Qt::Key_PageUp:
d->m_blockSelection.positionBlock -= verticalScrollBar()->pageStep();
if (d->m_blockSelection.positionBlock < 0)
d->m_blockSelection.positionBlock = 0;
break;
case Qt::Key_PageDown:
d->m_blockSelection.positionBlock += verticalScrollBar()->pageStep();
if (d->m_blockSelection.positionBlock > document()->blockCount() - 1)
d->m_blockSelection.positionBlock = document()->blockCount() - 1;
break;
case Qt::Key_Home:
d->m_blockSelection.positionBlock = 0;
break;
case Qt::Key_End:
d->m_blockSelection.positionBlock = document()->blockCount() - 1;
break;
default:
break;
}