mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book list: When a series column is not wide enough, elide text in the middle so that the series number is visible
This commit is contained in:
parent
a91d7ddb18
commit
fe9653fa13
@ -322,6 +322,14 @@ class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class SeriesDelegate(TextDelegate): # {{{
|
||||
|
||||
def initStyleOption(self, option, index):
|
||||
TextDelegate.initStyleOption(self, option, index)
|
||||
option.textElideMode = Qt.ElideMiddle
|
||||
# }}}
|
||||
|
||||
|
||||
class CompleteDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
|
||||
def __init__(self, parent, sep, items_func_name, space_before_sep=False):
|
||||
@ -482,6 +490,14 @@ class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||
# }}}
|
||||
|
||||
|
||||
class CcSeriesDelegate(CcTextDelegate): # {{{
|
||||
|
||||
def initStyleOption(self, option, index):
|
||||
CcTextDelegate.initStyleOption(self, option, index)
|
||||
option.textElideMode = Qt.ElideMiddle
|
||||
# }}}
|
||||
|
||||
|
||||
class CcLongTextDelegate(QStyledItemDelegate): # {{{
|
||||
|
||||
'''
|
||||
|
@ -19,7 +19,7 @@ from calibre.constants import islinux
|
||||
from calibre.gui2.library.delegates import (RatingDelegate, PubDateDelegate,
|
||||
TextDelegate, DateDelegate, CompleteDelegate, CcTextDelegate, CcLongTextDelegate,
|
||||
CcBoolDelegate, CcCommentsDelegate, CcDateDelegate, CcTemplateDelegate,
|
||||
CcEnumDelegate, CcNumberDelegate, LanguagesDelegate)
|
||||
CcEnumDelegate, CcNumberDelegate, LanguagesDelegate, SeriesDelegate, CcSeriesDelegate)
|
||||
from calibre.gui2.library.models import BooksModel, DeviceBooksModel
|
||||
from calibre.gui2.pin_columns import PinTableView
|
||||
from calibre.gui2.library.alternate_views import AlternateViews, setup_dnd_interface, handle_enter_press
|
||||
@ -267,10 +267,11 @@ class BooksView(QTableView): # {{{
|
||||
self.tags_delegate = CompleteDelegate(self, ',', 'all_tag_names')
|
||||
self.authors_delegate = CompleteDelegate(self, '&', 'all_author_names', True)
|
||||
self.cc_names_delegate = CompleteDelegate(self, '&', 'all_custom', True)
|
||||
self.series_delegate = TextDelegate(self)
|
||||
self.series_delegate = SeriesDelegate(self)
|
||||
self.publisher_delegate = TextDelegate(self)
|
||||
self.text_delegate = TextDelegate(self)
|
||||
self.cc_text_delegate = CcTextDelegate(self)
|
||||
self.cc_series_delegate = CcSeriesDelegate(self)
|
||||
self.cc_longtext_delegate = CcLongTextDelegate(self)
|
||||
self.cc_enum_delegate = CcEnumDelegate(self)
|
||||
self.cc_bool_delegate = CcBoolDelegate(self)
|
||||
@ -924,7 +925,7 @@ class BooksView(QTableView): # {{{
|
||||
else:
|
||||
set_item_delegate(colhead, self.cc_text_delegate)
|
||||
elif cc['datatype'] == 'series':
|
||||
set_item_delegate(colhead, self.cc_text_delegate)
|
||||
set_item_delegate(colhead, self.cc_series_delegate)
|
||||
elif cc['datatype'] in ('int', 'float'):
|
||||
set_item_delegate(colhead, self.cc_number_delegate)
|
||||
elif cc['datatype'] == 'bool':
|
||||
|
Loading…
x
Reference in New Issue
Block a user