Fix display or custom columns of type rating in Tag Browser

This commit is contained in:
Kovid Goyal 2010-05-03 21:03:09 -06:00
parent d6bf59d83f
commit c1fd349e10
4 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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'):