diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 5984c66dcd..5ede2b49a0 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -8,8 +8,8 @@ from math import cos, sin, pi from itertools import repeat from PyQt4.QtGui import QTableView, QProgressDialog, QAbstractItemView, QColor, \ QItemDelegate, QPainterPath, QLinearGradient, QBrush, \ - QPen, QStyle, QPainter, QLineEdit, QApplication, \ - QPalette, QImage, QStyleOptionFocusRect, QApplication + QPen, QStyle, QPainter, QLineEdit, \ + QPalette, QImage, QApplication from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, QString, \ QCoreApplication, SIGNAL, QObject, QSize, QModelIndex, \ QTimer @@ -55,7 +55,10 @@ class LibraryDelegate(QItemDelegate): painter.restore() painter.save() - QApplication.style().drawControl(QStyle.CE_ItemViewItem, option, painter) + if hasattr(QStyle, 'CE_ItemViewItem'): + QApplication.style().drawControl(QStyle.CE_ItemViewItem, option, painter) + elif option.state & QStyle.State_Selected: + painter.fillRect(option.rect, option.palette.highlight()) try: painter.setRenderHint(QPainter.Antialiasing) y = option.rect.center().y()-self.SIZE/2. diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index 9846d4d46d..1f9de46c5b 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -143,7 +143,7 @@ class LocationDelegate(QAbstractItemDelegate): def paint(self, painter, option, index): style = QApplication.style() painter.save() - if hasattr(QStyle.CE_ItemViewItem): + if hasattr(QStyle, 'CE_ItemViewItem'): QApplication.style().drawControl(QStyle.CE_ItemViewItem, option, painter) highlight = getattr(index.model(), 'highlight_row', -1) == index.row() mode = QIcon.Active if highlight else QIcon.Normal