mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove use of legacy db.prefs API where possible
This commit is contained in:
parent
99bf8b9dac
commit
065becd6a6
@ -71,7 +71,7 @@ class ViewAction(InterfaceAction):
|
||||
for ac in self.history_actions:
|
||||
self.view_menu.removeAction(ac)
|
||||
self.history_actions = []
|
||||
history = db.prefs.get('gui_view_history', [])
|
||||
history = db.new_api.pref('gui_view_history', [])
|
||||
if history:
|
||||
self.view_menu.insertAction(self.clear_sep2, self.clear_sep1)
|
||||
self.history_actions.append(self.clear_sep1)
|
||||
@ -317,7 +317,7 @@ class ViewAction(InterfaceAction):
|
||||
if views:
|
||||
seen = set()
|
||||
history = []
|
||||
for id_, title in views + db.prefs.get('gui_view_history', []):
|
||||
for id_, title in views + db.new_api.pref('gui_view_history', []):
|
||||
if title not in seen:
|
||||
seen.add(title)
|
||||
history.append((id_, title))
|
||||
@ -325,7 +325,7 @@ class ViewAction(InterfaceAction):
|
||||
db.new_api.set_pref('gui_view_history', history[:vh])
|
||||
self.build_menus(db)
|
||||
if remove:
|
||||
history = db.prefs.get('gui_view_history', [])
|
||||
history = db.new_api.pref('gui_view_history', [])
|
||||
history = [x for x in history if x[0] not in remove]
|
||||
db.new_api.set_pref('gui_view_history', history[:vh])
|
||||
self.build_menus(db)
|
||||
|
@ -164,7 +164,7 @@ class Bool(Base):
|
||||
l.addWidget(c)
|
||||
c.clicked.connect(self.set_to_no)
|
||||
|
||||
if self.db.prefs.get('bools_are_tristate'):
|
||||
if self.db.new_api.pref('bools_are_tristate'):
|
||||
t = _('Clear')
|
||||
c = QPushButton(t, parent)
|
||||
width = c.fontMetrics().boundingRect(t).width() + 7
|
||||
@ -179,7 +179,7 @@ class Bool(Base):
|
||||
w = self.combobox
|
||||
items = [_('Yes'), _('No'), _('Undefined')]
|
||||
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')]
|
||||
if not self.db.prefs.get('bools_are_tristate'):
|
||||
if not self.db.new_api.pref('bools_are_tristate'):
|
||||
items = items[:-1]
|
||||
icons = icons[:-1]
|
||||
for icon, text in zip(icons, items):
|
||||
@ -187,7 +187,7 @@ class Bool(Base):
|
||||
|
||||
def setter(self, val):
|
||||
val = {None: 2, False: 1, True: 0}[val]
|
||||
if not self.db.prefs.get('bools_are_tristate') and val == 2:
|
||||
if not self.db.new_api.pref('bools_are_tristate') and val == 2:
|
||||
val = 1
|
||||
self.combobox.setCurrentIndex(val)
|
||||
|
||||
@ -908,7 +908,7 @@ class BulkBool(BulkBase, Bool):
|
||||
value = None
|
||||
for book_id in book_ids:
|
||||
val = self.db.get_custom(book_id, num=self.col_id, index_is_id=True)
|
||||
if not self.db.prefs.get('bools_are_tristate') and val is None:
|
||||
if not self.db.new_api.pref('bools_are_tristate') and val is None:
|
||||
val = False
|
||||
if value is not None and value != val:
|
||||
return None
|
||||
@ -918,7 +918,7 @@ class BulkBool(BulkBase, Bool):
|
||||
def setup_ui(self, parent):
|
||||
self.make_widgets(parent, QComboBox)
|
||||
items = [_('Yes'), _('No')]
|
||||
if not self.db.prefs.get('bools_are_tristate'):
|
||||
if not self.db.new_api.pref('bools_are_tristate'):
|
||||
items.append('')
|
||||
else:
|
||||
items.append(_('Undefined'))
|
||||
@ -930,7 +930,7 @@ class BulkBool(BulkBase, Bool):
|
||||
|
||||
def getter(self):
|
||||
val = self.main_widget.currentIndex()
|
||||
if not self.db.prefs.get('bools_are_tristate'):
|
||||
if not self.db.new_api.pref('bools_are_tristate'):
|
||||
return {2: False, 1: False, 0: True}[val]
|
||||
else:
|
||||
return {2: None, 1: False, 0: True}[val]
|
||||
@ -945,13 +945,13 @@ class BulkBool(BulkBase, Bool):
|
||||
return
|
||||
val = self.gui_val
|
||||
val = self.normalize_ui_val(val)
|
||||
if not self.db.prefs.get('bools_are_tristate') and val is None:
|
||||
if not self.db.new_api.pref('bools_are_tristate') and val is None:
|
||||
val = False
|
||||
self.db.set_custom_bulk(book_ids, val, num=self.col_id, notify=notify)
|
||||
|
||||
def a_c_checkbox_changed(self):
|
||||
if not self.ignore_change_signals:
|
||||
if not self.db.prefs.get('bools_are_tristate') and \
|
||||
if not self.db.new_api.pref('bools_are_tristate') and \
|
||||
self.main_widget.currentIndex() == 2:
|
||||
self.a_c_checkbox.setChecked(False)
|
||||
else:
|
||||
|
@ -1372,7 +1372,7 @@ class DeviceMixin(object): # {{{
|
||||
'Set of ids to be sent to device'
|
||||
ans = []
|
||||
try:
|
||||
ans = self.library_view.model().db.prefs.get('news_to_be_synced',
|
||||
ans = self.library_view.model().db.new_api.pref('news_to_be_synced',
|
||||
[])
|
||||
except:
|
||||
import traceback
|
||||
@ -1563,7 +1563,7 @@ class DeviceMixin(object): # {{{
|
||||
'''
|
||||
Upload metadata to device.
|
||||
'''
|
||||
plugboards = self.library_view.model().db.prefs.get('plugboards', {})
|
||||
plugboards = self.library_view.model().db.new_api.pref('plugboards', {})
|
||||
self.device_manager.sync_booklists(Dispatcher(lambda x: x),
|
||||
self.booklists(), plugboards)
|
||||
|
||||
@ -1571,7 +1571,7 @@ class DeviceMixin(object): # {{{
|
||||
'''
|
||||
Upload metadata to device.
|
||||
'''
|
||||
plugboards = self.library_view.model().db.prefs.get('plugboards', {})
|
||||
plugboards = self.library_view.model().db.new_api.pref('plugboards', {})
|
||||
self.device_manager.sync_booklists(FunctionDispatcher(self.metadata_synced),
|
||||
self.booklists(), plugboards,
|
||||
add_as_step_to_job=add_as_step_to_job)
|
||||
@ -1611,7 +1611,7 @@ class DeviceMixin(object): # {{{
|
||||
:param files: List of either paths to files or file like objects
|
||||
'''
|
||||
titles = [i.title for i in metadata]
|
||||
plugboards = self.library_view.model().db.prefs.get('plugboards', {})
|
||||
plugboards = self.library_view.model().db.new_api.pref('plugboards', {})
|
||||
job = self.device_manager.upload_books(
|
||||
FunctionDispatcher(self.books_uploaded),
|
||||
files, names, on_card=on_card,
|
||||
@ -1947,7 +1947,7 @@ class DeviceMixin(object): # {{{
|
||||
|
||||
if update_metadata:
|
||||
if self.device_manager.is_device_connected:
|
||||
plugboards = self.library_view.model().db.prefs.get('plugboards', {})
|
||||
plugboards = self.library_view.model().db.new_api.pref('plugboards', {})
|
||||
self.device_manager.sync_booklists(
|
||||
FunctionDispatcher(self.metadata_synced), booklists,
|
||||
plugboards, add_as_step_to_job)
|
||||
|
@ -208,7 +208,7 @@ class CheckLibraryDialog(QDialog):
|
||||
ln = QLabel(_('Names to ignore:'))
|
||||
h.addWidget(ln)
|
||||
self.name_ignores = QLineEdit()
|
||||
self.name_ignores.setText(db.prefs.get('check_library_ignore_names', ''))
|
||||
self.name_ignores.setText(db.new_api.pref('check_library_ignore_names', ''))
|
||||
self.name_ignores.setToolTip(
|
||||
_('Enter comma-separated standard file name wildcards, such as synctoy*.dat'))
|
||||
ln.setBuddy(self.name_ignores)
|
||||
@ -216,7 +216,7 @@ class CheckLibraryDialog(QDialog):
|
||||
le = QLabel(_('Extensions to ignore:'))
|
||||
h.addWidget(le)
|
||||
self.ext_ignores = QLineEdit()
|
||||
self.ext_ignores.setText(db.prefs.get('check_library_ignore_extensions', ''))
|
||||
self.ext_ignores.setText(db.new_api.pref('check_library_ignore_extensions', ''))
|
||||
self.ext_ignores.setToolTip(
|
||||
_('Enter comma-separated extensions without a leading dot. Used only in book folders'))
|
||||
le.setBuddy(self.ext_ignores)
|
||||
|
@ -92,7 +92,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
self.category_icons.append(cc_icon)
|
||||
category_names.append(cc['name'])
|
||||
self.category_values.append(lambda col=key: [t.original_name for t in self.db_categories[col]])
|
||||
self.categories = dict.copy(db.prefs.get('user_categories', {}))
|
||||
self.categories = dict.copy(db.new_api.pref('user_categories', {}))
|
||||
if self.categories is None:
|
||||
self.categories = {}
|
||||
self.initialize_category_lists(book_ids=None)
|
||||
|
@ -460,7 +460,7 @@ class VLTabs(QTabBar): # {{{
|
||||
vl = unicode_type(self.tabData(index) or '')
|
||||
if vl: # Dont allow closing the All Books tab
|
||||
self.current_db.new_api.set_pref('virt_libs_hidden', list(
|
||||
self.current_db.prefs['virt_libs_hidden']) + [vl])
|
||||
self.current_db.new_api.pref('virt_libs_hidden', ())) + [vl])
|
||||
self.removeTab(index)
|
||||
|
||||
@property
|
||||
@ -476,13 +476,13 @@ class VLTabs(QTabBar): # {{{
|
||||
|
||||
def _rebuild(self):
|
||||
db = self.current_db
|
||||
vl_map = db.prefs.get('virtual_libraries', {})
|
||||
vl_map = db.new_api.pref('virtual_libraries', {})
|
||||
virt_libs = frozenset(vl_map)
|
||||
hidden = set(db.prefs['virt_libs_hidden'])
|
||||
hidden = set(db.new_api.pref('virt_libs_hidden', ()))
|
||||
if hidden - virt_libs:
|
||||
hidden = hidden.intersection(virt_libs)
|
||||
db.new_api.set_pref('virt_libs_hidden', list(hidden))
|
||||
order = db.prefs['virt_libs_order']
|
||||
order = db.new_api.pref('virt_libs_order', ())
|
||||
while self.count():
|
||||
self.removeTab(0)
|
||||
current_lib = db.data.get_base_restriction_name()
|
||||
@ -521,7 +521,7 @@ class VLTabs(QTabBar): # {{{
|
||||
def contextMenuEvent(self, ev):
|
||||
m = QMenu(self)
|
||||
m.addAction(_('Sort tabs alphabetically'), self.sort_alphabetically)
|
||||
hidden = self.current_db.prefs['virt_libs_hidden']
|
||||
hidden = self.current_db.new_api.pref('virt_libs_hidden')
|
||||
if hidden:
|
||||
s = m._s = m.addMenu(_('Restore hidden tabs'))
|
||||
for x in hidden:
|
||||
@ -545,7 +545,7 @@ class VLTabs(QTabBar): # {{{
|
||||
self.rebuild()
|
||||
|
||||
def restore(self, x):
|
||||
h = self.current_db.prefs['virt_libs_hidden']
|
||||
h = self.current_db.new_api.pref('virt_libs_hidden', ())
|
||||
self.current_db.new_api.set_pref('virt_libs_hidden', list(set(h) - {x}))
|
||||
self.rebuild()
|
||||
|
||||
|
@ -699,7 +699,7 @@ class CcBoolDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
editor = DelegateCB(parent)
|
||||
items = [_('Y'), _('N'), ' ']
|
||||
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')]
|
||||
if not index.model().db.prefs.get('bools_are_tristate'):
|
||||
if not index.model().db.new_api.pref('bools_are_tristate'):
|
||||
items = items[:-1]
|
||||
icons = icons[:-1]
|
||||
self.longest_text = ''
|
||||
@ -721,7 +721,7 @@ class CcBoolDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
def setEditorData(self, editor, index):
|
||||
m = index.model()
|
||||
val = m.db.data[index.row()][m.custom_columns[m.column_map[index.column()]]['rec_index']]
|
||||
if not m.db.prefs.get('bools_are_tristate'):
|
||||
if not m.db.new_api.pref('bools_are_tristate'):
|
||||
val = 1 if not val or check_key_modifier(Qt.ControlModifier) else 0
|
||||
else:
|
||||
val = 2 if val is None or check_key_modifier(Qt.ControlModifier) \
|
||||
|
@ -660,7 +660,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
cover_as_data=True)
|
||||
newmi = None
|
||||
if use_plugboard and format.lower() in plugboard_formats:
|
||||
plugboards = self.db.prefs.get('plugboards', {})
|
||||
plugboards = self.new_api.pref('plugboards', {})
|
||||
cpb = find_plugboard(use_plugboard, format.lower(),
|
||||
plugboards)
|
||||
if cpb:
|
||||
@ -895,7 +895,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
if col >= len(self.column_to_dc_map):
|
||||
return None
|
||||
if role == Qt.DisplayRole:
|
||||
rules = self.db.prefs['column_icon_rules']
|
||||
rules = self.db.new_api.pref('column_icon_rules')
|
||||
if rules:
|
||||
key = self.column_map[col]
|
||||
id_ = None
|
||||
@ -928,7 +928,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
id_ = self.id(index)
|
||||
self.column_color.mi = None
|
||||
|
||||
for k, fmt in self.db.prefs['column_color_rules']:
|
||||
for k, fmt in self.db.new_api.pref('column_color_rules', ()):
|
||||
if k == key:
|
||||
ccol = self.column_color(id_, key, fmt, self.db,
|
||||
self.color_cache, self.color_template_cache)
|
||||
@ -952,7 +952,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
|
||||
if self.color_row_fmt_cache is None:
|
||||
self.color_row_fmt_cache = tuple(fmt for key, fmt in
|
||||
self.db.prefs['column_color_rules'] if key == color_row_key)
|
||||
self.db.new_api.pref('column_color_rules', ()) if key == color_row_key)
|
||||
for fmt in self.color_row_fmt_cache:
|
||||
ccol = self.column_color(id_, color_row_key, fmt, self.db,
|
||||
self.color_cache, self.color_template_cache)
|
||||
@ -965,7 +965,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
default_icon = None
|
||||
if self.column_to_dc_decorator_map[col] is not None:
|
||||
default_icon = self.column_to_dc_decorator_map[index.column()](index.row())
|
||||
rules = self.db.prefs['column_icon_rules']
|
||||
rules = self.db.new_api.pref('column_icon_rules')
|
||||
if rules:
|
||||
key = self.column_map[col]
|
||||
id_ = None
|
||||
|
@ -760,7 +760,7 @@ class BooksView(QTableView): # {{{
|
||||
name += ' books view state'
|
||||
db = getattr(self.model(), 'db', None)
|
||||
if db is not None:
|
||||
ans = db.prefs.get(name, None)
|
||||
ans = db.new_api.pref(name)
|
||||
if ans is None:
|
||||
ans = gprefs.get(name, None)
|
||||
try:
|
||||
|
@ -119,7 +119,7 @@ class PinTableView(QTableView):
|
||||
def restore_state(self):
|
||||
db = getattr(self.model(), 'db', None)
|
||||
if db is not None:
|
||||
state = db.prefs.get('books view split pane state', None)
|
||||
state = db.new_api.pref('books view split pane state', None)
|
||||
if self.splitter is not None:
|
||||
self.splitter.restore_state()
|
||||
if state:
|
||||
|
@ -211,7 +211,7 @@ class ConditionEditor(QWidget): # {{{
|
||||
dt = m['datatype']
|
||||
if dt == 'bool':
|
||||
from calibre.gui2.ui import get_gui
|
||||
if not get_gui().current_db.prefs.get('bools_are_tristate'):
|
||||
if not get_gui().current_db.new_api.pref('bools_are_tristate'):
|
||||
dt = 'bool2'
|
||||
if dt in self.action_map:
|
||||
actions = self.action_map[dt]
|
||||
|
@ -170,7 +170,7 @@ class CreateVirtualLibrary(QDialog): # {{{
|
||||
|
||||
if editing:
|
||||
db = self.gui.current_db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
for dex,vl in enumerate(sorted(virt_libs.keys(), key=sort_key)):
|
||||
self.vl_name.addItem(vl, virt_libs.get(vl, ''))
|
||||
if vl == editing:
|
||||
@ -348,14 +348,14 @@ class SearchRestrictionMixin(object):
|
||||
self.search_restriction_list_built = False
|
||||
|
||||
def add_virtual_library(self, db, name, search):
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
virt_libs[name] = search
|
||||
db.new_api.set_pref('virtual_libraries', virt_libs)
|
||||
db.new_api.clear_search_caches()
|
||||
|
||||
def do_create_edit(self, name=None):
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
cd = CreateVirtualLibrary(self, virt_libs.keys(), editing=name)
|
||||
if cd.exec_() == cd.Accepted:
|
||||
if name:
|
||||
@ -371,7 +371,7 @@ class SearchRestrictionMixin(object):
|
||||
a = m.addAction(_('Create Virtual library'))
|
||||
a.triggered.connect(partial(self.do_create_edit, name=None))
|
||||
db = self.current_db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
|
||||
a = self.edit_menu
|
||||
self.build_virtual_library_list(a, self.do_create_edit)
|
||||
@ -437,7 +437,7 @@ class SearchRestrictionMixin(object):
|
||||
|
||||
def apply_virtual_library(self, library=None, update_tabs=True):
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
if not library:
|
||||
db.data.set_base_restriction('')
|
||||
db.data.set_base_restriction_name('')
|
||||
@ -475,7 +475,7 @@ class SearchRestrictionMixin(object):
|
||||
|
||||
def build_virtual_library_list(self, menu, handler):
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
menu.clear()
|
||||
menu.setIcon(self.empty)
|
||||
|
||||
@ -502,7 +502,7 @@ class SearchRestrictionMixin(object):
|
||||
def choose_vl_triggerred(self):
|
||||
from calibre.gui2.tweak_book.widgets import QuickOpen, emphasis_style
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
if not virt_libs:
|
||||
return error_dialog(self, _('No Virtual libraries'), _(
|
||||
'No Virtual libraries present, create some first'), show=True)
|
||||
@ -524,7 +524,7 @@ class SearchRestrictionMixin(object):
|
||||
|
||||
def _remove_vl(self, name, reapply=True):
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = db.new_api.pref('virtual_libraries', {})
|
||||
virt_libs.pop(name, None)
|
||||
db.new_api.set_pref('virtual_libraries', virt_libs)
|
||||
if reapply and db.data.get_base_restriction_name() == name:
|
||||
|
@ -400,7 +400,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
# Note that _get_category_nodes can indirectly change the
|
||||
# user_categories dict.
|
||||
data = self._get_category_nodes(config['sort_tags_by'])
|
||||
gst = self.db.prefs.get('grouped_search_terms', {})
|
||||
gst = self.db.new_api.pref('grouped_search_terms', {})
|
||||
|
||||
last_category_node = None
|
||||
category_node_map = {}
|
||||
@ -726,7 +726,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if result is None:
|
||||
result = not (
|
||||
key in ['authors', 'publisher', 'news', 'formats', 'rating'] or
|
||||
key not in self.db.prefs.get('categories_using_hierarchy', []) or
|
||||
key not in self.db.new_api.pref('categories_using_hierarchy', []) or
|
||||
config['sort_tags_by'] != 'name')
|
||||
self.hierarchical_categories[key] = result
|
||||
return result
|
||||
@ -867,7 +867,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
is_uc, dest_key, c)
|
||||
return copied
|
||||
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cats = self.db.new_api.pref('user_categories', {})
|
||||
path = None
|
||||
for s in src:
|
||||
src_parent, src_parent_is_gst = s[1:3]
|
||||
@ -929,7 +929,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
return False
|
||||
|
||||
def handle_user_category_drop(self, on_node, ids, column):
|
||||
categories = self.db.prefs.get('user_categories', {})
|
||||
categories = self.db.new_api.pref('user_categories', {})
|
||||
cat_contents = categories.get(on_node.category_key[1:], None)
|
||||
if cat_contents is None:
|
||||
return
|
||||
@ -1147,7 +1147,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
'renaming User categories'), show=True)
|
||||
return False
|
||||
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cats = self.db.new_api.pref('user_categories', {})
|
||||
user_cat_keys_lower = [icu_lower(k) for k in user_cats]
|
||||
ckey = item.category_key[1:]
|
||||
ckey_lower = icu_lower(ckey)
|
||||
@ -1250,7 +1250,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
item_category and rename them to new_name. The caller must arrange to
|
||||
redisplay the tree as appropriate.
|
||||
'''
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cats = self.db.new_api.pref('user_categories', {})
|
||||
for k in user_cats.keys():
|
||||
new_contents = []
|
||||
for tup in user_cats[k]:
|
||||
@ -1267,7 +1267,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
item_category and delete them. The caller must arrange to redisplay the
|
||||
tree as appropriate.
|
||||
'''
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cats = self.db.new_api.pref('user_categories', {})
|
||||
for cat in user_cats.keys():
|
||||
self.delete_item_from_user_category(cat, item_name, item_category,
|
||||
user_categories=user_cats)
|
||||
@ -1278,7 +1278,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if user_categories is not None:
|
||||
user_cats = user_categories
|
||||
else:
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cats = self.db.new_api.pref('user_categories', {})
|
||||
new_contents = []
|
||||
for tup in user_cats[category]:
|
||||
if tup[0] != item_name or tup[1] != item_category:
|
||||
|
@ -108,7 +108,7 @@ class TagBrowserMixin(object): # {{{
|
||||
opportunity to edit the name.
|
||||
'''
|
||||
db = self.library_view.model().db
|
||||
user_cats = db.prefs.get('user_categories', {})
|
||||
user_cats = db.new_api.pref('user_categories', {})
|
||||
|
||||
# Ensure that the temporary name we will use is not already there
|
||||
i = 0
|
||||
@ -157,7 +157,7 @@ class TagBrowserMixin(object): # {{{
|
||||
if category_name.startswith('@'):
|
||||
category_name = category_name[1:]
|
||||
db = self.library_view.model().db
|
||||
user_cats = db.prefs.get('user_categories', {})
|
||||
user_cats = db.new_api.pref('user_categories', {})
|
||||
cat_keys = sorted(user_cats.keys(), key=sort_key)
|
||||
has_children = False
|
||||
found = False
|
||||
@ -192,7 +192,7 @@ class TagBrowserMixin(object): # {{{
|
||||
if user_cat.startswith('@'):
|
||||
user_cat = user_cat[1:]
|
||||
db = self.library_view.model().db
|
||||
user_cats = db.prefs.get('user_categories', {})
|
||||
user_cats = db.new_api.pref('user_categories', {})
|
||||
if user_cat not in user_cats:
|
||||
error_dialog(self.tags_view, _('Remove category'),
|
||||
_('User category %s does not exist')%user_cat,
|
||||
@ -209,7 +209,7 @@ class TagBrowserMixin(object): # {{{
|
||||
dest_category. Any leading '@' is removed
|
||||
'''
|
||||
db = self.library_view.model().db
|
||||
user_cats = db.prefs.get('user_categories', {})
|
||||
user_cats = db.new_api.pref('user_categories', {})
|
||||
|
||||
if dest_category and dest_category.startswith('@'):
|
||||
dest_category = dest_category[1:]
|
||||
|
@ -785,7 +785,7 @@ class TagsView(QTreeView): # {{{
|
||||
# Always show the User categories editor
|
||||
self.context_menu.addSeparator()
|
||||
if key.startswith('@') and \
|
||||
key[1:] in self.db.prefs.get('user_categories', {}).keys():
|
||||
key[1:] in self.db.new_api.pref('user_categories', {}).keys():
|
||||
self.context_menu.addAction(_('Manage User categories'),
|
||||
partial(self.context_menu_handler, action='manage_categories',
|
||||
category=key[1:]))
|
||||
|
@ -373,8 +373,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.library_view.model().database_changed.connect(self.populate_tb_manage_menu, type=Qt.QueuedConnection)
|
||||
|
||||
# ######################## Search Restriction ##########################
|
||||
if db.prefs['virtual_lib_on_startup']:
|
||||
self.apply_virtual_library(db.prefs['virtual_lib_on_startup'])
|
||||
if db.new_api.pref('virtual_lib_on_startup'):
|
||||
self.apply_virtual_library(db.new_api.pref('virtual_lib_on_startup'))
|
||||
self.rebuild_vl_tabs()
|
||||
|
||||
# ########################## Cover Flow ################################
|
||||
@ -713,7 +713,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
try:
|
||||
olddb = self.library_view.model().db
|
||||
if copy_structure:
|
||||
default_prefs = olddb.prefs
|
||||
default_prefs = dict(olddb.prefs)
|
||||
except:
|
||||
olddb = None
|
||||
if copy_structure and olddb is not None and default_prefs is not None:
|
||||
@ -758,8 +758,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.set_window_title()
|
||||
self.apply_named_search_restriction('') # reset restriction to null
|
||||
self.saved_searches_changed(recount=False) # reload the search restrictions combo box
|
||||
if db.prefs['virtual_lib_on_startup']:
|
||||
self.apply_virtual_library(db.prefs['virtual_lib_on_startup'])
|
||||
if db.new_api.pref('virtual_lib_on_startup'):
|
||||
self.apply_virtual_library(db.new_api.pref('virtual_lib_on_startup'))
|
||||
self.rebuild_vl_tabs()
|
||||
for action in self.iactions.values():
|
||||
action.library_changed(db)
|
||||
|
@ -632,7 +632,7 @@ class CatalogBuilder(object):
|
||||
|
||||
# Handle condition where bools_are_tristate is False,
|
||||
# field is a bool and contents is None, which is displayed as No
|
||||
if (not self.db.prefs.get('bools_are_tristate') and
|
||||
if (not self.db.new_api.pref('bools_are_tristate') and
|
||||
self.db.metadata_for_field(rule['field'])['datatype'] == 'bool' and
|
||||
field_contents is None):
|
||||
field_contents = _('False')
|
||||
@ -1070,7 +1070,7 @@ class CatalogBuilder(object):
|
||||
|
||||
if self.DEBUG:
|
||||
if self.prefix_rules:
|
||||
self.opts.log.info(" Added prefixes (bools_are_tristate: {0}):".format(self.db.prefs.get('bools_are_tristate')))
|
||||
self.opts.log.info(" Added prefixes (bools_are_tristate: {0}):".format(self.db.new_api.pref('bools_are_tristate')))
|
||||
else:
|
||||
self.opts.log.info(" No added prefixes")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user