mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Revert part of 20b0cb68bf
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
This commit is contained in:
parent
2fafb33240
commit
631f97a6d9
1 changed files with 3 additions and 25 deletions
|
@ -68,14 +68,6 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList
|
|||
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);
|
||||
|
@ -92,7 +84,7 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList
|
|||
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) {
|
||||
|
@ -988,17 +980,8 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
|
|||
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 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());
|
||||
|
@ -1032,7 +1015,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
|
|||
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(),
|
||||
|
@ -1047,11 +1030,6 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
|
|||
}
|
||||
|
||||
const QString text = roleText(role, values);
|
||||
|
||||
if (role != "text" && role != "rating" && text.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TextInfo* textInfo = m_textInfo.value(role);
|
||||
textInfo->staticText.setText(text);
|
||||
|
||||
|
|
Loading…
Reference in a new issue