mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Recover from more changes in delegates.py. Do robustness checks correctly in models.py.
This commit is contained in:
commit
6d19e4279f
@ -7,12 +7,12 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from math import cos, sin, pi
|
||||
|
||||
from PyQt4.Qt import QColor, Qt, QModelIndex, QSize, QPalette, \
|
||||
QPainterPath, QLinearGradient, QBrush, QApplication, \
|
||||
QPen, QStyle, QPainter, QStyleOptionViewItemV4, \
|
||||
QIcon, QDoubleSpinBox, QVariant, QSpinBox, \
|
||||
QStyledItemDelegate, QComboBox, QTextDocument, \
|
||||
QAbstractTextDocumentLayout
|
||||
from PyQt4.Qt import (QColor, Qt, QModelIndex, QSize, QApplication,
|
||||
QPainterPath, QLinearGradient, QBrush,
|
||||
QPen, QStyle, QPainter, QStyleOptionViewItemV4,
|
||||
QIcon, QDoubleSpinBox, QVariant, QSpinBox,
|
||||
QStyledItemDelegate, QComboBox, QTextDocument,
|
||||
QAbstractTextDocumentLayout)
|
||||
|
||||
from calibre.gui2 import UNDEFINED_QDATE, error_dialog
|
||||
from calibre.gui2.widgets import EnLineEdit
|
||||
|
@ -714,9 +714,9 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
mi = self.db.get_metadata(self.id(index), index_is_id=True)
|
||||
fmt = self.column_color_map[key]
|
||||
try:
|
||||
color = composite_formatter.safe_format(fmt, mi, '', mi)
|
||||
if QColor.isValid(color):
|
||||
return QColor(color)
|
||||
color = QColor(composite_formatter.safe_format(fmt, mi, '', mi))
|
||||
if color.isValid():
|
||||
return color
|
||||
except:
|
||||
return None
|
||||
elif self.is_custom_column(key) and \
|
||||
@ -727,9 +727,9 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
txt = unicode(index.data(Qt.DisplayRole).toString())
|
||||
if len(colors) > 0 and txt in values:
|
||||
try:
|
||||
color = colors[values.index(txt)]
|
||||
if QColor.isValid(color):
|
||||
return QColor(color)
|
||||
color = QColor(colors[values.index(txt)])
|
||||
if color.isValid():
|
||||
return color
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user