Allow to choose note type from list by pressing ctrl + row number

This commit is contained in:
Alexander Presnyakov 2020-07-12 22:15:58 +03:00
parent 17edbd119d
commit e092dadc9a
2 changed files with 18 additions and 14 deletions

View file

@ -42,6 +42,7 @@ kenden
Nickolay Yudin <kelciour@gmail.com> Nickolay Yudin <kelciour@gmail.com>
neitrinoweb <github.com/neitrinoweb/> neitrinoweb <github.com/neitrinoweb/>
Andreas Reis <github.com/rathsky> Andreas Reis <github.com/rathsky>
Alexander Presnyakov <flagist0@gmail.com>
******************** ********************
The text of the 3 clause BSD license follows: The text of the 3 clause BSD license follows:

View file

@ -77,20 +77,23 @@ class StudyDeck(QDialog):
def eventFilter(self, obj: QObject, evt: QEvent) -> bool: def eventFilter(self, obj: QObject, evt: QEvent) -> bool:
if evt.type() == QEvent.KeyPress: if evt.type() == QEvent.KeyPress:
if evt.key() == Qt.Key_Up: new_row = current_row = self.form.list.currentRow()
c = self.form.list.count() rows_count = self.form.list.count()
row = self.form.list.currentRow() - 1 key = evt.key()
if row < 0:
row = c - 1 if key == Qt.Key_Up:
self.form.list.setCurrentRow(row) new_row = current_row - 1
return True elif key == Qt.Key_Down:
elif evt.key() == Qt.Key_Down: new_row = current_row + 1
c = self.form.list.count() elif evt.modifiers() & Qt.ControlModifier and Qt.Key_1 <= key <= Qt.Key_9:
row = self.form.list.currentRow() + 1 row_index = key - Qt.Key_1
if row == c: if row_index < rows_count:
row = 0 new_row = row_index
self.form.list.setCurrentRow(row)
return True if rows_count:
new_row %= rows_count # don't let row index overflow/underflow
self.form.list.setCurrentRow(new_row)
return new_row != current_row
return False return False
def redraw(self, filt, focus=None): def redraw(self, filt, focus=None):