From e3781d0f15e4b7fa9dec8f55348dae129172c52f Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 26 Sep 2010 12:38:34 +0100 Subject: [PATCH] 1) add force renumber series to custom series bulk editing 2) add clear series to both standard and custom series bulk editing --- src/calibre/gui2/custom_column_widgets.py | 44 +++++-- src/calibre/gui2/dialogs/metadata_bulk.py | 8 +- src/calibre/gui2/dialogs/metadata_bulk.ui | 137 +++++++++++++--------- 3 files changed, 124 insertions(+), 65 deletions(-) diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py index 90abfc2474..1d265fea1e 100644 --- a/src/calibre/gui2/custom_column_widgets.py +++ b/src/calibre/gui2/custom_column_widgets.py @@ -452,9 +452,25 @@ class BulkSeries(BulkBase): self.name_widget = w self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), w] - self.widgets.append(QLabel(_('Automatically number books in this series'), parent)) - self.idx_widget=QCheckBox(parent) - self.widgets.append(self.idx_widget) + self.widgets.append(QLabel('', parent)) + w = QWidget(parent) + layout = QHBoxLayout(w) + layout.setContentsMargins(0, 0, 0, 0) + self.remove_series = QCheckBox(parent) + self.remove_series.setText(_('Remove series')) + layout.addWidget(self.remove_series) + self.idx_widget = QCheckBox(parent) + self.idx_widget.setText(_('Automatically number books')) + layout.addWidget(self.idx_widget) + self.force_number = QCheckBox(parent) + self.force_number.setText(_('Force numbers to start with ')) + layout.addWidget(self.force_number) + self.series_start_number = QSpinBox(parent) + self.series_start_number.setMinimum(1) + self.series_start_number.setProperty("value", 1) + layout.addWidget(self.series_start_number) + layout.addItem(QSpacerItem(20, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)) + self.widgets.append(w) def initialize(self, book_id): self.idx_widget.setChecked(False) @@ -465,17 +481,27 @@ class BulkSeries(BulkBase): def getter(self): n = unicode(self.name_widget.currentText()).strip() i = self.idx_widget.checkState() - return n, i + f = self.force_number.checkState() + s = self.series_start_number.value() + r = self.remove_series.checkState() + return n, i, f, s, r def commit(self, book_ids, notify=False): - val, update_indices = self.gui_val - val = self.normalize_ui_val(val) - if val != '': + val, update_indices, force_start, at_value, clear = self.gui_val + val = '' if clear else self.normalize_ui_val(val) + if clear or val != '': extras = [] next_index = self.db.get_next_cc_series_num_for(val, num=self.col_id) + print 'cc commit next index', next_index for book_id in book_ids: + if clear: + extras.append(None) + continue if update_indices: - if tweaks['series_index_auto_increment'] == 'next': + if force_start: + s_index = at_value + at_value += 1 + elif tweaks['series_index_auto_increment'] == 'next': s_index = next_index next_index += 1 else: @@ -483,6 +509,8 @@ class BulkSeries(BulkBase): else: s_index = self.db.get_custom_extra(book_id, num=self.col_id, index_is_id=True) + if s_index is None: + s_index = 1.0 extras.append(s_index) self.db.set_custom_bulk(book_ids, val, extras=extras, num=self.col_id, notify=notify) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index b14390e001..9c83b3aee5 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -32,7 +32,7 @@ class Worker(Thread): 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 = self.args + series_start_value, do_title_case, clear_series = self.args # first loop: do author and title. These will commit at the end of each # operation, because each operation modifies the file system. We want to @@ -75,6 +75,9 @@ class Worker(Thread): if pub: self.db.set_publisher(id, pub, notify=False, commit=False) + if clear_series: + self.db.set_series(id, '', notify=False, commit=False) + if do_series: if do_series_restart: next = series_start_value @@ -592,6 +595,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): rating = self.rating.value() pub = unicode(self.publisher.text()) do_series = self.write_series + clear_series = self.clear_series.isChecked() series = unicode(self.series.currentText()).strip() do_autonumber = self.autonumber_series.isChecked() do_series_restart = self.series_numbering_restarts.isChecked() @@ -606,7 +610,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): args = (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) + series_start_value, do_title_case, clear_series) bb = BlockingBusy(_('Applying changes to %d books. This may take a while.') %len(self.ids), parent=self) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index e03a59b7ea..60e24dbceb 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -225,61 +225,50 @@ - - - List of known series. You can add new series. - - - List of known series. You can add new series. - - - true - - - QComboBox::InsertAlphabetically - - - QComboBox::AdjustToContents - - - - - - - Remove &format: - - - remove_format - - - - - - - - - - true - - - - - - - &Swap title and author - - - - - - - Change title to title case - - - 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 - - + + + + + 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 + 00 + + + + + @@ -339,6 +328,44 @@ from the value in the box + + + + Remove &format: + + + remove_format + + + + + + + + + + true + + + + + + + &Swap title and author + + + + + + + Change title to title case + + + 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 + + +