1) add force renumber series to custom series bulk editing

2) add clear series to both standard and custom series bulk editing
This commit is contained in:
Charles Haley 2010-09-26 12:38:34 +01:00
parent 1453722815
commit e3781d0f15
3 changed files with 124 additions and 65 deletions

View File

@ -452,9 +452,25 @@ class BulkSeries(BulkBase):
self.name_widget = w self.name_widget = w
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), w] self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), w]
self.widgets.append(QLabel(_('Automatically number books in this series'), parent)) self.widgets.append(QLabel('', parent))
self.idx_widget=QCheckBox(parent) w = QWidget(parent)
self.widgets.append(self.idx_widget) 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): def initialize(self, book_id):
self.idx_widget.setChecked(False) self.idx_widget.setChecked(False)
@ -465,17 +481,27 @@ class BulkSeries(BulkBase):
def getter(self): def getter(self):
n = unicode(self.name_widget.currentText()).strip() n = unicode(self.name_widget.currentText()).strip()
i = self.idx_widget.checkState() 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): def commit(self, book_ids, notify=False):
val, update_indices = self.gui_val val, update_indices, force_start, at_value, clear = self.gui_val
val = self.normalize_ui_val(val) val = '' if clear else self.normalize_ui_val(val)
if val != '': if clear or val != '':
extras = [] extras = []
next_index = self.db.get_next_cc_series_num_for(val, num=self.col_id) 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: for book_id in book_ids:
if clear:
extras.append(None)
continue
if update_indices: 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 s_index = next_index
next_index += 1 next_index += 1
else: else:
@ -483,6 +509,8 @@ class BulkSeries(BulkBase):
else: else:
s_index = self.db.get_custom_extra(book_id, num=self.col_id, s_index = self.db.get_custom_extra(book_id, num=self.col_id,
index_is_id=True) index_is_id=True)
if s_index is None:
s_index = 1.0
extras.append(s_index) extras.append(s_index)
self.db.set_custom_bulk(book_ids, val, extras=extras, self.db.set_custom_bulk(book_ids, val, extras=extras,
num=self.col_id, notify=notify) num=self.col_id, notify=notify)

View File

@ -32,7 +32,7 @@ class Worker(Thread):
remove, add, au, aus, do_aus, rating, pub, do_series, \ remove, add, au, aus, do_aus, rating, pub, do_series, \
do_autonumber, do_remove_format, remove_format, do_swap_ta, \ do_autonumber, do_remove_format, remove_format, do_swap_ta, \
do_remove_conv, do_auto_author, series, do_series_restart, \ 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 # 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 # operation, because each operation modifies the file system. We want to
@ -75,6 +75,9 @@ class Worker(Thread):
if pub: if pub:
self.db.set_publisher(id, pub, notify=False, commit=False) 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:
if do_series_restart: if do_series_restart:
next = series_start_value next = series_start_value
@ -592,6 +595,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
rating = self.rating.value() rating = self.rating.value()
pub = unicode(self.publisher.text()) pub = unicode(self.publisher.text())
do_series = self.write_series do_series = self.write_series
clear_series = self.clear_series.isChecked()
series = unicode(self.series.currentText()).strip() series = unicode(self.series.currentText()).strip()
do_autonumber = self.autonumber_series.isChecked() do_autonumber = self.autonumber_series.isChecked()
do_series_restart = self.series_numbering_restarts.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, args = (remove, add, au, aus, do_aus, rating, pub, do_series,
do_autonumber, do_remove_format, remove_format, do_swap_ta, do_autonumber, do_remove_format, remove_format, do_swap_ta,
do_remove_conv, do_auto_author, series, do_series_restart, 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.') bb = BlockingBusy(_('Applying changes to %d books. This may take a while.')
%len(self.ids), parent=self) %len(self.ids), parent=self)

View File

@ -225,6 +225,8 @@
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="7" column="1">
<layout class="QHBoxLayout" name="HLayout_34">
<item>
<widget class="EnComboBox" name="series"> <widget class="EnComboBox" name="series">
<property name="toolTip"> <property name="toolTip">
<string>List of known series. You can add new series.</string> <string>List of known series. You can add new series.</string>
@ -243,44 +245,31 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item>
<widget class="QLabel" name="label_5"> <widget class="QCheckBox" name="clear_series">
<property name="text">
<string>Remove &amp;format:</string>
</property>
<property name="buddy">
<cstring>remove_format</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="remove_format"/>
</item>
<item row="0" column="1">
<widget class="EnComboBox" name="authors">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="swap_title_and_author">
<property name="text">
<string>&amp;Swap title and author</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QCheckBox" name="change_title_to_title_case">
<property name="text">
<string>Change title to title case</string>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Force the title to be in title case. If both this and swap authors are checked, <string>If checked, the series will be cleared</string>
title and author are swapped before the title case is set</string> </property>
<property name="text">
<string>Clear series</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="HSpacer_344">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>00</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="8" column="1" colspan="2"> <item row="8" column="1" colspan="2">
<layout class="QHBoxLayout" name="HLayout_3"> <layout class="QHBoxLayout" name="HLayout_3">
<item> <item>
@ -339,6 +328,44 @@ from the value in the box</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="9" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Remove &amp;format:</string>
</property>
<property name="buddy">
<cstring>remove_format</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="remove_format"/>
</item>
<item row="0" column="1">
<widget class="EnComboBox" name="authors">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="swap_title_and_author">
<property name="text">
<string>&amp;Swap title and author</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QCheckBox" name="change_title_to_title_case">
<property name="text">
<string>Change title to title case</string>
</property>
<property name="toolTip">
<string>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</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2"> <item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="remove_conversion_settings"> <widget class="QCheckBox" name="remove_conversion_settings">
<property name="toolTip"> <property name="toolTip">