diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py
index 5ea8f00148..da6e92c26a 100644
--- a/src/calibre/gui2/dialogs/metadata_bulk.py
+++ b/src/calibre/gui2/dialogs/metadata_bulk.py
@@ -15,15 +15,16 @@ from calibre.ebooks.metadata import string_to_authors, authors_to_string
from calibre.ebooks.metadata.book.base import composite_formatter
from calibre.ebooks.metadata.meta import get_metadata
from calibre.gui2.custom_column_widgets import populate_metadata_page
-from calibre.gui2 import error_dialog, ResizableDialog
+from calibre.gui2 import error_dialog, ResizableDialog, UNDEFINED_QDATE
from calibre.gui2.progress_indicator import ProgressIndicator
from calibre.utils.config import dynamic
from calibre.utils.titlecase import titlecase
from calibre.utils.icu import sort_key, capitalize
-from calibre.utils.config import prefs
+from calibre.utils.config import prefs, tweaks
from calibre.utils.magick.draw import identify_data
+from calibre.utils.date import qt_to_dt
-def get_cover_data(path):
+def get_cover_data(path): # {{{
old = prefs['read_file_metadata']
if not old:
prefs['read_file_metadata'] = True
@@ -46,7 +47,7 @@ def get_cover_data(path):
prefs['read_file_metadata'] = old
return cdata, area
-
+# }}}
class MyBlockingBusy(QDialog): # {{{
@@ -132,7 +133,8 @@ class MyBlockingBusy(QDialog): # {{{
remove_all, remove, add, au, aus, do_aus, rating, pub, do_series, \
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 = self.args
+ series_start_value, do_title_case, cover_action, clear_series, \
+ pubdate = self.args
# first loop: do author and title. These will commit at the end of each
@@ -209,6 +211,9 @@ class MyBlockingBusy(QDialog): # {{{
if clear_series:
self.db.set_series(id, '', notify=False, commit=False)
+ if pubdate is not None:
+ self.db.set_pubdate(id, pubdate, notify=False, commit=False)
+
if do_series:
if do_series_restart:
if self.series_start_value is None:
@@ -288,6 +293,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.series.editTextChanged.connect(self.series_changed)
self.tag_editor_button.clicked.connect(self.tag_editor)
self.autonumber_series.stateChanged[int].connect(self.auto_number_changed)
+ self.pubdate.setMinimumDate(UNDEFINED_QDATE)
+ pubdate_format = tweaks['gui_pubdate_display_format']
+ if pubdate_format is not None:
+ self.pubdate.setDisplayFormat(pubdate_format)
+ self.pubdate.setSpecialValueText(_('Undefined'))
+ self.clear_pubdate_button.clicked.connect(self.clear_pubdate)
if len(self.db.custom_field_keys(include_composites=False)) == 0:
self.central_widget.removeTab(1)
@@ -304,6 +315,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.central_widget.setCurrentIndex(tab)
self.exec_()
+ def clear_pubdate(self, *args):
+ self.pubdate.setDate(UNDEFINED_QDATE)
+
def button_clicked(self, which):
if which == self.button_box.button(QDialogButtonBox.Apply):
self.do_again = True
@@ -783,6 +797,10 @@ 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
+ if self.apply_pubdate.isChecked():
+ pubdate = qt_to_dt(self.pubdate.date())
+
cover_action = None
if self.cover_remove.isChecked():
cover_action = 'remove'
@@ -794,7 +812,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
args = (remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
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)
+ series_start_value, do_title_case, cover_action, clear_series,
+ pubdate)
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 d52bc2cb89..b14c31c9d1 100644
--- a/src/calibre/gui2/dialogs/metadata_bulk.ui
+++ b/src/calibre/gui2/dialogs/metadata_bulk.ui
@@ -220,6 +220,9 @@
&Remove tags:
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
remove_tags
@@ -260,6 +263,12 @@
-
+
+
+ 0
+ 0
+
+
List of known series. You can add new series.
@@ -273,7 +282,10 @@
QComboBox::InsertAlphabetically
- QComboBox::AdjustToContents
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
+
+
+ 40
@@ -335,27 +347,52 @@ from the value in the box
- -
-
+
-
+
- Remove &format:
+ &Published:
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
- remove_format
+ pubdate
- -
-
-
-
- 120
- 16777215
-
+
-
+
+
-
+
+
+ MMM yyyy
+
+
+
+ -
+
+
+ Clear published date
+
+
+ ...
+
+
+
+ :/images/trash.png:/images/trash.png
+
+
+
+
+
+ -
+
+
+ &Apply date
- -
+
-
-
@@ -395,7 +432,7 @@ Future conversion of these books will use the default settings.
- -
+
-
Change &cover
@@ -425,7 +462,7 @@ Future conversion of these books will use the default settings.
- -
+
-
Qt::Vertical
@@ -438,6 +475,42 @@ Future conversion of these books will use the default settings.
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 20
+ 15
+
+
+
+
+ -
+
+
+ Remove &format:
+
+
+ remove_format
+
+
+
+ -
+
+
+
+ 120
+ 16777215
+
+
+
+
@@ -798,8 +871,8 @@ not multiple and the destination field is multiple
0
0
- 197
- 60
+ 826
+ 313
@@ -903,7 +976,6 @@ not multiple and the destination field is multiple
autonumber_series
series_numbering_restarts
series_start_number
- remove_format
button_box
search_field
search_mode
diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py
index ede605343b..e4efdf0470 100644
--- a/src/calibre/gui2/dialogs/metadata_single.py
+++ b/src/calibre/gui2/dialogs/metadata_single.py
@@ -16,7 +16,7 @@ from PyQt4.Qt import SIGNAL, QObject, Qt, QTimer, QDate, \
from calibre.gui2 import error_dialog, file_icon_provider, dynamic, \
choose_files, choose_images, ResizableDialog, \
- warning_dialog, question_dialog
+ warning_dialog, question_dialog, UNDEFINED_QDATE
from calibre.gui2.dialogs.metadata_single_ui import Ui_MetadataSingleDialog
from calibre.gui2.dialogs.fetch_metadata import FetchMetadata
from calibre.gui2.dialogs.tag_editor import TagEditor
@@ -491,11 +491,15 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.formats.setAcceptDrops(True)
self.cover_changed = False
self.cpixmap = None
- self.pubdate.setMinimumDate(QDate(100,1,1))
+ self.pubdate.setMinimumDate(UNDEFINED_QDATE)
pubdate_format = tweaks['gui_pubdate_display_format']
if pubdate_format is not None:
self.pubdate.setDisplayFormat(pubdate_format)
- self.date.setMinimumDate(QDate(100,1,1))
+ self.date.setMinimumDate(UNDEFINED_QDATE)
+ self.pubdate.setSpecialValueText(_('Undefined'))
+ self.date.setSpecialValueText(_('Undefined'))
+ self.clear_pubdate_button.clicked.connect(self.clear_pubdate)
+
self.connect(self.cover, SIGNAL('cover_changed(PyQt_PyObject)'), self.cover_dropped)
QObject.connect(self.cover_button, SIGNAL("clicked(bool)"), \
@@ -615,6 +619,9 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.show()
+ def clear_pubdate(self, *args):
+ self.pubdate.setDate(UNDEFINED_QDATE)
+
def create_custom_column_editors(self):
w = self.central_widget.widget(1)
layout = w.layout()
diff --git a/src/calibre/gui2/dialogs/metadata_single.ui b/src/calibre/gui2/dialogs/metadata_single.ui
index 6d31342dcf..60c221be1a 100644
--- a/src/calibre/gui2/dialogs/metadata_single.ui
+++ b/src/calibre/gui2/dialogs/metadata_single.ui
@@ -100,6 +100,112 @@
+ -
+
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Automatically create the title sort entry based on the current title entry.
+Using this button to create title sort will change title sort from red to green.
+
+
+ ...
+
+
+
+ :/images/auto_author_sort.png:/images/auto_author_sort.png
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Swap the author and title
+
+
+ ...
+
+
+
+ :/images/swap.png:/images/swap.png
+
+
+
+ 16
+ 16
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Automatically create the author sort entry based on the current author entry.
+Using this button to create author sort will change author sort from red to green.
+
+
+ ...
+
+
+
+ :/images/auto_author_sort.png:/images/auto_author_sort.png
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
-
@@ -226,6 +332,31 @@ If the box is colored green, then text matches the individual author's sort stri
+ -
+
+
-
+
+
+ Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas.
+
+
+
+
+
+ -
+
+
+ Open Tag Editor
+
+
+ Open Tag Editor
+
+
+
+ :/images/chapters.png:/images/chapters.png
+
+
+
-
@@ -265,6 +396,20 @@ If the box is colored green, then text matches the individual author's sort stri
+ -
+
+
+ Remove unused series (Series that have no books)
+
+
+ ...
+
+
+
+ :/images/trash.png:/images/trash.png
+
+
+
-
@@ -330,7 +475,7 @@ If the box is colored green, then text matches the individual author's sort stri
- -
+
-
MMM yyyy
@@ -340,144 +485,10 @@ If the box is colored green, then text matches the individual author's sort stri
- -
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Automatically create the title sort entry based on the current title entry.
-Using this button to create title sort will change title sort from red to green.
-
-
- ...
-
-
-
- :/images/auto_author_sort.png:/images/auto_author_sort.png
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Swap the author and title
-
-
- ...
-
-
-
- :/images/swap.png:/images/swap.png
-
-
-
- 16
- 16
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Automatically create the author sort entry based on the current author entry.
-Using this button to create author sort will change author sort from red to green.
-
-
- ...
-
-
-
- :/images/auto_author_sort.png:/images/auto_author_sort.png
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
- -
-
-
-
-
-
- Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas.
-
-
-
-
-
- -
-
+
-
+
- Open Tag Editor
-
-
- Open Tag Editor
-
-
-
- :/images/chapters.png:/images/chapters.png
-
-
-
- -
-
-
- Remove unused series (Series that have no books)
-
-
- ...
+ Clear published date