In the main book list when editing a blank published date, use a default value of Jan 2000 so that changing the date it easier

This commit is contained in:
Kovid Goyal 2012-09-20 08:45:22 +05:30
parent 060836c133
commit f5086f5c9c

View File

@ -9,7 +9,7 @@ import sys
from PyQt4.Qt import (Qt, QApplication, QStyle, QIcon, QDoubleSpinBox,
QVariant, QSpinBox, QStyledItemDelegate, QComboBox, QTextDocument,
QAbstractTextDocumentLayout, QFont, QFontInfo)
QAbstractTextDocumentLayout, QFont, QFontInfo, QDate)
from calibre.gui2 import UNDEFINED_QDATETIME, error_dialog, rating_font
from calibre.constants import iswindows
@ -83,6 +83,7 @@ class DateDelegate(QStyledItemDelegate): # {{{
qde.setSpecialValueText(_('Undefined'))
qde.setCalendarPopup(True)
return qde
# }}}
class PubDateDelegate(QStyledItemDelegate): # {{{
@ -104,6 +105,12 @@ class PubDateDelegate(QStyledItemDelegate): # {{{
qde.setCalendarPopup(True)
return qde
def setEditorData(self, editor, index):
val = index.data(Qt.EditRole).toDate()
if val == UNDEFINED_QDATETIME.date():
val = QDate(2000, 1, 1)
editor.setDate(val)
# }}}
class TextDelegate(QStyledItemDelegate): # {{{