mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Walk tree to get category data.
This commit is contained in:
parent
7a69120f4f
commit
5383af193f
@ -500,6 +500,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
if i < len(components)-1:
|
if i < len(components)-1:
|
||||||
t = copy.copy(tag)
|
t = copy.copy(tag)
|
||||||
t.original_name = '.'.join(components[:i+1])
|
t.original_name = '.'.join(components[:i+1])
|
||||||
|
t.count = 0
|
||||||
if key != 'search':
|
if key != 'search':
|
||||||
# This 'manufactured' intermediate node can
|
# This 'manufactured' intermediate node can
|
||||||
# be searched, but cannot be edited.
|
# be searched, but cannot be edited.
|
||||||
@ -524,6 +525,12 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
for category in self.category_nodes:
|
for category in self.category_nodes:
|
||||||
process_one_node(category, state_map.get(category.category_key, {}))
|
process_one_node(category, state_map.get(category.category_key, {}))
|
||||||
|
|
||||||
|
def get_category_editor_data(self, category):
|
||||||
|
for cat in self.root_item.children:
|
||||||
|
if cat.category_key == category:
|
||||||
|
return [(t.tag.id, t.tag.original_name, t.tag.count)
|
||||||
|
for t in cat.child_tags() if t.tag.count > 0]
|
||||||
|
|
||||||
# Drag'n Drop {{{
|
# Drag'n Drop {{{
|
||||||
def mimeTypes(self):
|
def mimeTypes(self):
|
||||||
return ["application/calibre+from_library",
|
return ["application/calibre+from_library",
|
||||||
|
@ -196,11 +196,10 @@ class TagBrowserMixin(object): # {{{
|
|||||||
Open the 'manage_X' dialog where X == category. If tag is not None, the
|
Open the 'manage_X' dialog where X == category. If tag is not None, the
|
||||||
dialog will position the editor on that item.
|
dialog will position the editor on that item.
|
||||||
'''
|
'''
|
||||||
db=self.library_view.model().db
|
|
||||||
cats = db.get_categories(sort='name', icon_map=None)
|
tags_model = self.tags_view.model()
|
||||||
if category in cats:
|
result = tags_model.get_category_editor_data(category)
|
||||||
result = [(t.id, t.name, t.count) for t in cats[category]]
|
if result is None:
|
||||||
else:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if category == 'series':
|
if category == 'series':
|
||||||
@ -208,6 +207,7 @@ class TagBrowserMixin(object): # {{{
|
|||||||
else:
|
else:
|
||||||
key = sort_key
|
key = sort_key
|
||||||
|
|
||||||
|
db=self.library_view.model().db
|
||||||
d = TagListEditor(self, cat_name=db.field_metadata[category]['name'],
|
d = TagListEditor(self, cat_name=db.field_metadata[category]['name'],
|
||||||
tag_to_match=tag, data=result, sorter=key)
|
tag_to_match=tag, data=result, sorter=key)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user