Skip to content

Commit

Permalink
Home/End keys in the input editor move to top/bottom row (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
clementgallet committed May 7, 2020
1 parent f127e07 commit 485aa7e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Add horizontal scrollbar in the input editor (#316)
* Change the format of the input file, to make it more robust and adaptative (#332)
* Input Editor window can get behind main window (#334, #49)
* Home/End keys in the input editor move to top/bottom row (#335)

### Fixed

Expand Down
23 changes: 23 additions & 0 deletions src/program/ui/InputEditorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,29 @@ void InputEditorView::mouseMoveEvent(QMouseEvent *event)
event->accept();
}

void InputEditorView::keyPressEvent(QKeyEvent *event)
{
/* Check for the Home and End keys */
if ((event->key() == Qt::Key_End) && (event->modifiers() == Qt::NoModifier)) {
/* Select the last frame */
QModelIndex newSel = inputEditorModel->index(inputEditorModel->rowCount()-1, 0);
selectionModel()->clear();
setCurrentIndex(newSel);
selectionModel()->select(newSel, QItemSelectionModel::Select | QItemSelectionModel::Rows);
event->accept();
}
else if ((event->key() == Qt::Key_Home) && (event->modifiers() == Qt::NoModifier)) {
/* Select the first frame */
QModelIndex newSel = inputEditorModel->index(0, 0);
selectionModel()->clear();
setCurrentIndex(newSel);
selectionModel()->select(newSel, QItemSelectionModel::Select | QItemSelectionModel::Rows);
event->accept();
}

return QTableView::keyPressEvent(event);
}

void InputEditorView::horizontalMenu(QPoint pos)
{
/* Storing the index of the section where context menu was shown */
Expand Down
1 change: 1 addition & 0 deletions src/program/ui/InputEditorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public slots:
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;

private slots:
void resizeAllColumns();
Expand Down

0 comments on commit 485aa7e

Please sign in to comment.