View Single Post
Old 01-04-2022, 04:06 PM   #781
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,199
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by compurandom View Post
I'm looking for a more selective selection.
Something like given this search and sort, select variations of:
  • The first 10 items
  • The 10 items after an offset
  • a random 10 items
  • everything except the first 10 items
You can write a custom action that does what you want. To select books based on book_ids you can use:

Code:
books_ids = [1,2,3]
gui.library_view.select_rows(book_ids)
To get the currently selected books ids:

Code:
rows = gui.current_view().selectionModel().selectedRows()
book_ids = [ gui.library_view.model().db.id(row.row()) for row in rows ]
To get the book_ids for the first 10 books in the current library view:
Code:
book_ids = [gui.library_view.model().id(x) for x in range(0, 10)]

Last edited by capink; 01-06-2022 at 05:42 PM.
capink is offline   Reply With Quote