Make PortSymbol output its number in case its name string is empty

(This actually a fix of what I broke when I was migrating the
rendering from ViewPainter to QPainter)
This commit is contained in:
Andrey Kalmykov 2024-06-12 16:34:49 +02:00
parent 9ede1ffe89
commit c10c7db9fc

View File

@ -53,7 +53,7 @@ void PortSymbol::paint(QPainter *painter) {
painter->setPen(QPen(Qt::red,1)); // like open node
painter->drawEllipse(circle_br);
QSize name_size = painter->fontMetrics().size(0b0, nameStr);
QSize name_size = painter->fontMetrics().size(0b0, nameStr.isEmpty() ? numberStr : nameStr);
const int half_nameheight = static_cast<int>(std::round(name_size.height() / 2.0));
constexpr int offset = 8;
@ -88,7 +88,7 @@ void PortSymbol::paint(QPainter *painter) {
}
painter->setPen(Qt::black);
painter->drawText(0, 0, 0, 0, Qt::TextDontClip, nameStr);
painter->drawText(0, 0, 0, 0, Qt::TextDontClip, nameStr.isEmpty() ? numberStr : nameStr);
}
painter->restore();