Merge stuff in user categories with same name.
#1  silentguy 02-26-2011, 06:00 AM
In light of the new grouped search user categories and hierarchical tag browser, I was looking into merging stuff in the Tag browser.
e.g. I have a combined search for "series,#series2,tags" and items with the tag "Star Trek.DS9", the series "Star Trek.DS9.Relaunch [8]" and the #series2 "Star Trek.DS9.Mission Gamma [1]". This currently leades to three "Star Trek" in the tag browser, and each one will search it's origin category.

My first thought was to start with modifying the search generated in tag_view - tokens to just search the grouped search if possible and then as a second step try to figure out how to merge the entries in the tag browser. I Expected the first one to be easy as the tooltip of the items already displays the proper user category, but it turned out more difficult then I thought. Am I seeing this right that he just reuses the same object in the user category and in the actual category?

So I guess I would have to clone/recreate the object while merging them. Seems more difficult then I thought. Could someone give me some pointers where the user category tree is actually build?

Or am I trying something that will turn our really really complex? Now that I think about it, it might break some stuff that I never use. e.g. drag-n-drop on a merged entry would not be defined. Darn, it sounded to easy in my head.

#2  chaley 02-26-2011, 07:02 AM
You are correct, wherever possible, calibre uses the same 'Tag' object when placing the same tag in the TreeView. This permits several things, the most important being sharing of search state.

My understanding is that you want the item in the global-search-term (GST) user category not to be an instance of the tag, but instead be an instance of something like a search term. Although I wouldn't want it to behave this way, I can see why you would.

There are two ways to accomplish this.

1) The best would be two build the category information the way you want. The list of tags used in a category is built in library.database2.get_categories. There is a block of code there that constructs a temporary user category by merging all items from the 'real' categories into the new category. The block of code after that builds the category tag structures for all user categories, including this temporary one. You would change that code to:2) Rewrite the search category when the search is emitted. This way would leave the duplicates in the list, but would emit @GST_Name:val instead of the original_category_name:val. To do this, you:Neither way is particularly difficult. That said, I am sure that there are corner cases with both of them.

Today's Posts | Search this Thread | Login | Register