mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix display or custom columns of type rating in Tag Browser
This commit is contained in:
parent
d6bf59d83f
commit
c1fd349e10
@ -184,11 +184,14 @@ class MessageBox(QMessageBox):
|
||||
|
||||
|
||||
|
||||
def warning_dialog(parent, title, msg, det_msg='', show=False):
|
||||
def warning_dialog(parent, title, msg, det_msg='', show=False,
|
||||
show_copy_button=True):
|
||||
d = MessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
|
||||
parent, det_msg)
|
||||
d.setEscapeButton(QMessageBox.Ok)
|
||||
d.setIconPixmap(QPixmap(I('dialog_warning.svg')))
|
||||
if not show_copy_button:
|
||||
d.cb.setVisible(False)
|
||||
if show:
|
||||
return d.exec_()
|
||||
return d
|
||||
|
@ -831,7 +831,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
warning_dialog(self, _('Must restart'),
|
||||
_('The changes you made require that Calibre be '
|
||||
'restarted. Please restart as soon as practical.'),
|
||||
show=True)
|
||||
show=True, show_copy_button=False)
|
||||
self.parent.must_restart_before_config = True
|
||||
QDialog.accept(self)
|
||||
|
||||
|
@ -145,6 +145,8 @@ class CustomColumns(object):
|
||||
if v['normalized']:
|
||||
tn = 'custom_column_{0}'.format(i)
|
||||
self.tag_browser_categories[tn] = [v['label'], 'value']
|
||||
if v['datatype'] == 'rating':
|
||||
self.tag_browser_formatters[tn] = lambda x:u'\u2605'*int(round(x/2.))
|
||||
|
||||
|
||||
def get_custom(self, idx, label=None, num=None, index_is_id=False):
|
||||
|
@ -127,6 +127,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
'authors' : ['author', 'name'],
|
||||
'news' : ['news', 'name'],
|
||||
}
|
||||
self.tag_browser_formatters = {}
|
||||
|
||||
self.connect()
|
||||
self.is_case_sensitive = not iswindows and not isosx and \
|
||||
@ -632,7 +633,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
else:
|
||||
icon = icon_map['*custom']
|
||||
tooltip = self.custom_column_label_map[category]['name']
|
||||
categories[category] = [Tag(r[1], count=r[2], id=r[0], icon=icon, tooltip = tooltip)
|
||||
formatter = self.tag_browser_formatters.get(tn, lambda x: x)
|
||||
categories[category] = [Tag(formatter(r[1]), count=r[2], id=r[0], icon=icon, tooltip = tooltip)
|
||||
for r in data if r[2] > 0]
|
||||
categories['format'] = []
|
||||
for fmt in self.conn.get('SELECT DISTINCT format FROM data'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user