# HG changeset patch # User Matti Hamalainen # Date 1491738543 -10800 # Node ID f9a1d33ed4a8de4688b9dd4bec24944936b811f5 # Parent 73fd86778014c1d956f3f5d653a28d1d7f1505da Add more keyboard controls. diff -r 73fd86778014 -r f9a1d33ed4a8 main.cpp --- a/main.cpp Sun Apr 09 11:29:56 2017 +0300 +++ b/main.cpp Sun Apr 09 14:49:03 2017 +0300 @@ -283,6 +283,11 @@ new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_Minus), this, SLOT(changeUIZoomOut())); new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_0), this, SLOT(changeUIZoomReset())); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this, SLOT(changeUIZoomReset())); + + new QShortcut(QKeySequence(Qt::Key_PageUp), this, SLOT(selectRowPrev())); + new QShortcut(QKeySequence(Qt::Key_PageDown), this, SLOT(selectRowNext())); + + new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(focusDebtEdit())); } @@ -539,6 +544,38 @@ void SyntilistaMainWindow::on_button_ClearFilter_clicked() { ui->edit_PersonFilter->clear(); + ui->edit_PersonFilter->setFocus(Qt::ShortcutFocusReason); +} + + +void SyntilistaMainWindow::focusDebtEdit() +{ + if (currPerson.id >= 0) + ui->edit_Amount->setFocus(Qt::ShortcutFocusReason); +} + + +void SyntilistaMainWindow::selectRowPrev() +{ + QItemSelectionModel *sel = ui->tableview_People->selectionModel(); + int row = sel->currentIndex().row() - 1; + if (row < 0) + row = 0; + + sel->setCurrentIndex(model_People->index(row, 0), + QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows); +} + + +void SyntilistaMainWindow::selectRowNext() +{ + QItemSelectionModel *sel = ui->tableview_People->selectionModel(); + int row = sel->currentIndex().row() + 1; + if (row >= model_People->rowCount()) + row = model_People->rowCount() - 1; + + sel->setCurrentIndex(model_People->index(row, 0), + QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows); } diff -r 73fd86778014 -r f9a1d33ed4a8 main.h --- a/main.h Sun Apr 09 11:29:56 2017 +0300 +++ b/main.h Sun Apr 09 14:49:03 2017 +0300 @@ -140,7 +140,11 @@ void on_tableview_People_doubleClicked(const QModelIndex &index); void selectedPersonChanged(const QModelIndex &, const QModelIndex &); - + + void focusDebtEdit(); + void selectRowPrev(); + void selectRowNext(); + void changeUIZoomIn(); void changeUIZoomOut(); void changeUIZoomReset();