This commit is contained in:
Kovid Goyal 2011-02-23 08:00:34 -07:00
commit afbf4a4b51
2 changed files with 29 additions and 7 deletions

View File

@ -898,11 +898,12 @@ class TagsModel(QAbstractItemModel): # {{{
if cat_len <= 0:
return ((collapse_letter, collapse_letter_sk))
fm = self.db.field_metadata[key]
clear_rating = True if key not in self.categories_with_ratings and \
not self.db.field_metadata[key]['is_custom'] and \
not self.db.field_metadata[key]['kind'] == 'user' \
not fm['is_custom'] and \
not fm['kind'] == 'user' \
else False
tt = key if self.db.field_metadata[key]['kind'] == 'user' else None
tt = key if fm['kind'] == 'user' else None
for idx,tag in enumerate(data[key]):
if clear_rating:
tag.avg_rating = None
@ -949,9 +950,11 @@ class TagsModel(QAbstractItemModel): # {{{
node_parent = category
components = [t for t in tag.name.split('.')]
if key not in self.db.prefs.get('categories_using_hierarchy', []) \
or len(components) == 1 or \
self.db.field_metadata[key]['kind'] == 'user':
if key in ['authors', 'publisher', 'news', 'formats'] or \
key not in self.db.prefs.get('categories_using_hierarchy', []) or\
len(components) == 1 or \
fm['kind'] == 'user' or \
fm['datatype'] not in ['text', 'series', 'enumeration']:
self.beginInsertRows(category_index, 999999, 1)
TagTreeItem(parent=node_parent, data=tag, tooltip=tt,
icon_map=self.icon_state_map)
@ -1384,13 +1387,25 @@ class TagBrowserMixin(object): # {{{
def do_add_subcategory(self, on_category=None):
db = self.library_view.model().db
user_cats = db.prefs.get('user_categories', {})
new_cat = on_category[1:] + '.' + _('New Category').replace('.', '')
# Ensure that the temporary name we will use is not already there
i = 0
new_name = _('New Category').replace('.', '')
n = new_name
while True:
new_cat = on_category[1:] + '.' + n
if new_cat not in user_cats:
break
i += 1
n = new_name + unicode(i)
# Add the new category
user_cats[new_cat] = []
db.prefs.set('user_categories', user_cats)
self.tags_view.set_new_model()
m = self.tags_view.model()
idx = m.index_for_path(m.find_category_node('@' + new_cat))
m.show_item_at_index(idx)
# Open the editor on the new item to rename it
self.tags_view.edit(idx)
def do_user_categories_edit(self, on_category=None):

View File

@ -425,6 +425,13 @@ There is a search bar at the top of the Tag Browser that allows you to easily fi
For convenience, you can drag and drop books from the book list to items in the Tag Browser and that item will be automatically applied to the dropped books. For example, dragging a book to Isaac Asimov will set the author of that book to Isaac Asimov or dragging it to the tag History will add the tag History to its tags.
The outer-level items in the tag browser such as Authors and Series are called categories. You can create your own categories, called User Categories, which are useful for organizing items. For example, you can use the user categories editor (push the Manage User Categories button) to create a user category called Favorite Authors, then put the items for your favorites into the category. User categories act like built-in categories; you can click on items to search for them. You can search for all items in a category by right-clicking on the category name and choosing "Search for books in ...".
User categories can have sub-categories. For example, the user category Favorites.Authors is a sub-category of Favorites. You might also have Favorites.Series, in which case there will be two sub-categories under Favorites. Sub-categories can be created using Manage User Categories by entering names like the Favorites example. They can also be created by right-clicking on a user category, choosing "Add sub-category to ...", and entering the category name.
It is also possible to create hierarchies inside some of the built-in categories (the text categories). These hierarchies show with the small triangle permitting the sub-items to be hidden. To use hierarchies in a category, you must first go to Preferences / Look & Feel and enter the category name(s) into the "Categories with hierarchical items" box. Once this is done, items in that category that contain periods will be shown using the small triangle. For example, assume you create a custom column called "Genre" and indicate that it contains hierarchical items. Once done, items such as Mystery.Thriller and Mystery.English will display as Mystery with the small triangle next to it. Clicking on the triangle will show Thriller and English as sub-items.
Jobs
-----
.. image:: images/jobs.png