Editing a None date now defaults to today instead of Unknown. This permits editing in place.

Using the character * in the bulk metadata is_mult delete box will cause all the values for that column to be deleted. In addition, deletes are done before adds.
This commit is contained in:
Charles Haley 2010-05-08 11:38:23 +01:00
parent fc5c5eb3c7
commit 324a651a12
3 changed files with 22 additions and 12 deletions

View File

@ -373,16 +373,15 @@ class BulkText(BulkBase):
def getter(self, original_value = None):
if self.col_metadata['is_multiple']:
ans = original_value
vals = [v.strip() for v in unicode(self.adding_widget.text()).split(',')]
for t in vals:
if t not in ans:
ans.append(t)
vals = [v.strip() for v in unicode(self.removing_widget.text()).split(',')]
for t in vals:
if t in ans:
ans.remove(t)
return ans
if self.removing_widget.text() == '*':
ans = set()
else:
ans = set(original_value)
ans -= set([v.strip() for v in
unicode(self.removing_widget.text()).split(',')])
ans |= set([v.strip() for v in
unicode(self.adding_widget.text()).split(',')])
return ans # returning a set instead of a list works, for now at least.
val = unicode(self.widgets[1].currentText()).strip()
if not val:
val = None

View File

@ -127,6 +127,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
if col_type == 'datetime':
if self.date_format_box.text():
date_format = {'date_format':unicode(self.date_format_box.text())}
else:
date_format = {'date_format': None}
if not self.editing_col:
self.parent.custcols[col] = {
@ -150,7 +152,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
item.setText(col_heading)
self.parent.custcols[self.orig_column_name]['label'] = col
self.parent.custcols[self.orig_column_name]['name'] = col_heading
self.parent.custcols[self.orig_column_name]['display'] = date_format
self.parent.custcols[self.orig_column_name]['display'].update(date_format)
self.parent.custcols[self.orig_column_name]['*edited'] = True
self.parent.custcols[self.orig_column_name]['*must_restart'] = True
QDialog.accept(self)

View File

@ -25,7 +25,7 @@ from calibre.gui2.widgets import EnLineEdit, TagsLineEdit
from calibre.library.caches import _match, CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils.config import tweaks
from calibre.utils.date import dt_factory, qt_to_dt, isoformat
from calibre.utils.date import dt_factory, qt_to_dt, isoformat, now
from calibre.utils.pyparsing import ParseException
from calibre.utils.search_query_parser import SearchQueryParser
@ -204,6 +204,15 @@ class CcDateDelegate(QStyledItemDelegate):
qde.setCalendarPopup(True)
return qde
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.db.FIELD_MAP[m.custom_columns[m.column_map[index.column()]]['num']]]
if val is None:
val = now()
editor.setDate(val)
class CcTextDelegate(QStyledItemDelegate):
'''
Delegate for text/int/float data.