Core: Limit rendering of tag rows in ListItemDelegate

Unlimited rows make the tags flow over the lower edge. Two rows should
be enough for proper tagging.

All tags are still used for searching, even if some are omitted in the
rendering.

Change-Id: Ia731031f362165c75ef5fa34a80200c85d2f93aa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Alessandro Portale
2022-02-10 09:22:17 +01:00
parent 64fee150ef
commit d84c5da4e9

View File

@@ -522,11 +522,14 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->setPen(themeColor(Theme::Welcome_LinkColor)); painter->setPen(themeColor(Theme::Welcome_LinkColor));
m_currentTagRects.clear(); m_currentTagRects.clear();
int emptyTagRowsLeft = 2;
int xx = 0; int xx = 0;
int yy = 0; int yy = 0;
for (const QString &tag : item->tags) { for (const QString &tag : item->tags) {
const int ww = fm.horizontalAdvance(tag) + tagsHorSpacing; const int ww = fm.horizontalAdvance(tag) + tagsHorSpacing;
if (xx + ww > textArea.width() - tagsLabelRect.width()) { if (xx + ww > textArea.width() - tagsLabelRect.width()) {
if (--emptyTagRowsLeft == 0)
break;
yy += fm.lineSpacing(); yy += fm.lineSpacing();
xx = 0; xx = 0;
} }