View Single Post
Old 04-11-2012, 12:16 AM   #3
idea00
Junior Member
idea00 will become famous soon enoughidea00 will become famous soon enoughidea00 will become famous soon enoughidea00 will become famous soon enoughidea00 will become famous soon enoughidea00 will become famous soon enough
 
Posts: 7
Karma: 684
Join Date: Apr 2012
Device: android
Quote:
Originally Posted by kovidgoyal View Post
Backwards compatibility:

You cannot remove the sr?_replace options. calibre saves previously used conversion settings. Your change would render the saved settings useless. Instead leave them be and add another option. Have the GUI use the new option for new conversions, pre-populating it with the values from the sr? options, if they exist. In the case where values exist for both, ignore the old ones.
I need a bit of help with this as I do not entirely understand how options are handled.
As far as I've gathered the options in the UI are somehow connected to the OptionRecomendations in plumber.py using the functions get_value and set_value in the class Widget (gui2\convert\__init__.py)
I added support for handling QTableWidget widgets to this class and named my table opt_search_replace so it matches the option name (search_replace)

In order to support sr?_search/sr?_replace options I'd either need dummy widgets or would have to use a different mechanism than the one used in the original search_and_replace.py. Can you point me in the right direction for this?

Quote:
Originally Posted by kovidgoyal View Post
UI

Why not use both the explicitly added expressions and the values in the textboxes, if they exist.
That's the less intuitive option, it means if a user just messes around with search/replace and decides not to use it, he now needs to delete the regex from the RegexEdit widget not just remove everything from the table.


Quote:
Originally Posted by kovidgoyal View Post
CLI

How are you serializing multiple expressions on a single command line option?
Forgot to ask about this.
I use json.
Widget.get_value gets the text values of the table into a list (of lists) and json encodes it.Widget.set_value reverses the process.
The save and load load functions use the same functions to serialize/deserialize the search/replace definitions into a file.
A bit ugly but less computationally intensive than dynamically generating search and replace options. The original approach of using two options for what is in essence a single function was uglier still as one could potentially disable just a replace option without disabling the matching search option.
The best approach would be for options to support lists natively not just numbers and strings, but I have not yet deciphered how to do it or know the implications of such a change.
idea00 is offline   Reply With Quote