mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add new option to the series_index_auto_increment tweak, no_change, that causes calibre not to change the series_index when the series is changed.
This commit is contained in:
parent
7b98ace36e
commit
51d866063a
@ -21,6 +21,7 @@ defaults.
|
|||||||
# last_free - First available integer smaller than the largest existing number
|
# last_free - First available integer smaller than the largest existing number
|
||||||
# Return largest existing + 1 if no free number is found
|
# Return largest existing + 1 if no free number is found
|
||||||
# const - Assign the number 1 always
|
# const - Assign the number 1 always
|
||||||
|
# no_change - Do not change the series index
|
||||||
# a number - Assign that number always. The number is not in quotes. Note that
|
# a number - Assign that number always. The number is not in quotes. Note that
|
||||||
# 0.0 can be used here.
|
# 0.0 can be used here.
|
||||||
# Examples:
|
# Examples:
|
||||||
|
@ -261,8 +261,12 @@ class MyBlockingBusy(QDialog): # {{{
|
|||||||
else:
|
else:
|
||||||
next = self.db.get_next_series_num_for(series)
|
next = self.db.get_next_series_num_for(series)
|
||||||
self.db.set_series(id, series, notify=False, commit=False)
|
self.db.set_series(id, series, notify=False, commit=False)
|
||||||
num = next if do_autonumber and series else 1.0
|
if not series:
|
||||||
self.db.set_series_index(id, num, notify=False, commit=False)
|
self.db.set_series_index(id, 1.0, notify=False, commit=False)
|
||||||
|
elif do_autonumber: # is True if do_series_restart is True
|
||||||
|
self.db.set_series_index(id, next, notify=False, commit=False)
|
||||||
|
elif tweaks['series_index_auto_increment'] != 'no_change':
|
||||||
|
self.db.set_series_index(id, 1.0, notify=False, commit=False)
|
||||||
|
|
||||||
if do_remove_conv:
|
if do_remove_conv:
|
||||||
self.db.delete_conversion_options(id, 'PIPE', commit=False)
|
self.db.delete_conversion_options(id, 'PIPE', commit=False)
|
||||||
|
@ -846,7 +846,9 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
s_index = float(match.group(1))
|
s_index = float(match.group(1))
|
||||||
val = pat.sub('', val).strip()
|
val = pat.sub('', val).strip()
|
||||||
elif val:
|
elif val:
|
||||||
if tweaks['series_index_auto_increment'] != 'const':
|
# it is OK to leave s_index == None when using 'no_change'
|
||||||
|
if tweaks['series_index_auto_increment'] != 'const' and \
|
||||||
|
tweaks['series_index_auto_increment'] != 'no_change':
|
||||||
s_index = self.db.get_next_cc_series_num_for(val,
|
s_index = self.db.get_next_cc_series_num_for(val,
|
||||||
label=label, num=None)
|
label=label, num=None)
|
||||||
elif typ == 'composite':
|
elif typ == 'composite':
|
||||||
@ -915,7 +917,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
self.db.set_series_index(id, float(match.group(1)))
|
self.db.set_series_index(id, float(match.group(1)))
|
||||||
val = pat.sub('', val).strip()
|
val = pat.sub('', val).strip()
|
||||||
elif val:
|
elif val:
|
||||||
if tweaks['series_index_auto_increment'] != 'const':
|
if tweaks['series_index_auto_increment'] != 'const' and \
|
||||||
|
tweaks['series_index_auto_increment'] != 'no_change':
|
||||||
ni = self.db.get_next_series_num_for(val)
|
ni = self.db.get_next_series_num_for(val)
|
||||||
if ni != 1:
|
if ni != 1:
|
||||||
self.db.set_series_index(id, ni)
|
self.db.set_series_index(id, ni)
|
||||||
|
@ -560,7 +560,7 @@ class SeriesIndexEdit(QDoubleSpinBox):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def increment(self):
|
def increment(self):
|
||||||
if self.db is not None:
|
if tweaks['series_index_auto_increment'] != 'no_change' and self.db is not None:
|
||||||
try:
|
try:
|
||||||
series = self.series_edit.current_val
|
series = self.series_edit.current_val
|
||||||
if series and series != self.original_series_name:
|
if series and series != self.original_series_name:
|
||||||
|
@ -829,7 +829,9 @@ def parse_series_string(db, label, value):
|
|||||||
val = pat.sub('', val).strip()
|
val = pat.sub('', val).strip()
|
||||||
s_index = float(match.group(1))
|
s_index = float(match.group(1))
|
||||||
elif val:
|
elif val:
|
||||||
if tweaks['series_index_auto_increment'] != 'const':
|
if tweaks['series_index_auto_increment'] == 'no_change':
|
||||||
|
pass
|
||||||
|
elif tweaks['series_index_auto_increment'] != 'const':
|
||||||
s_index = db.get_next_cc_series_num_for(val, label=label)
|
s_index = db.get_next_cc_series_num_for(val, label=label)
|
||||||
else:
|
else:
|
||||||
s_index = 1.0
|
s_index = 1.0
|
||||||
|
@ -2613,7 +2613,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.conn.execute('''UPDATE books_series_link
|
self.conn.execute('''UPDATE books_series_link
|
||||||
SET series=?
|
SET series=?
|
||||||
WHERE series=?''',(new_id, old_id,))
|
WHERE series=?''',(new_id, old_id,))
|
||||||
if change_index:
|
if change_index and tweaks['series_index_auto_increment'] != 'no_change':
|
||||||
# Now set the indices
|
# Now set the indices
|
||||||
for (book_id,) in books:
|
for (book_id,) in books:
|
||||||
# Get the next series index
|
# Get the next series index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user