03-27-2023, 06:40 AM | #1 |
Zealot
Posts: 114
Karma: 34
Join Date: Jun 2015
Device: ipad & inkpad X
|
changing column type
I want to change a plugin which has a setting "reading status" which is set to "text".
I want to change this setting to "bool", "boolean", "yes/no". I tried any of this settings but none works. What is the right thing to get this done? Here is the relevant thing: (taken from koreader plugin) { 'name': 'column_status', 'label': 'Reading status column:', 'tooltip': 'A regular “text” column to store the reading status of the\n' 'book, as entered on the book status page (“Finished”,\n' '“Reading”, “On hold”).', 'type': 'text', (*1) 'sidecar_property': ['summary', 'status'], } (*1): Changed 'type': 'text', to 'type': 'bool', and the other above mentioned types. available_columns = { 'comments': self.get_custom_columns(['comments']), 'datetime': self.get_custom_columns(['datetime']), 'float': self.get_custom_columns(['float']), 'int': self.get_custom_columns(['int']), 'rating': self.get_rating_columns(), # Includes built-in 'text': self.get_custom_columns(['text']), 'bool': self.get_custom_columns(['bool']), (*2) } (*2): added this line with the different types as mentioned above. What types do i have for changing columns? Where is that documented? I didnt find anything in help/plugins or plugin API... |
03-27-2023, 08:18 AM | #2 | ||
Grand Sorcerer
Posts: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
As I said above, there is no API for changing column types because you can't do that. If you are looking for documentation of the API to prompt the user to create new columns, see CreateNewCustomColumn in src/calibre/gui2/preferences/create_custom_column.py. However, I think you already are looking at that. |
||
03-27-2023, 09:50 AM | #3 |
Zealot
Posts: 114
Karma: 34
Join Date: Jun 2015
Device: ipad & inkpad X
|
You didnt understand: I dont want to change the column, its type yes/no. I want to change the plugin! So what types do i have?
text, float, int, comments, datetime... Does exist a type bool and what is its name? See in preferences, custom column. The boolean is named yes/no. Whats its real name which i can use in my plugin? Oh, got it! Forgot to restart calibre. Its bool. Last edited by igorius; 03-27-2023 at 10:49 AM. |
03-27-2023, 10:17 AM | #4 | |
Grand Sorcerer
Posts: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
For the complete list of datatypes see calibre/library/field_metadata.py line 293: Code:
VALID_DATA_TYPES = frozenset([None, 'rating', 'text', 'comments', 'datetime', 'int', 'float', 'bool', 'series', 'composite', 'enumeration']) Code:
CUSTOM_DATA_TYPES = frozenset(('rating', 'text', 'comments', 'datetime', 'int', 'float', 'bool', 'series', 'composite', 'enumeration')) Code:
The datatype must be one of calibre's custom column types: 'bool', 'comments', 'composite', 'datetime', 'enumeration', 'float', 'int', 'rating', 'series', or 'text'. The datatype can't be changed in the dialog. Code:
column_types = dict(enumerate(( ... { 'datatype':'bool', # The column datatype 'text':_('Yes/No'), # The name used in the dialog's type dropdown 'is_multiple':False }, ... ))) Last edited by chaley; 03-27-2023 at 10:22 AM. Reason: Added a third source of datatypes |
|
04-01-2023, 10:46 AM | #5 | |
Guru
Posts: 908
Karma: 1171905
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
The problem is that the information is coming from the device as text (look at the red text above). So, you need to treat this in the 'action.py' file. Looking at the plugin's code, I would suggest changing the 'sync_to_calibre' method. Here is a possible solution: Original: Code:
def sync_to_calibre(self): ... keys_values_to_update[target] = value ... Code:
def sync_to_calibre(self): ... if value in ('Finished', 'Reading', 'On hold'): if value == 'Finished': value = True else: value = False keys_values_to_update[target] = value ... |
|
04-02-2023, 07:27 PM | #6 |
Custom User Title
Posts: 8,425
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Similar to this case:
I use Kobo Utilities, which stores the reading position in a column. This column is required to be of type 'text.' However, I'd like to use a longtext column (short title) which is 'comments'. (This is something I'd meant to ask about before davidfor left us ) By looking at the code, I think I can do this by changing several instances of 'text' to ''text, commenst'. dialogs.py, lines 927-929: Code:
def get_text_type_custom_columns(self): column_types = ['text'] return self.get_custom_columns(column_types) lines 357-365: Code:
CUSTOM_COLUMN_DEFAULTS = { CUSTOM_COLUMN_DEFAULT_LOOKUP_READING_LOCATION : { 'column_heading': _("Kobo Reading Location"), 'datatype' : 'text', 'description' : _("Kobo Reading location from the device."), 'columns_list' : 'avail_text_columns', 'config_label' : _('Current Reading Location Column:'), 'config_tool_tip' : _("Select a custom column to store the current reading location. The column type must be 'text'. Leave this blank if you do not want to store or restore the current reading location."), }, Code:
def get_text_custom_columns(self): column_types = ['text'] return self.get_custom_columns(column_types) The GetFileName plugin uses ['text','enumeration','custom','comments'] (what is custom?), which makes me think it should work. I have a few other small edits to my version of KU to add some extra fonts so would like to do this myself Last edited by ownedbycats; 04-02-2023 at 07:39 PM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing font type in viewer | rulet | Library Management | 1 | 07-15-2017 02:00 AM |
Using "Build column from other column" custom-column type | HFC3 | Library Management | 3 | 07-07-2013 03:11 AM |
Changing custom columns type? | Pepin33 | Calibre | 4 | 08-27-2012 08:44 PM |
Changing the partition type ? | rolgiati | Kindle Developer's Corner | 1 | 12-08-2011 09:39 PM |
Changing column type for reading queue | paulfiera | Calibre | 7 | 05-31-2011 01:10 PM |