mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add highlighting the header of the column containing the current cell
This commit is contained in:
parent
145858572b
commit
0ae22558a2
@ -537,3 +537,9 @@ many_libraries = 10
|
|||||||
# that off.
|
# that off.
|
||||||
highlight_virtual_library_book_count = True
|
highlight_virtual_library_book_count = True
|
||||||
|
|
||||||
|
#: Color for the current column highlight in the library view
|
||||||
|
# This color is used to highlight the column header of the column containing the
|
||||||
|
# currently-selected cell. It must be an valid color name. See
|
||||||
|
# http://webdesign.about.com/od/colorcharts/l/bl_namedcolors.htm
|
||||||
|
# for a list of valid color names
|
||||||
|
column_highlight_color = 'lightgrey'
|
||||||
|
@ -164,6 +164,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
self.ids_to_highlight_set = set()
|
self.ids_to_highlight_set = set()
|
||||||
self.current_highlighted_idx = None
|
self.current_highlighted_idx = None
|
||||||
self.highlight_only = False
|
self.highlight_only = False
|
||||||
|
self.current_index_column = -1
|
||||||
|
self.column_highlight_color = QVariant(QColor(tweaks['column_highlight_color']))
|
||||||
self.read_config()
|
self.read_config()
|
||||||
|
|
||||||
def _clear_caches(self):
|
def _clear_caches(self):
|
||||||
@ -889,6 +891,12 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
# return QVariant(_("Double click to <b>edit</b> me<br><br>"))
|
# return QVariant(_("Double click to <b>edit</b> me<br><br>"))
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
|
def set_current_cell(self, idx):
|
||||||
|
if idx and idx.isValid():
|
||||||
|
self.current_index_column = idx.column()
|
||||||
|
else:
|
||||||
|
self.current_index_column = -1
|
||||||
|
|
||||||
def headerData(self, section, orientation, role):
|
def headerData(self, section, orientation, role):
|
||||||
if orientation == Qt.Horizontal:
|
if orientation == Qt.Horizontal:
|
||||||
if section >= len(self.column_map): # same problem as in data, the column_map can be wrong
|
if section >= len(self.column_map): # same problem as in data, the column_map can be wrong
|
||||||
@ -900,6 +908,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
return QVariant(_('The lookup/search name is "{0}"').format(ht))
|
return QVariant(_('The lookup/search name is "{0}"').format(ht))
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
return QVariant(self.headers[self.column_map[section]])
|
return QVariant(self.headers[self.column_map[section]])
|
||||||
|
if role == Qt.BackgroundRole and section == self.current_index_column:
|
||||||
|
return self.column_highlight_color
|
||||||
return NONE
|
return NONE
|
||||||
if DEBUG and role == Qt.ToolTipRole and orientation == Qt.Vertical:
|
if DEBUG and role == Qt.ToolTipRole and orientation == Qt.Vertical:
|
||||||
col = self.db.field_metadata['uuid']['rec_index']
|
col = self.db.field_metadata['uuid']['rec_index']
|
||||||
|
@ -169,6 +169,10 @@ class BooksView(QTableView): # {{{
|
|||||||
self._model.sorting_done.connect(self.sorting_done,
|
self._model.sorting_done.connect(self.sorting_done,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
|
|
||||||
|
def currentChanged(self, current, previous):
|
||||||
|
self.model().set_current_cell(current)
|
||||||
|
QTableView.currentChanged(self, current, previous)
|
||||||
|
|
||||||
# Column Header Context Menu {{{
|
# Column Header Context Menu {{{
|
||||||
def column_header_context_handler(self, action=None, column=None):
|
def column_header_context_handler(self, action=None, column=None):
|
||||||
if not action or not column:
|
if not action or not column:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user