From 994095076cccdb703b2bb285d4118bd9c654fd93 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 15 Oct 2008 21:23:42 +0000 Subject: Assure that the item delegate draws the hover effect and the selection for the details view only above the icon + name. Open issue: The performance when selecting files by the rubberband is too slow (will be fixed before KDE 4.2). CCBUG: 165999 CCMAIL: simon@etotheipiplusone.com svn path=/trunk/KDE/kdebase/apps/; revision=871874 --- src/dolphindetailsview.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/dolphindetailsview.cpp') diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 045ea6a6a..08eef4307 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -22,6 +22,7 @@ #include "dolphinmodel.h" #include "dolphincontroller.h" +#include "dolphinfileitemdelegate.h" #include "dolphinsettings.h" #include "dolphinsortfilterproxymodel.h" #include "draganddrophelper.h" @@ -737,19 +738,14 @@ void DolphinDetailsView::resizeColumns() QRect DolphinDetailsView::nameColumnRect(const QModelIndex& index) const { - // TODO: The code guesses the width of the name, but it is defined - // by KFileItemDelegate. Find a way to tell the item delegate to - // use a specified width. - QRect guessedItemContentRect = visualRect(index); - const KFileItem fileItem = m_controller->itemForIndex(index); - if (!fileItem.isNull()) { - QStyleOptionViewItem itemStyle = viewOptions(); - QFontMetrics fontMetrics(itemStyle.font); - const int itemContentWidth = itemStyle.decorationSize.width() + fontMetrics.width(fileItem.name()); - guessedItemContentRect.setWidth(itemContentWidth); + QRect rect = visualRect(index); + const KFileItem item = m_controller->itemForIndex(index); + if (!item.isNull()) { + const int width = DolphinFileItemDelegate::nameColumnWidth(item.name(), viewOptions()); + rect.setWidth(width); } - return guessedItemContentRect; + return rect; } void DolphinDetailsView::setSelectionRecursive(const QModelIndex& startIndex, -- cgit v1.3