From e131f99db8e5a80a68e4e28a152848effb7ece76 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Jan 2011 09:18:37 -0700 Subject: [PATCH 1/2] Cleanup layout of bulk metadata edit dialog --- src/calibre/gui2/dialogs/metadata_bulk.ui | 236 +++++++++++----------- 1 file changed, 115 insertions(+), 121 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 9240cd1af8..d52bc2cb89 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -75,13 +75,31 @@ - - - - A&utomatically set author sort + + + + true + + + + + + A&utomatically set author sort + + + + + + + &Swap title and author + + + + + @@ -95,7 +113,7 @@ - + Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. @@ -115,7 +133,7 @@ - + Rating of this book. 0-5 stars @@ -156,7 +174,7 @@ - + true @@ -220,7 +238,7 @@ Check this box to remove all tags from the books. - Remove all + Remove &all @@ -241,52 +259,35 @@ - - - - - List of known series. You can add new series. - - - List of known series. You can add new series. - - - true - - - QComboBox::InsertAlphabetically - - - QComboBox::AdjustToContents - - - - - - - If checked, the series will be cleared - - - Clear series - - - - - - - Qt::Horizontal - - - - 20 - 0 - - - - - + + + List of known series. You can add new series. + + + List of known series. You can add new series. + + + true + + + QComboBox::InsertAlphabetically + + + QComboBox::AdjustToContents + + - + + + + If checked, the series will be cleared + + + &Clear series + + + + @@ -297,7 +298,7 @@ you selected them. So if you selected Book A and then Book B, Book A will have series number 1 and Book B series number 2. - Automatically number books in this series + &Automatically number books in this series @@ -312,7 +313,7 @@ for that series. Checking this box will tell calibre to start numbering from the value in the box - Force numbers to start with + &Force numbers to start with: @@ -332,19 +333,6 @@ from the value in the box - - - - Qt::Horizontal - - - - 20 - 10 - - - - @@ -358,59 +346,56 @@ from the value in the box - - - - - - true - - - - - - - &Swap title and author - - - - - - - Force the title to be in title case. If both this and swap authors are checked, -title and author are swapped before the title case is set - - - Change title to title case - - - - - - - Remove stored conversion settings for the selected books. - -Future conversion of these books will use the default settings. - - - Remove &stored conversion settings for the selected books - - - - - - - Qt::Vertical - - + + - 20 - 40 + 120 + 16777215 - + - + + + + + + Force the title to be in title case. If both this and swap authors are checked, +title and author are swapped before the title case is set + + + Change title to title &case + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Remove stored conversion settings for the selected books. + +Future conversion of these books will use the default settings. + + + Remove &stored conversion settings for the selected books + + + + + + Change &cover @@ -440,6 +425,19 @@ Future conversion of these books will use the default settings. + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -902,14 +900,10 @@ not multiple and the destination field is multiple remove_tags remove_all_tags series - clear_series autonumber_series series_numbering_restarts series_start_number remove_format - remove_conversion_settings - swap_title_and_author - change_title_to_title_case button_box search_field search_mode From b83b89ce7437a8e0b7547cf6ac8a27112ee243ae Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Jan 2011 10:09:14 -0700 Subject: [PATCH 2/2] Fix #7568 (Allow bulk editing of Published date) --- src/calibre/gui2/dialogs/metadata_bulk.py | 31 ++- src/calibre/gui2/dialogs/metadata_bulk.ui | 108 ++++++-- src/calibre/gui2/dialogs/metadata_single.py | 13 +- src/calibre/gui2/dialogs/metadata_single.ui | 287 ++++++++++---------- 4 files changed, 274 insertions(+), 165 deletions(-) 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