This commit is contained in:
Kovid Goyal 2023-04-26 16:24:31 +05:30
commit e9f3b50fd6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 23 additions and 29 deletions

View File

@ -574,11 +574,3 @@ allow_template_database_functions_in_composites = False
# for https://whatever URLs. %u is replaced by the URL to be opened. The scheme
# takes a glob pattern allowing a single entry to match multiple URL types.
openers_by_scheme = {}
#: Change standard column names
# Use the dictionary below to change a column name.
# This tweak works only with standard columns, it cannot be used to change
# the heading for a custom column.
# Example:
# alternate_column_names = {'authors':'Writers', 'size':'MBytes'}
alternate_column_names = {}

View File

@ -38,7 +38,7 @@ from calibre.utils.date import (
UNDEFINED_DATE, as_local_time, dt_factory, is_date_undefined, qt_to_dt,
)
from calibre.utils.icu import sort_key
from calibre.utils.localization import calibre_langcode_to_name
from calibre.utils.localization import calibre_langcode_to_name, ngettext
from calibre.utils.resources import get_path as P
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
from polyglot.builtins import iteritems, itervalues, string_or_bytes
@ -192,13 +192,23 @@ class BooksModel(QAbstractTableModel): # {{{
self.bi_font = QFont(self.bold_font)
self.bi_font.setItalic(True)
self.styled_columns = {}
possible_columns = ('title', 'ondevice', 'authors', 'size', 'timestamp',
'pubdate', 'rating', 'publisher', 'tags', 'series',
'last_modified', 'languages', 'formats', 'id', 'path')
from calibre.library.field_metadata import FieldMetadata
fm = FieldMetadata()
self.orig_headers = {k: fm[k]['name'] for k in possible_columns}
self.orig_headers = {
'title' : _("Title"),
'ondevice' : _("On Device"),
'authors' : _("Author(s)"),
'size' : _("Size (MB)"),
'timestamp' : _("Date"),
'pubdate' : _('Published'),
'rating' : _('Rating'),
'publisher' : _("Publisher"),
'tags' : _("Tags"),
'series' : ngettext("Series", 'Series', 1),
'last_modified' : _('Modified'),
'languages' : _('Languages'),
'formats' : _('Formats'),
'id' : _('Id'),
'path' : _('Path'),
}
self.db = None
self.formatter = SafeFormat()

View File

@ -1137,9 +1137,10 @@ class BooksView(QTableView): # {{{
elif cc['datatype'] == 'enumeration':
set_item_delegate(colhead, self.cc_enum_delegate)
else:
dattr = colhead+'_delegate'
delegate = colhead if hasattr(self, dattr) else 'text'
set_item_delegate(colhead, getattr(self, delegate+'_delegate'))
if colhead in self._model.editable_cols:
dattr = colhead+'_delegate'
delegate = colhead if hasattr(self, dattr) else 'text'
set_item_delegate(colhead, getattr(self, delegate+'_delegate'))
self.restore_state()
self.set_ondevice_column_visibility()

View File

@ -771,10 +771,7 @@ class SeriesIndexEdit(make_undoable(QDoubleSpinBox), ToMetadataMixin):
class BuddyLabel(QLabel): # {{{
def __init__(self, buddy):
sval = tweaks['alternate_column_names'].get(getattr(buddy, 'FIELD_NAME', None))
if sval:
sval = '&' + sval.replace('&', '&&')
QLabel.__init__(self, sval or buddy.LABEL)
QLabel.__init__(self, buddy.LABEL)
self.setBuddy(buddy)
self.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignVCenter)
# }}}

View File

@ -412,12 +412,6 @@ class FieldMetadata:
self._tb_cats[k]['display'] = {}
self._tb_cats[k]['is_editable'] = True
self._add_search_terms_to_map(k, v['search_terms'])
try:
for k, v in tweaks['alternate_column_names'].items():
if k in self._tb_cats and not self.is_custom_field(k):
self._tb_cats[k]['name'] = v
except Exception:
traceback.print_exc()
self._tb_cats['timestamp']['display'] = {
'date_format': tweaks['gui_timestamp_display_format']}
self._tb_cats['pubdate']['display'] = {