mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:05:04 +02:00
Recover from more changes in delegates.py. Do robustness checks correctly in models.py.
This commit is contained in:
commit
6d19e4279f
2 changed files with 12 additions and 12 deletions
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
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 @@ def data(self, index, role):
|
|||
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 @@ def data(self, index, role):
|
|||
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…
Reference in a new issue