impr: fallback when no chart data in database

This commit is contained in:
2023-09-23 14:53:04 +08:00
parent 109e635347
commit 0bd709f49e
6 changed files with 77 additions and 25 deletions

View File

@ -93,13 +93,18 @@ class ChartDelegate(TextSegmentDelegate):
[{self.TextRole: "Chart Invalid", self.ColorRole: QColor("#ff0000")}]
]
chartConstantString = (
f"{chart.constant / 10:.1f}"
if chart.constant is not None and chart.constant > 0
else "?"
)
return [
[
{self.TextRole: f"{chart.title}"},
],
[
{
self.TextRole: f"{rating_class_to_text(chart.rating_class)} {chart.constant / 10:.1f}",
self.TextRole: f"{rating_class_to_text(chart.rating_class)} {chartConstantString}",
self.ColorRole: self.RatingClassColors[chart.rating_class],
},
],