|
|
#1 |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Displaying arbitrary results in search screen from plugin
So the plugin iterates through the data set and ends up with a bunch of calibre ids it wants to display in the library view. Is there a way to display these? It's a not dissimilar issue to the discussion we had on duplicate detection - except for that we think adding a custom column is appropriate in which case a normal search based on that column is possible. Is adding a custom column the only way to display arbitrary ids? |
|
|
|
|
|
#2 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
What should work today is library_view.select_rows(). This is not a search, but instead will highlight the rows in the view in the same fashion as search w/highlight search results. The user can use next and previous to move around in the highlighted set. This technique will not interfere with searching and restrictions.
'Searching' for a collection of arbitrary IDs would be more complicated. The problem is that searching is done by restricting the content of the cache (tied in with restrictions), which the GUI then treats as the library. Changing this processing is almost certainly not going to happen. I could imagine a special search syntax, something like 'ids:n,n,n,n,n,n,n,n,n', but this wouldn't be good if there are 1000s of them.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
Enthusiast
|
|
|
|
#3 |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Thanks Charles, I think it's time I tried that highlight feature you keep mentioning to see what it does for myself
.
|
|
|
|
|
|
#4 | |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Quote:
Code:
self.gui.search.clear() # As my code works across the whole library invalid_ids = [... build up my model ids...] self.gui.library_view.model().set_highlight_only(True) self.gui.library_view.select_rows(invalid_ids) Any suggestions as to what else I need to do? |
|
|
|
|
|
|
#5 |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Ok, this is working, I am sure someone can slap me around if there is a better approach:
Code:
model = self.gui.library_view.model()
model.ids_to_highlight = invalid_ids
model.ids_to_highlight_set = set(invalid_ids)
model.current_highlighted_idx = 0
self.gui.library_view.select_rows(invalid_ids[:1])
|
|
|
|
|
|
#6 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
I am not happy about you needing to reach inside the model like that. I can provide an API to do the 'right' way. However, before I do that, is the highlighting solution adequate?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#7 |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Thought you might want to wrap it up
![]() In a perfect world I think I would still prefer a way of limiting the view to just the invalid ids, but I can appreciate as per your initial response this isn't something easily possible currently. The disadvantage of the highlighting approach is that it requires leaving the view in "highlight mode" while the user works through those rows, and then they need to perform an action to get back out of it and return to normal searching. I've got a keyboard shortcut in my plugin to toggle turning highlight mode on/off. However there is no visible indication in the main gui as to whether you are in highlight mode or not (you have to drill into the search preferences dialog) so that is a little icky. I think as a user I might have preferred the checkbox (or a toggle button) on next to the search box as it used to be as it least you could see what "mode" you currently are in. With that all said, as you have the N/shift-N keyboard shortcuts to work through the results it functionally does the job. It just isn't quite as nice imho as limiting the set of rows to just the ones you are interested in rather than jumping all around the results, particularly since there is no way to sort to show the highlighted rows at the top. |
|
|
|
|
|
#8 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
I don't understand. I have a prototype in model() that sets the highlighted rows. They get highlighted. I am not required to turn highlight mode on or off. Are you sure that you need to change the toggle?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#9 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
How many rows are we talking about here? Tens, or tens of thousands?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#10 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
If you could try this before I submit to Kovid, that would be useful.
Add in gui2.library.models.py at line 280, just before 'search(...) Code:
def highlight_ids(self, ids_to_highlight):
self.ids_to_highlight = ids_to_highlight
self.ids_to_highlight_set = set(self.ids_to_highlight)
if self.ids_to_highlight:
self.current_highlighted_idx = 0
else:
self.current_highlighted_idx = None
self.reset()
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
#11 | |
|
calibre/Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,087
Karma: 1211084
Join Date: Oct 2010
Location: London, UK
Device: Kindle 3 3G, iPad 2, iPad 3
|
Quote:
In terms of rows, it could be thousands, it could be a handful. Really depends on the state of the users library ![]() Perhaps it is possible to supply some custom sorting to the view with a delegate to display the highlighted rows at the top (in my case I just want to test for presence in the highlighted set)? |
|
|
|
|
|
|
#12 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
It really sounds like you should create a (hidden?) custom column, fill that in how you want, then set a search restriction to select rows with appropriate values in the column. That would do everything you have described, including permitting sub-searching.
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
|
|
#13 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,486
Karma: 2944574
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It may be worth using the (currently unused) flags column for this kind of thing. We could provide an API to set the value for it and then have a true false search on it. That way every use would not require a separate custom column.
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
|
#14 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,486
Karma: 2944574
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In fact there's no need to use the actual column, we could create a virtual column in meta2. This would not persist between calibre restarts, but I see that as a plus.
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
|
#15 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
|
Quote:
That should work easily enough. I will give it a try. What column name would you like to see in field_metadata?
__________________
Support calibre developers at no cost to you by using calibre's get books feature. Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre charles.haleys.org/calibre |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [GUI Plugin] Search the Internet | kiwidude | Plugins | 195 | 03-29-2013 01:15 AM |
| [GUI Plugin] Clipboard Search | kiwidude | Plugins | 4 | 09-11-2011 06:14 AM |
| Fictionwise Browser Search Plugin | Zero9 | Deals, Freebies, and Resources (No Self-Promotion) | 17 | 07-27-2009 03:15 PM |
| eReader.com Browser Search Plugin | Zero9 | Deals, Freebies, and Resources (No Self-Promotion) | 0 | 07-24-2009 09:44 PM |
| Snap.com - new search engine with sortable results | Colin Dunstan | Lounge | 1 | 10-06-2004 06:50 AM |