Book list: Press Shift+F2 to clear the contents of the current date like cell before editing it

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2015-10-15 13:14:01 +05:30
commit f8670c524c

View File

@ -223,7 +223,11 @@ class DateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
return DateTimeEdit(parent, self.format) return DateTimeEdit(parent, self.format)
def setEditorData(self, editor, index): 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) return DateTimeEdit(parent, self.format)
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
m = index.model() if QApplication.keyboardModifiers() == Qt.ShiftModifier:
# db col is not named for the field, but for the table number. To get it, val = UNDEFINED_QDATETIME
# gui column -> column label -> table number -> db column else:
val = m.db.data[index.row()][m.custom_columns[m.column_map[index.column()]]['rec_index']] m = index.model()
if val is None: # db col is not named for the field, but for the table number. To get it,
val = now() # 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) editor.setDateTime(val)
def setModelData(self, editor, model, index): def setModelData(self, editor, model, index):