mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fixes #1968559 [Enhancement Request: Tooltips on 'show checkmarks' columns](https://bugs.launchpad.net/calibre/+bug/1968559)
This commit is contained in:
commit
28c9006729
@ -764,6 +764,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
|
|
||||||
def build_data_convertors(self):
|
def build_data_convertors(self):
|
||||||
rating_fields = {}
|
rating_fields = {}
|
||||||
|
bool_fields = set()
|
||||||
|
|
||||||
def renderer(field, decorator=False):
|
def renderer(field, decorator=False):
|
||||||
idfunc = self.db.id
|
idfunc = self.db.id
|
||||||
@ -775,6 +776,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
dt = m['datatype']
|
dt = m['datatype']
|
||||||
|
|
||||||
if decorator == 'bool':
|
if decorator == 'bool':
|
||||||
|
bool_fields.add(field)
|
||||||
bt = self.db.new_api.pref('bools_are_tristate')
|
bt = self.db.new_api.pref('bools_are_tristate')
|
||||||
bn = self.bool_no_icon
|
bn = self.bool_no_icon
|
||||||
by = self.bool_yes_icon
|
by = self.bool_yes_icon
|
||||||
@ -895,14 +897,23 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
|
|
||||||
def stars_tooltip(func, allow_half=True):
|
def stars_tooltip(func, allow_half=True):
|
||||||
def f(idx):
|
def f(idx):
|
||||||
ans = val = int(func(idx))
|
val = int(func(idx))
|
||||||
ans = str(val // 2)
|
ans = str(val // 2)
|
||||||
if allow_half and val % 2:
|
if allow_half and val % 2:
|
||||||
ans += '.5'
|
ans += '.5'
|
||||||
return _('%s stars') % ans
|
return _('%s stars') % ans
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
def bool_tooltip(key):
|
||||||
|
def f(idx):
|
||||||
|
return self.db.new_api.fast_field_for(self.db.new_api.fields[key],
|
||||||
|
self.db.id(idx))
|
||||||
|
return f
|
||||||
|
|
||||||
for f, allow_half in iteritems(rating_fields):
|
for f, allow_half in iteritems(rating_fields):
|
||||||
tc[f] = stars_tooltip(self.dc[f], allow_half)
|
tc[f] = stars_tooltip(self.dc[f], allow_half)
|
||||||
|
for f in bool_fields:
|
||||||
|
tc[f] = bool_tooltip(f)
|
||||||
# build a index column to data converter map, to remove the string lookup in the data loop
|
# build a index column to data converter map, to remove the string lookup in the data loop
|
||||||
self.column_to_dc_map = [self.dc[col] for col in self.column_map]
|
self.column_to_dc_map = [self.dc[col] for col in self.column_map]
|
||||||
self.column_to_tc_map = [tc[col] for col in self.column_map]
|
self.column_to_tc_map = [tc[col] for col in self.column_map]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user