X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/994095076cccdb703b2bb285d4118bd9c654fd93..b1c9b5126d:/src/dolphinfileitemdelegate.cpp diff --git a/src/dolphinfileitemdelegate.cpp b/src/dolphinfileitemdelegate.cpp index 53c1d781e..3fa05cbb5 100644 --- a/src/dolphinfileitemdelegate.cpp +++ b/src/dolphinfileitemdelegate.cpp @@ -42,13 +42,13 @@ void DolphinFileItemDelegate::paint(QPainter* painter, { if (m_hasMinimizedNameColumn && (index.column() == KDirModel::Name)) { QStyleOptionViewItemV4 opt(option); - + const QAbstractProxyModel* proxyModel = static_cast(index.model()); const KDirModel* dirModel = static_cast(proxyModel->sourceModel()); 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,12 @@ 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"