changeset 65:f9a1d33ed4a8

Add more keyboard controls.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 09 Apr 2017 14:49:03 +0300
parents 73fd86778014
children 6767807df30e
files main.cpp main.h
diffstat 2 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }
 
 
--- 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();