X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/994095076cccdb703b2bb285d4118bd9c654fd93..148282e2d856b47ceb191eeef4c834118c8cdffd:/src/dolphinfileitemdelegate.cpp diff --git a/src/dolphinfileitemdelegate.cpp b/src/dolphinfileitemdelegate.cpp index 53c1d781e..9889feef8 100644 --- a/src/dolphinfileitemdelegate.cpp +++ b/src/dolphinfileitemdelegate.cpp @@ -48,7 +48,7 @@ void DolphinFileItemDelegate::paint(QPainter* painter, const QModelIndex dirIndex = proxyModel->mapToSource(index); const KFileItem item = dirModel->itemForIndex(dirIndex); if (!item.isNull()) { - const int width = nameColumnWidth(item.name(), opt); + const int width = nameColumnWidth(item.text(), opt); opt.rect.setWidth(width); } KFileItemDelegate::paint(painter, opt, index); @@ -60,7 +60,13 @@ void DolphinFileItemDelegate::paint(QPainter* painter, int DolphinFileItemDelegate::nameColumnWidth(const QString& name, const QStyleOptionViewItem& option) { QFontMetrics fontMetrics(option.font); - return option.decorationSize.width() + fontMetrics.width(name) + 16; + int width = option.decorationSize.width() + fontMetrics.width(name) + 16; + + const int defaultWidth = option.rect.width(); + if ((defaultWidth > 0) && (defaultWidth < width)) { + width = defaultWidth; + } + return width; } #include "dolphinfileitemdelegate.moc"