mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use bold italic font in headers to indicate current selected cell
This commit is contained in:
parent
df9f089c12
commit
6b227f9a49
@ -537,13 +537,6 @@ 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_header_highlight_color = 'lightgrey'
|
|
||||||
|
|
||||||
#: Control how the currently selected cell is marked.
|
#: Control how the currently selected cell is marked.
|
||||||
# You can control how the currently selected cell is marked using something
|
# You can control how the currently selected cell is marked using something
|
||||||
# very similar to a CSS style sheet.
|
# very similar to a CSS style sheet.
|
||||||
|
@ -9,7 +9,7 @@ import functools, re, os, traceback, errno, time
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from PyQt4.Qt import (QAbstractTableModel, Qt, pyqtSignal, QIcon, QImage,
|
from PyQt4.Qt import (QAbstractTableModel, Qt, pyqtSignal, QIcon, QImage,
|
||||||
QModelIndex, QVariant, QDateTime, QColor, QPixmap)
|
QModelIndex, QVariant, QDateTime, QColor, QPixmap, QFont)
|
||||||
|
|
||||||
from calibre.gui2 import NONE, UNDEFINED_QDATETIME, error_dialog
|
from calibre.gui2 import NONE, UNDEFINED_QDATETIME, error_dialog
|
||||||
from calibre.utils.search_query_parser import ParseException
|
from calibre.utils.search_query_parser import ParseException
|
||||||
@ -165,8 +165,11 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
self.current_highlighted_idx = None
|
self.current_highlighted_idx = None
|
||||||
self.highlight_only = False
|
self.highlight_only = False
|
||||||
self.current_index_column = -1
|
self.current_index_column = -1
|
||||||
self.column_header_highlight_color = \
|
self.current_index_row = -1
|
||||||
QVariant(QColor(tweaks['column_header_highlight_color']))
|
self.selected_header_font = QFont()
|
||||||
|
self.selected_header_font.setBold(True)
|
||||||
|
self.selected_header_font.setItalic(True)
|
||||||
|
|
||||||
self.read_config()
|
self.read_config()
|
||||||
|
|
||||||
def _clear_caches(self):
|
def _clear_caches(self):
|
||||||
@ -894,9 +897,12 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
|
|
||||||
def set_current_cell(self, idx):
|
def set_current_cell(self, idx):
|
||||||
if idx and idx.isValid():
|
if idx and idx.isValid():
|
||||||
|
# Copy these out here for performance, avoiding using idx in headerData
|
||||||
self.current_index_column = idx.column()
|
self.current_index_column = idx.column()
|
||||||
|
self.current_index_row = idx.row()
|
||||||
else:
|
else:
|
||||||
self.current_index_column = -1
|
self.current_index_column = -1
|
||||||
|
self.current_index_row = -1
|
||||||
|
|
||||||
def headerData(self, section, orientation, role):
|
def headerData(self, section, orientation, role):
|
||||||
if orientation == Qt.Horizontal:
|
if orientation == Qt.Horizontal:
|
||||||
@ -909,8 +915,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:
|
if role == Qt.FontRole and self.current_index_column == section:
|
||||||
return self.column_header_highlight_color
|
return QVariant(self.selected_header_font)
|
||||||
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']
|
||||||
@ -918,6 +924,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
|
|
||||||
if role == Qt.DisplayRole: # orientation is vertical
|
if role == Qt.DisplayRole: # orientation is vertical
|
||||||
return QVariant(section+1)
|
return QVariant(section+1)
|
||||||
|
if role == Qt.FontRole and self.current_index_row == section:
|
||||||
|
return QVariant(self.selected_header_font)
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user