diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-14 12:50:42 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-14 12:50:42 +0200 |
| commit | 811bea0640dbfd27ca2c47b0288716ca608e5abb (patch) | |
| tree | fcc55aa4d6b50305d3bbbd062de1dadc3dc1fca1 /src | |
| parent | 7e1cabf49c03c1e0c2926dcfcf82adedbf98940e (diff) | |
| download | qtmaildir-811bea0640dbfd27ca2c47b0288716ca608e5abb.tar.gz qtmaildir-811bea0640dbfd27ca2c47b0288716ca608e5abb.zip | |
refactor(tags): name what the overflow chip's x actually is
The loop was assigning a variable it never read, overwritten on every pass and
used only after, which reads as an accumulator and is not one. The overflow
chip's position is derived where it is used instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tagstrip.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/tagstrip.cpp b/src/tagstrip.cpp index 7e671ce..565a054 100644 --- a/src/tagstrip.cpp +++ b/src/tagstrip.cpp @@ -163,17 +163,20 @@ void TagStrip::paintEvent(QPaintEvent *) const QFontMetrics metrics(font()); const int top = (height() - (metrics.height() + TagChip::kPaddingY * 2)) / 2; - int x = 0; for (int i = 0; i < m_visible.size(); ++i) { const QString &tag = m_visible.at(i); - const QRect rect = chipRectAt(i); const QColor colour = m_tagColors ? m_tagColors->colourFor(tag) : TagColors().colourFor(tag); - TagChip::paint(&painter, rect, tag, colour); - x = rect.right() + 1 + TagChip::kSpacing; + TagChip::paint(&painter, chipRectAt(i), tag, colour); } if (!m_hidden.isEmpty()) { + // After the last visible chip. right() is inclusive, so +1 makes it an + // exclusive edge before the gap is added. The overflow chip is not in + // m_visible and so has no chipRectAt() of its own. + const QRect last = chipRectAt(m_visible.size() - 1); + const int x = last.right() + 1 + TagChip::kSpacing; + const QString text = overflowText(m_hidden.size()); const QSize size = TagChip::sizeFor(metrics, text); TagChip::paint(&painter, QRect(QPoint(x, top), size), text, |
