mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
More unsafe usage of db.prefs.__setitem__ replaced
This commit is contained in:
parent
9464f31908
commit
56b04a40d8
@ -74,7 +74,7 @@ class ViewAction(InterfaceAction):
|
|||||||
|
|
||||||
def clear_history(self):
|
def clear_history(self):
|
||||||
db = self.gui.current_db
|
db = self.gui.current_db
|
||||||
db.prefs['gui_view_history'] = []
|
db.new_api.set_pref('gui_view_history', [])
|
||||||
self.build_menus(db)
|
self.build_menus(db)
|
||||||
|
|
||||||
def view_historical(self, id_):
|
def view_historical(self, id_):
|
||||||
@ -272,12 +272,12 @@ class ViewAction(InterfaceAction):
|
|||||||
seen.add(title)
|
seen.add(title)
|
||||||
history.append((id_, title))
|
history.append((id_, title))
|
||||||
|
|
||||||
db.prefs['gui_view_history'] = history[:vh]
|
db.new_api.set_pref('gui_view_history', history[:vh])
|
||||||
self.build_menus(db)
|
self.build_menus(db)
|
||||||
if remove:
|
if remove:
|
||||||
history = db.prefs.get('gui_view_history', [])
|
history = db.prefs.get('gui_view_history', [])
|
||||||
history = [x for x in history if x[0] not in remove]
|
history = [x for x in history if x[0] not in remove]
|
||||||
db.prefs['gui_view_history'] = history[:vh]
|
db.new_api.set_pref('gui_view_history', history[:vh])
|
||||||
self.build_menus(db)
|
self.build_menus(db)
|
||||||
|
|
||||||
def view_device_book(self, path):
|
def view_device_book(self, path):
|
||||||
|
@ -230,10 +230,8 @@ class CheckLibraryDialog(QDialog):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.db.prefs['check_library_ignore_extensions'] = \
|
self.db.new_api.set_pref('check_library_ignore_extensions', unicode(self.ext_ignores.text()))
|
||||||
unicode(self.ext_ignores.text())
|
self.db.new_api.set_pref('check_library_ignore_names', unicode(self.name_ignores.text()))
|
||||||
self.db.prefs['check_library_ignore_names'] = \
|
|
||||||
unicode(self.name_ignores.text())
|
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
def box_to_list(self, txt):
|
def box_to_list(self, txt):
|
||||||
|
@ -341,13 +341,13 @@ class VLTabs(QTabBar): # {{{
|
|||||||
self.gui.apply_virtual_library(vl, update_tabs=False)
|
self.gui.apply_virtual_library(vl, update_tabs=False)
|
||||||
|
|
||||||
def tab_moved(self, from_, to):
|
def tab_moved(self, from_, to):
|
||||||
self.current_db.prefs['virt_libs_order'] = [unicode(self.tabData(i) or '') for i in range(self.count())]
|
self.current_db.new_api.set_pref('virt_libs_order', [unicode(self.tabData(i) or '') for i in range(self.count())])
|
||||||
|
|
||||||
def tab_close(self, index):
|
def tab_close(self, index):
|
||||||
vl = unicode(self.tabData(index) or '')
|
vl = unicode(self.tabData(index) or '')
|
||||||
if vl: # Dont allow closing the All Books tab
|
if vl: # Dont allow closing the All Books tab
|
||||||
self.current_db.prefs['virt_libs_hidden'] = list(
|
self.current_db.new_api.set_pref('virt_libs_hidden', list(
|
||||||
self.current_db.prefs['virt_libs_hidden']) + [vl]
|
self.current_db.prefs['virt_libs_hidden']) + [vl])
|
||||||
self.removeTab(index)
|
self.removeTab(index)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -368,14 +368,14 @@ class VLTabs(QTabBar): # {{{
|
|||||||
hidden = set(db.prefs['virt_libs_hidden'])
|
hidden = set(db.prefs['virt_libs_hidden'])
|
||||||
if hidden - virt_libs:
|
if hidden - virt_libs:
|
||||||
hidden = hidden.intersection(virt_libs)
|
hidden = hidden.intersection(virt_libs)
|
||||||
db.prefs['virt_libs_hidden'] = list(hidden)
|
db.new_api.set_pref('virt_libs_hidden', list(hidden))
|
||||||
order = db.prefs['virt_libs_order']
|
order = db.prefs['virt_libs_order']
|
||||||
while self.count():
|
while self.count():
|
||||||
self.removeTab(0)
|
self.removeTab(0)
|
||||||
current_lib = db.data.get_base_restriction_name()
|
current_lib = db.data.get_base_restriction_name()
|
||||||
if current_lib in hidden:
|
if current_lib in hidden:
|
||||||
hidden.discard(current_lib)
|
hidden.discard(current_lib)
|
||||||
db.prefs['virt_libs_hidden'] = list(hidden)
|
db.new_api.set_pref('virt_libs_hidden', list(hidden))
|
||||||
current_idx = all_idx = None
|
current_idx = all_idx = None
|
||||||
virt_libs = (set(virt_libs) - hidden) | {''}
|
virt_libs = (set(virt_libs) - hidden) | {''}
|
||||||
order = {x:i for i, x in enumerate(order)}
|
order = {x:i for i, x in enumerate(order)}
|
||||||
@ -417,12 +417,12 @@ class VLTabs(QTabBar): # {{{
|
|||||||
m.exec_(ev.globalPos())
|
m.exec_(ev.globalPos())
|
||||||
|
|
||||||
def sort_alphabetically(self):
|
def sort_alphabetically(self):
|
||||||
self.current_db.prefs['virt_libs_order'] = ()
|
self.current_db.new_api.set_pref('virt_libs_order', ())
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def restore(self, x):
|
def restore(self, x):
|
||||||
h = self.current_db.prefs['virt_libs_hidden']
|
h = self.current_db.prefs['virt_libs_hidden']
|
||||||
self.current_db.prefs['virt_libs_hidden'] = list(set(h) - {x})
|
self.current_db.new_api.set_pref('virt_libs_hidden', list(set(h) - {x}))
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -610,7 +610,7 @@ class BooksView(QTableView): # {{{
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if ans is not None:
|
if ans is not None:
|
||||||
db.prefs[name] = ans
|
db.new_api.set_pref(name, ans)
|
||||||
else:
|
else:
|
||||||
injected = False
|
injected = False
|
||||||
if not ans.get('last_modified_injected', False):
|
if not ans.get('last_modified_injected', False):
|
||||||
@ -626,7 +626,7 @@ class BooksView(QTableView): # {{{
|
|||||||
if 'languages' not in hc:
|
if 'languages' not in hc:
|
||||||
hc.append('languages')
|
hc.append('languages')
|
||||||
if injected:
|
if injected:
|
||||||
db.prefs[name] = ans
|
db.new_api.set_pref(name, ans)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def restore_state(self):
|
def restore_state(self):
|
||||||
|
@ -83,7 +83,7 @@ class DisplayedFields(QAbstractListModel): # {{{
|
|||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if self.changed:
|
if self.changed:
|
||||||
self.db.prefs['book_display_fields'] = self.fields
|
self.db.new_api.set_pref('book_display_fields', self.fields)
|
||||||
|
|
||||||
def move(self, idx, delta):
|
def move(self, idx, delta):
|
||||||
row = idx.row() + delta
|
row = idx.row() + delta
|
||||||
|
@ -876,7 +876,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
cf()
|
cf()
|
||||||
# Save the current field_metadata for applications like calibre2opds
|
# Save the current field_metadata for applications like calibre2opds
|
||||||
# Goes here, because if cf is valid, db is valid.
|
# Goes here, because if cf is valid, db is valid.
|
||||||
db.prefs['field_metadata'] = db.field_metadata.all_metadata()
|
db.new_api.set_pref('field_metadata', db.field_metadata.all_metadata())
|
||||||
db.commit_dirty_cache()
|
db.commit_dirty_cache()
|
||||||
db.prefs.write_serialized(prefs['library_path'])
|
db.prefs.write_serialized(prefs['library_path'])
|
||||||
for action in self.iactions.values():
|
for action in self.iactions.values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user