From 9a5d795d4da08c1863ff4492af000f5bf09ed154 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Thu, 15 Oct 2015 09:36:24 +0200 Subject: [PATCH] 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. --- src/calibre/gui2/library/delegates.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index 460cc092d7..fae6f05a23 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -223,7 +223,11 @@ class DateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ 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 @@ class CcDateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ 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):