03-08-2011, 11:57 AM | #16 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
search_mark?
|
03-08-2011, 11:58 AM | #17 |
Calibre Plugins Developer
Posts: 4,644
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Yeah, full circle back to my first post in the thread.
The more I think about this the more I think highlighting is not the right approach for this plugin. The problem is that I am trying to highlight rows which need attention by the user. If they use the likes of the bulk metadata edit dialog to edit only a subset of the rows, they are going to lose their highlighted rows and have to run the plugin action again to see the rest. Plus either I select all the invalid rows for them which gives them no individual review or I only select the first which makes it a pain for them to select the rest. The custom column approach has some challenges of its own but perhaps is a bit more flexible/robust in this situation. EDIT: While I was typing you guys have come up with what sounds a nice solution to the "challenges" I had in mind... very cool. |
Advert | |
|
03-08-2011, 12:02 PM | #18 |
Grand Sorcerer
Posts: 11,773
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Major problem. The virtual column will not survive cache.refresh() because there is no data source.
This can be fixed at the cost of having refresh() call a function that checks for the presence of an ID in a set. Are we willing to pay that price? |
03-08-2011, 12:08 PM | #19 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Since the set will typically be empty, seems like it shouldn't be much overhead.
|
03-08-2011, 12:11 PM | #20 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Since the set will typically be empty, seems like it shouldn't be much overhead. We can optimize the case of an empty set so that it is only a single if statement per refresh call.
|
Advert | |
|
03-08-2011, 12:15 PM | #21 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In fact, if you are storing the ids in the set, then you dont actually need to test each id, instead iterate over the ids in the set and set the flag on each row manually, which is an O(1) operation per id
And I think "marked" is a better search term than "search_mark" |
03-08-2011, 12:15 PM | #22 | |
Grand Sorcerer
Posts: 11,773
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
As for the empty set, I am not convinced that an 'if foo: xxx' is much faster than 'if id in some_empty_set'. |
|
03-08-2011, 12:24 PM | #23 |
Calibre Plugins Developer
Posts: 4,644
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
For my own needs for this plugin a boolean column is fine. The mythical duplicate finder plugin will need a dedicated custom column and will likely want to be persisted across Calibre restarts. That's the only uses I personally have fwiw.
|
03-08-2011, 12:46 PM | #24 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Fine by me.
|
03-08-2011, 01:28 PM | #25 |
Grand Sorcerer
Posts: 11,773
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
After thought, I was bothered a bit by purposely limiting the value to bool, especially as it gains no performance. Looking up a key in a dict has the same performance as looking up a key in a set. Both are hashed in the same way.
What I am ready to commit: Setting API: db.set_marked_ids(ids) -- ids can be a list or dict. If a list, then a dict is constructed where {id:'true'} for all ids in the list. If it is a dict, then it is copied and checked to be sure that all the values are unicode. If ids == [] or {}, the right thing happens. The virtual column is set to the val if id is in the dict, otherwise None. Search API: marked:true -- finds anything set. If a list was passed to set_marked_ids, then it finds all the ids in that list. marked:false -- finds anything not set. marked:foobar -- if a dict was used, then this will find any book with value foobar. All the string matching search syntax can be used (equals, contains, regexp). Usage: 1) call db.set_marked_ids(...). 2) call gui.search_box.set_search_string('marked:...') where the ... is what you want. The user can, of course, make a saved search and then use that search as a restriction. There is no API to do these things. |
03-08-2011, 01:33 PM | #26 |
creator of calibre
Posts: 43,992
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Sounds fine
|
03-08-2011, 01:47 PM | #27 |
Calibre Plugins Developer
Posts: 4,644
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
|
03-08-2011, 02:10 PM | #28 |
Grand Sorcerer
Posts: 11,773
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Changes are now in trunk.
|
03-08-2011, 02:11 PM | #29 |
Grand Sorcerer
Posts: 11,773
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
03-08-2011, 02:20 PM | #30 |
Calibre Plugins Developer
Posts: 4,644
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Working brilliantly, plugin now finished for a release this weekend. Thanks for the additions.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] Clipboard Search | kiwidude | Plugins | 29 | 04-02-2024 10:05 PM |
[GUI Plugin] Search the Internet | kiwidude | Plugins | 433 | 04-01-2024 05:48 PM |
Fictionwise Browser Search Plugin | Zero9 | Deals and Resources (No Self-Promotion or Affiliate Links) | 17 | 07-27-2009 03:15 PM |
eReader.com Browser Search Plugin | Zero9 | Deals and Resources (No Self-Promotion or Affiliate Links) | 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 |