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);
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"