mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
0c0224f9d9
@ -356,10 +356,11 @@ class TagsView(QTreeView): # {{{
|
|||||||
|
|
||||||
# Always show the user categories editor
|
# Always show the user categories editor
|
||||||
self.context_menu.addSeparator()
|
self.context_menu.addSeparator()
|
||||||
if category in self.db.prefs.get('user_categories', {}).keys():
|
if key.startswith('@') and \
|
||||||
|
key[1:] in self.db.prefs.get('user_categories', {}).keys():
|
||||||
self.context_menu.addAction(_('Manage User Categories'),
|
self.context_menu.addAction(_('Manage User Categories'),
|
||||||
partial(self.context_menu_handler, action='manage_categories',
|
partial(self.context_menu_handler, action='manage_categories',
|
||||||
category=category))
|
category=key[1:]))
|
||||||
else:
|
else:
|
||||||
self.context_menu.addAction(_('Manage User Categories'),
|
self.context_menu.addAction(_('Manage User Categories'),
|
||||||
partial(self.context_menu_handler, action='manage_categories',
|
partial(self.context_menu_handler, action='manage_categories',
|
||||||
@ -727,15 +728,21 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
if s[0] != TagTreeItem.TAG:
|
if s[0] != TagTreeItem.TAG:
|
||||||
return False
|
return False
|
||||||
user_cats = self.db.prefs.get('user_categories', {})
|
user_cats = self.db.prefs.get('user_categories', {})
|
||||||
|
parent_node = None
|
||||||
for s in src:
|
for s in src:
|
||||||
src_parent, src_name, src_cat = s[1:4]
|
src_parent, src_name, src_cat = s[1:4]
|
||||||
|
parent_node = src_parent
|
||||||
|
if src_parent.startswith('@'):
|
||||||
|
is_uc = True
|
||||||
src_parent = src_parent[1:]
|
src_parent = src_parent[1:]
|
||||||
|
else:
|
||||||
|
is_uc = False
|
||||||
dest_key = dest.category_key[1:]
|
dest_key = dest.category_key[1:]
|
||||||
if dest_key not in user_cats:
|
if dest_key not in user_cats:
|
||||||
continue
|
continue
|
||||||
new_cat = []
|
new_cat = []
|
||||||
# delete the item if the source is a user category and action is move
|
# delete the item if the source is a user category and action is move
|
||||||
if src_parent in user_cats and action == Qt.MoveAction:
|
if is_uc and src_parent in user_cats and action == Qt.MoveAction:
|
||||||
for tup in user_cats[src_parent]:
|
for tup in user_cats[src_parent]:
|
||||||
if src_name == tup[0] and src_cat == tup[1]:
|
if src_name == tup[0] and src_cat == tup[1]:
|
||||||
continue
|
continue
|
||||||
@ -743,6 +750,8 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
user_cats[src_parent] = new_cat
|
user_cats[src_parent] = new_cat
|
||||||
# Now add the item to the destination user category
|
# Now add the item to the destination user category
|
||||||
add_it = True
|
add_it = True
|
||||||
|
if not is_uc and src_cat == 'news':
|
||||||
|
src_cat = 'tags'
|
||||||
for tup in user_cats[dest_key]:
|
for tup in user_cats[dest_key]:
|
||||||
if src_name == tup[0] and src_cat == tup[1]:
|
if src_name == tup[0] and src_cat == tup[1]:
|
||||||
add_it = False
|
add_it = False
|
||||||
@ -750,9 +759,10 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
user_cats[dest_key].append([src_name, src_cat, 0])
|
user_cats[dest_key].append([src_name, src_cat, 0])
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.prefs.set('user_categories', user_cats)
|
||||||
self.tags_view.set_new_model()
|
self.tags_view.set_new_model()
|
||||||
|
if parent_node is not None:
|
||||||
# Must work with the new model here
|
# Must work with the new model here
|
||||||
m = self.tags_view.model()
|
m = self.tags_view.model()
|
||||||
path = m.find_category_node('@' + src_parent)
|
path = m.find_category_node(parent_node)
|
||||||
idx = m.index_for_path(path)
|
idx = m.index_for_path(path)
|
||||||
self.tags_view.setExpanded(idx, True)
|
self.tags_view.setExpanded(idx, True)
|
||||||
m.show_item_at_index(idx)
|
m.show_item_at_index(idx)
|
||||||
|
@ -426,6 +426,8 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
if l > 0:
|
if l > 0:
|
||||||
alt_loc = location[0:l]
|
alt_loc = location[0:l]
|
||||||
alt_item = location[l+1:]
|
alt_item = location[l+1:]
|
||||||
|
else:
|
||||||
|
alt_loc = None
|
||||||
for key in user_cats:
|
for key in user_cats:
|
||||||
if key == location or key.startswith(location + '.'):
|
if key == location or key.startswith(location + '.'):
|
||||||
for (item, category, ign) in user_cats[key]:
|
for (item, category, ign) in user_cats[key]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user