![]() |
#1531 | |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 451
Karma: 678910
Join Date: Dec 2017
Device: Kobo
|
Quote:
If this book matches the condition, the action will be performed on all selected books, even those that do not match and on which you did not want to perform this action. And I don't think a real filter feature would be possible, because Action Chains often uses the selected books to retrive the id to perform their own action, so it real not depending of Action Chains that the Calibre actions are all or nothing. A real filter feature would involve deselecting and selecting dynamically wich rows is needed before run the Calibre actions, then redo that at each step of the chain. ... I think it's possible (Calibre is powerfull like that), but it would be terribly complicated, so I will give it no hope. Last edited by un_pogaz; Today at 05:38 AM. |
|
![]() |
![]() |
![]() |
#1532 |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 451
Karma: 678910
Join Date: Dec 2017
Device: Kobo
|
Okay. By checking the code, I found a possible way.
`gui.current_view().get_selected_ids()` allow to retrive the book id of the selected row, and `gui.current_view().select_rows()` allow to select the book base on their id `class calibre.gui2.library.views.BooksView. Additionaly, using this two function allow to mimic and preserve the selection order. Beside @capink, get_selected_ids() it probably a better ways to retrive the book id than you current way. Damn it, if you had GitHub or similiar, I could work on proposing a patch, to either transform the condition on a true filter, or add a new filter feature. I'll see what I can do, but it won't be as clean to share you the full files like that. Last edited by un_pogaz; Today at 05:40 AM. |
![]() |
![]() |
![]() |
#1533 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,205
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
Quote:
The solution in the post even allows for saving the initial selection into a variable, so that you can restore them mid-chain if you want, and allow for more flexible control. |
||
![]() |
![]() |
![]() |
#1534 |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 451
Karma: 678910
Join Date: Dec 2017
Device: Kobo
|
Interesing, but I think that a formal implementation of a filter system would be a big plus, certainly with its own column/settings.
Also, if I understand your idea of wanting to dynamically display the menu entry based on simple condition criteria and so limit this to a single metadata object for performance reason, I think that inside the chains themselves, this is too confusive. It's certainly too late to replace this column with a proper filter setting, but in any case, I really encourage the addition of such thing. Else, I worked of the idea and so here my proposal: Spoiler:
|
![]() |
![]() |
![]() |
#1535 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,501
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
FWIW: I'm currently implementing these changes to the base formatter.
Code:
program: ids = selected_books(); col = selected_column(); res = ''; for id in ids: with id: # prints information from the book with identifier 'id' print($title, field(col)); res = (if res then res & ',' fi) & field(col); template('program: print("inside template", $title)') htiw rof; list_remove_duplicates(res, ',') EDIT: I'm also going to implement "show_in_dialog()" that renders an html string. Last edited by chaley; Today at 10:17 AM. |
![]() |
![]() |
![]() |
#1536 | |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 451
Karma: 678910
Join Date: Dec 2017
Device: Kobo
|
Quote:
Else, if retrive the seleted book ids is good, I think it would be much more useful to have a function 'search_books()' that use the search syntax. Code:
ids = search_books('series:"='&field('series')&'"') rlst = '' for id in ids: with id: rlst = rlst & character('newline') & $title htiw; rof; show_in_dialog(rlst) # show all the books in a series (this two function would also greatly benefit to have a optional argument virtual libray) Damn, it will make the GPM incredible powerfull, able to execute an return big data for a one of execution. Python template are great, but GPM is much simpler and enough for 90% of case, and the 'with' statement will make it a "complet" language in a some way. But now that I think about it, I don't think the template editor is designed for that kind use, since it executes the code at each edit... it would become a hell to creat such things. So in addition, I think it would be useful to add a new mode that only executes code on demand. Nevermind, their is the Breakpoints mode that already do that, Yes. (however, you must not select such stored template without the Breakpoints mode enable, else your cooked) Last edited by un_pogaz; Today at 02:50 PM. |
|
![]() |
![]() |
![]() |
#1537 | ||||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,501
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
ids = book_values('id', 'series:"=' & field('series') & '"', ',', '0') Quote:
Code:
ids = book_values('id', '', ',', '0') Quote:
Code:
ids = book_values(id, 'vl:foo', ',', '0') Quote:
NB: I'm also adding a way to execute the template tester where it doesn't run the template for all the selected books, ignoring all but the first book. This helps develop and use templates that iterate over selected ids, generating reports. |
||||
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Action Chains Resources | capink | Plugins | 78 | 08-05-2025 04:01 AM |
[Editor Plugin] Editor Chains | capink | Plugins | 106 | 06-17-2025 05:36 PM |
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 03:15 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 05:25 AM |