I just "discovered" a use for a Calibre feature today ("Manage User Categories) to allow me to build various "lists" such as favourite authors etc, all very cool!

However I think the feature could be improved if you did not have to always go into the manage dialog to add to a user category. When you have a large database it is a bit painful to scroll up/down the list to find an author etc, plus it as not as convenient as a right-click on your library view could be.

So I started playing with the source code and have a very simple working implementation with the user category hard-coded (i.e. works for me, if no-one else cares/wants it then no problem). However I could submit the changes as a patch if it was developed a bit further.

There are various ways the context menu could be structured. From a user perspective I think the simplest to use (least clicks) would be for the user category name to appear as a sub-menu a bit like this:

However that would seem to require that every time a context menu is built to get the user category names via either
(1.1) interrogate the database, or
(1.2) interrogate a cache, or
(1.3) interrogate a tweak option value

Option (1.1) is likely undesired for performance reasons, and option (1.3) might be considered too complex for users and prone to becoming out of date as users add/remove categories in the tag viewer. I would need some guidance to implement option (1.2) and also the issue with caches is of course knowing all the places they need to be refreshed.

The alternative approach is to force the user through a popup dialog. Personally I hate popups where they can be avoided, but I can accept that in this situation if the above is unacceptable/undesired then it seems the only alternative. So the menu could look like this:

The dialog that appears could be one of two implementations I can think of:
(2.1) A simple popup list where the user chooses a category to add to (like remove format dialog), or
(2.2) Re-use the existing Manage User categories dialog

I would prefer option (2.1) here as a user I think though more work to code it. Option (2.2) would be possible by butchering the existing code a bit. For instance when the dialog is in this 'mode' rather than displaying "all" authors/tags/publishers etc on the LHS you restrict it to just data from the selected row(s). However the user would still need to first select the category, then select all the values on the LHS and the button to add them to your category. Lots more clicks, and more clicks suck imho.

Anyone have any thoughts on this? Would love to see the feature or really not bothered? Guidance would be appreciated if someone would like to see it as a patch, or else it will just stay forever in my local copy of Calibre...

I think what you are asking for is called "Saved Searches" (upper right)

Once made, you can use them as implied or to Restrict view: which allows you to still search within the restricted view.
Management can be done in the Tag view window

I will confess I haven't found a use yet for saved searches. I don't actually want to restrict my view of the library in normal day to day usage when I am adding new books and editing metadata. When you are trying to ensure no duplicates etc you can't use a restricted view.

What I do want to do is be able to build lists of series or authors that I intend to "revisit" in future. There is no meaningful "subset" that I could restrict my view to which reduces the authors down to a manageable level, given my favourite authors list for instance could include any one of them?

I understand I "could" construct my lists as a saved search by building monstrous "or" expressions, however this is pretty nasty to maintain and I think the "user categories" feature is better suited? Or am I missing something?

What I do want to do is be able to build lists of series or authors that I intend to "revisit" in future.

Why not just tag the books for that author "FavoriteAuthor" then search for that tag or tag the books "FavoriteSeries" and then search for that tag (and save the search)? I tag with "ToRead" to indicate it's a specific book I want to read (later), but you can do it at the series or author level, instead of at the book level, if you prefer.

Why not just tag the books for that author "FavoriteAuthor" then search for that tag or tag the books "FavoriteSeries" and then search for that tag (and save the search)? I tag with "ToRead" to indicate it's a specific book I want to read (later), but you can do it at the series or author level, instead of at the book level, if you prefer.

I've tried that tag approach for this but to be honest I just don't like it for this purpose. Absolutely I use a "Read" type tag if I spot an individual book that I want to highlight. However there are times where you want to work at a "level higher" than "per book" level which is the issue with tags. For instance if I want to read a series that has 20 books in it, either you have to remember to apply that tag to every book (and any new ones in the series you add over time), or you apply it to the first one and then do extra search steps to get all the books in that series when it comes time to make use of it.

Similarly I am still trying to consolidate my various book collections into Calibre and are working through author by author to update metadata, resolve duplicates, find better formats, create wishlist books for missing entries etc. So I am recording per author that I am "done" with them. I was doing this in a spreadsheet, but instead adding these to a user category list will work better than adding yet more tags across every book?

I think the tag viewer works well when you have a relatively small subset, which user categories allows you to make, and lets me drill into stuff with just a couple of clicks rather than typing search queries and sorting/scrolling through results to drill down to the same effect.

Excellent, thanks for the heads up Kovid. I wasn't sure where field_metadata fit into the picture until I found that tag_view.py rebuilds the list of user categories in field_metadata when it's model is refreshed. Sound just what I was after, thanks.

Excellent, thanks for the heads up Kovid. I wasn't sure where field_metadata fit into the picture until I found that tag_view.py rebuilds the list of user categories in field_metadata when it's model is refreshed. Sound just what I was after, thanks.

Ok, discovered a fly in the ointment but perhaps you know a workaround. It seems the context menus are only built once at application startup, rather than every time you right-click.

Problem (1) is that means if you add a new user category you won't see it in the menu until you restart. Not the end of the world given how rare you would add new ones.

However the bigger problem (2) is that it "appears" that in the genesis method of the user action I don't have access to the model? I've tried a number of permutations such as self.model(), self.gui.model(), self.gui.library_view.model() but keep getting hit with AttributeError:'xxx' object has no attribute 'model'.

I would presume that the model has not been initialised at the time the menus are created? Is there a plan B or is this approach scuppered? Apologies for being dense.

I've tried that tag approach for this but to be honest I just don't like it for this purpose. ...

Lots of ways to skin the cat, one of the great features of Calibre

Having thought about it a bit, I can see where you are going with the right click and assignment of selected items to user categories. It looks useful, and Kovid's leads should help you on your way. I'd encourage you to submit it as a patch.

To be sure I understand, you would select books, then you would right click, choose "Add to user category" which would expand to list all the created user categories , and you would choose one of the user categories, which would then expand to show these options: "Selected authors" or ... or "Selected series" or Selected Tags"?

Behind the scenes, all the authors in all the selected books would be assigned to the selected user category if you chose "Selected authors"?

Would you assign all the tags on all the selected books if you chose "Selected Tags"?

Starson17 - yes that is exactly the behaviour. Depending on the sub-menu you select I build a unique list of authors/tags/series/publishers from the rows selected. Any that don't already exist in the user category are then added to it. As mentioned above the one minor issue is that you have to restart Calibre to get new user categories to appear in the menu but that is no big deal once you know that.

I've attached a screenshot, and probably tomorrow submit it in a day or two as a patch in case anything else comes up or other suggestions arise.

Just curious, if someone hasn't created any "User categories" what will they see when they hover over the "Add to user category" menu?

The top level menu item is disabled in that situation currently. I considered it having a disabled sub-menu item saying something like "No user categories defined" or similar but perhaps that's a little non-standard?

Looking at the screenshot, the top level talks about "Favourite Auth" but then point to Authors, Series, etc. Perhaps the nintermediate level should just be "Favourites" and "Processed" as it does not seem to be limited to Authors?

Let us know when the patch is available - I would be interested in downloading it and seeing how it works in more detail.