diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py
index 9d7974a59c..eac9e33d06 100644
--- a/resources/default_tweaks.py
+++ b/resources/default_tweaks.py
@@ -537,3 +537,9 @@ many_libraries = 10
# that off.
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'
diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py
index d252af6395..c16f0022d4 100644
--- a/src/calibre/gui2/library/models.py
+++ b/src/calibre/gui2/library/models.py
@@ -164,6 +164,8 @@ class BooksModel(QAbstractTableModel): # {{{
self.ids_to_highlight_set = set()
self.current_highlighted_idx = None
self.highlight_only = False
+ self.current_index_column = -1
+ self.column_highlight_color = QVariant(QColor(tweaks['column_highlight_color']))
self.read_config()
def _clear_caches(self):
@@ -889,6 +891,12 @@ class BooksModel(QAbstractTableModel): # {{{
# return QVariant(_("Double click to edit me
"))
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):
if orientation == Qt.Horizontal:
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))
if role == Qt.DisplayRole:
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
if DEBUG and role == Qt.ToolTipRole and orientation == Qt.Vertical:
col = self.db.field_metadata['uuid']['rec_index']
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index 928d6d6107..9dbf4df1bd 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -169,6 +169,10 @@ class BooksView(QTableView): # {{{
self._model.sorting_done.connect(self.sorting_done,
type=Qt.QueuedConnection)
+ def currentChanged(self, current, previous):
+ self.model().set_current_cell(current)
+ QTableView.currentChanged(self, current, previous)
+
# Column Header Context Menu {{{
def column_header_context_handler(self, action=None, column=None):
if not action or not column: