mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 19:54:20 +02:00
Add method to edit custom column metadata
This commit is contained in:
parent
bc4e4e23d9
commit
d8f3c0605d
1 changed files with 31 additions and 0 deletions
|
|
@ -178,6 +178,37 @@ def delete_custom_column(self, label=None, num=None):
|
|||
(data['num'],))
|
||||
self.conn.commit()
|
||||
|
||||
def set_custom_column_metadata(self, num, name=None, label=None,
|
||||
is_editable=None, display=None):
|
||||
changed = False
|
||||
if name is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET name=? WHERE id=?',
|
||||
(name, num))
|
||||
self.custom_column_num_map[num]['name'] = name
|
||||
changed = True
|
||||
if label is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET label=? WHERE id=?',
|
||||
(label, num))
|
||||
self.custom_column_num_map[num]['label'] = label
|
||||
self.custom_column_label_map[label] = self.custom_column_num_map[num]
|
||||
changed = True
|
||||
if is_editable is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET is_editable=? WHERE id=?',
|
||||
(bool(is_editable), num))
|
||||
self.custom_column_num_map[num]['is_editable'] = bool(is_editable)
|
||||
changed = True
|
||||
if display is not None:
|
||||
self.conn.execute('UPDATE custom_columns SET display=? WHERE id=?',
|
||||
(json.dumps(display), num))
|
||||
self.custom_column_num_map[num]['display'] = display
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
self.conn.commit()
|
||||
return changed
|
||||
|
||||
|
||||
|
||||
def set_custom(self, id_, val, label=None, num=None, append=False, notify=True):
|
||||
if label is not None:
|
||||
data = self.custom_column_label_map[label]
|
||||
|
|
|
|||
Loading…
Reference in a new issue