Skip to content

Commit

Permalink
Improved error handling in ColoredAmountsDelegate.draw_value()
Browse files Browse the repository at this point in the history
  • Loading branch information
titov-vv committed Jul 30, 2024
1 parent f118163 commit 31c42b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jal/widgets/delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,14 @@ def paint(self, painter, option, index):
painter.restore()

# Displays given value as formatted number with required color (or Green/Red if self._colors is True)
# If value is None - displays nothing, If value is NaN - displays Setup.NULL_VALUE
# If value is None - do nothing, If value is Decimal.NaN - displays Setup.NULL_VALUE
def draw_value(self, rect, painter, value, color=None):
text = localize_decimal(value, precision=2, sign=self._signs)
pen = painter.pen()
try:
if self._view.isEnabled():
if self._colors:
if not value.is_nan():
if value is not None and not value.is_nan():
if value >= 0:
pen.setColor(CustomColor.DarkGreen)
else:
Expand All @@ -401,5 +401,5 @@ def draw_value(self, rect, painter, value, color=None):
if long_fraction(value): # Underline decimal part
shift = painter.fontMetrics().horizontalAdvance(text[-Setup.DEFAULT_ACCOUNT_PRECISION:])
painter.drawLine(rect.right() - shift, rect.bottom(), rect.right(), rect.bottom())
except TypeError:
except (TypeError, AttributeError):
pass

0 comments on commit 31c42b8

Please sign in to comment.