That commit, which disregarded roles with empty text for the row number
calculation in Icons View, caused the problem that icons might jump
around while information was retrieved asynchronously because previously
empty roles could get a non-empty value, and the corresponding items
would need an additional row in the view.
Thanks to Hrvoje Senjan for testing this feature in master and reporting
this issue early, such that we could fix it quickly and prevent that
other users suffer from this bug!
CCBUG: 304752
const qreal maxWidth = itemWidth - 2 * option.padding;
QTextLine line;
const qreal maxWidth = itemWidth - 2 * option.padding;
QTextLine line;
- int emptyRolesCount = 0;
- foreach (const QByteArray& role, view->visibleRoles()) {
- const QString text = roleText(role, values);
- if (role != "text" && role != "rating" && text.isEmpty()) {
- emptyRolesCount++;
- }
- }
-
// Calculate the number of lines required for wrapping the name
QTextOption textOption(Qt::AlignHCenter);
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
// Calculate the number of lines required for wrapping the name
QTextOption textOption(Qt::AlignHCenter);
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
layout.endLayout();
// Add one line for each additional information
layout.endLayout();
// Add one line for each additional information
- textHeight += (additionalRolesCount - emptyRolesCount) * option.fontMetrics.lineSpacing();
+ textHeight += additionalRolesCount * option.fontMetrics.lineSpacing();
const qreal maxTextHeight = option.maxTextSize.height();
if (maxTextHeight > 0 && textHeight > maxTextHeight) {
const qreal maxTextHeight = option.maxTextSize.height();
if (maxTextHeight > 0 && textHeight > maxTextHeight) {
qreal nameHeight = 0;
QTextLine line;
qreal nameHeight = 0;
QTextLine line;
- int emptyRolesCount = 0;
- foreach (const QByteArray& role, visibleRoles()) {
- const QString text = roleText(role, values);
- if (role != "text" && role != "rating" && text.isEmpty()) {
- emptyRolesCount++;
- }
- }
-
const int additionalRolesCount = qMax(visibleRoles().count() - 1, 0);
const int additionalRolesCount = qMax(visibleRoles().count() - 1, 0);
- const int maxNameLines = (option.maxTextSize.height() / int(lineSpacing)) -
- (additionalRolesCount - emptyRolesCount);
+ const int maxNameLines = (option.maxTextSize.height() / int(lineSpacing)) - additionalRolesCount;
QTextLayout layout(nameTextInfo->staticText.text(), m_customizedFont);
layout.setTextOption(nameTextInfo->staticText.textOption());
QTextLayout layout(nameTextInfo->staticText.text(), m_customizedFont);
layout.setTextOption(nameTextInfo->staticText.textOption());
nameTextInfo->staticText.setTextWidth(maxWidth);
nameTextInfo->pos = QPointF(padding, widgetHeight -
nameHeight -
nameTextInfo->staticText.setTextWidth(maxWidth);
nameTextInfo->pos = QPointF(padding, widgetHeight -
nameHeight -
- (additionalRolesCount - emptyRolesCount)* lineSpacing -
+ additionalRolesCount * lineSpacing -
padding);
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2,
nameTextInfo->pos.y(),
padding);
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2,
nameTextInfo->pos.y(),
}
const QString text = roleText(role, values);
}
const QString text = roleText(role, values);
-
- if (role != "text" && role != "rating" && text.isEmpty()) {
- continue;
- }
-
TextInfo* textInfo = m_textInfo.value(role);
textInfo->staticText.setText(text);
TextInfo* textInfo = m_textInfo.value(role);
textInfo->staticText.setText(text);