mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:05:04 +02:00
Make SHIFT+F2 clear the date when launching the editor on a date in the book list. This doesn't steal a shortcut because F" with any modifier launches the delegate.
This commit is contained in:
parent
dce2207202
commit
9a5d795d4d
1 changed files with 14 additions and 7 deletions
|
|
@ -223,7 +223,11 @@ def createEditor(self, parent, option, index):
|
|||
return DateTimeEdit(parent, self.format)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
QStyledItemDelegate.setEditorData(self, editor, index)
|
||||
if QApplication.keyboardModifiers() == Qt.ShiftModifier:
|
||||
val = UNDEFINED_QDATETIME
|
||||
else:
|
||||
val = index.data(Qt.EditRole)
|
||||
editor.setDateTime(val)
|
||||
|
||||
# }}}
|
||||
|
||||
|
|
@ -393,12 +397,15 @@ def createEditor(self, parent, option, index):
|
|||
return DateTimeEdit(parent, self.format)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
m = index.model()
|
||||
# db col is not named for the field, but for the table number. To get it,
|
||||
# gui column -> column label -> table number -> db column
|
||||
val = m.db.data[index.row()][m.custom_columns[m.column_map[index.column()]]['rec_index']]
|
||||
if val is None:
|
||||
val = now()
|
||||
if QApplication.keyboardModifiers() == Qt.ShiftModifier:
|
||||
val = UNDEFINED_QDATETIME
|
||||
else:
|
||||
m = index.model()
|
||||
# db col is not named for the field, but for the table number. To get it,
|
||||
# gui column -> column label -> table number -> db column
|
||||
val = m.db.data[index.row()][m.custom_columns[m.column_map[index.column()]]['rec_index']]
|
||||
if val is None:
|
||||
val = now()
|
||||
editor.setDateTime(val)
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
|
|
|
|||
Loading…
Reference in a new issue