From e82dd54242eb86382f55a2840338acea526b4fb1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Jan 2011 17:42:40 -0700 Subject: [PATCH] Fix #8409 (bulk edit date) --- src/calibre/gui2/dialogs/metadata_bulk.py | 24 ++++- src/calibre/gui2/dialogs/metadata_bulk.ui | 117 +++++++++++++++------- 2 files changed, 100 insertions(+), 41 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 2b3a319663..6e6b553dba 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -49,7 +49,6 @@ def get_cover_data(path): # {{{ return cdata, area # }}} - class MyBlockingBusy(QDialog): # {{{ do_one_signal = pyqtSignal() @@ -134,7 +133,7 @@ class MyBlockingBusy(QDialog): # {{{ do_autonumber, do_remove_format, remove_format, do_swap_ta, \ do_remove_conv, do_auto_author, series, do_series_restart, \ series_start_value, do_title_case, cover_action, clear_series, \ - pubdate = self.args + pubdate, adddate = self.args # first loop: do author and title. These will commit at the end of each @@ -214,6 +213,9 @@ class MyBlockingBusy(QDialog): # {{{ if pubdate is not None: self.db.set_pubdate(id, pubdate, notify=False, commit=False) + if adddate is not None: + self.db.set_timestamp(id, adddate, notify=False, commit=False) + if do_series: if do_series_restart: if self.series_start_value is None: @@ -300,6 +302,10 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): self.pubdate.setSpecialValueText(_('Undefined')) self.clear_pubdate_button.clicked.connect(self.clear_pubdate) self.pubdate.dateChanged.connect(self.do_apply_pubdate) + self.adddate.setMinimumDate(UNDEFINED_QDATE) + self.adddate.setSpecialValueText(_('Undefined')) + self.clear_adddate_button.clicked.connect(self.clear_adddate) + self.adddate.dateChanged.connect(self.do_apply_adddate) if len(self.db.custom_field_keys(include_composites=False)) == 0: self.central_widget.removeTab(1) @@ -322,6 +328,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): def clear_pubdate(self, *args): self.pubdate.setDate(UNDEFINED_QDATE) + def do_apply_adddate(self, *args): + self.apply_adddate.setChecked(True) + + def clear_adddate(self, *args): + self.adddate.setDate(UNDEFINED_QDATE) + def button_clicked(self, which): if which == self.button_box.button(QDialogButtonBox.Apply): self.do_again = True @@ -726,7 +738,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): name = name.strip().replace('|', ',') self.authors.addItem(name) self.authors.setEditText('') - + self.authors.set_separator('&') self.authors.set_space_before_sep(True) self.authors.update_items_cache(self.db.all_author_names()) @@ -805,9 +817,11 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): do_remove_conv = self.remove_conversion_settings.isChecked() do_auto_author = self.auto_author_sort.isChecked() do_title_case = self.change_title_to_title_case.isChecked() - pubdate = None + pubdate = adddate = None if self.apply_pubdate.isChecked(): pubdate = qt_to_dt(self.pubdate.date()) + if self.apply_adddate.isChecked(): + adddate = qt_to_dt(self.adddate.date()) cover_action = None if self.cover_remove.isChecked(): @@ -821,7 +835,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): do_autonumber, do_remove_format, remove_format, do_swap_ta, do_remove_conv, do_auto_author, series, do_series_restart, series_start_value, do_title_case, cover_action, clear_series, - pubdate) + pubdate, adddate) bb = MyBlockingBusy(_('Applying changes to %d books.\nPhase {0} {1}%%.') %len(self.ids), args, self.db, self.ids, diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 8db74b343d..f8ae926be6 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -347,6 +347,51 @@ from the value in the box + + + + &Date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + adddate + + + + + + + + + d MMM yyyy + + + true + + + + + + + ... + + + + :/images/trash.png:/images/trash.png + + + + + + + + + &Apply date + + + @@ -395,6 +440,42 @@ from the value in the box + + + + Remove &format: + + + remove_format + + + + + + + + 120 + 16777215 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 15 + + + + @@ -478,42 +559,6 @@ Future conversion of these books will use the default settings. - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 15 - - - - - - - - Remove &format: - - - remove_format - - - - - - - - 120 - 16777215 - - - -