- if (m_supportsItemExpanding) {
- // Prevent a possible overlapping of the additional-information texts
- // with the icon. This can happen if the user has minimized the width
- // of the name-column to a very small value.
- const qreal minX = m_pixmapPos.x() + m_pixmap.width() + 4 * itemListStyleOption.padding;
- if (textInfo->pos.x() + columnWidth("text") > minX) {
- clipAdditionalInfoBounds = true;
- painter->save();
- painter->setClipRect(minX, 0, size().width() - minX, size().height(), Qt::IntersectClip);
+ if (m_supportsItemExpanding && m_sortedVisibleRoles.count() > 1) {
+ // Prevent a possible overlapping of the additional-information-texts with the icon.
+ // This will happen if the user has resized the width of the name-column to be very narrow while having folders expanded.
+ // We only want to draw additional info text outside the area of the icon or expansion area, so we set a clip rect that does not contain the icon area.
+ // This needs to work both for left-to-right as well as right-to-left layout directions.
+ const TextInfo *potentiallyOverlappingRoleText = m_textInfo.value(m_sortedVisibleRoles[1]); // Only the first column after the name column can overlap.
+ if (layoutDirection() == Qt::LeftToRight) { // In left-to-right languages the left end of text would overlap. This is mirrored for right-to-left.
+ const qreal minX = m_iconRect.right() + 2 * itemListStyleOption.padding;
+ if (potentiallyOverlappingRoleText->pos.x() < minX) {
+ clipAdditionalInfoBounds = true;
+ painter->save();
+ painter->setClipRect(minX, 0, size().width() - minX, size().height(), Qt::IntersectClip);
+ }
+ } else {
+ const qreal maxX = m_iconRect.left() - 2 * itemListStyleOption.padding;
+ if (potentiallyOverlappingRoleText->pos.x() + m_customizedFontMetrics.horizontalAdvance(potentiallyOverlappingRoleText->staticText.text()) > maxX) {
+ clipAdditionalInfoBounds = true;
+ painter->save();
+ painter->setClipRect(0, 0, maxX, size().height(), Qt::IntersectClip);
+ }