From e29e1cda15973969164d7b7fa805544189a5e172 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 9 Feb 2012 09:57:47 +0100 Subject: [PATCH] Icon-rectangle and selection-toggle optimizations - No padding should be applied to the icon-rectangle - Base the selection-toggle size on the icon-size of the style not the actual pixmap content, as this might lead to smaller selection-toggles when having pixmap-previews with a small height. --- src/kitemviews/kfileitemlistwidget.cpp | 11 ++++++----- src/kitemviews/kitemlistviewlayouter.cpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 9fdcbec65..64cc8b449 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -179,7 +179,7 @@ QRectF KFileItemListWidget::selectionToggleRect() const { const_cast(this)->triggerCacheRefreshing(); - const int iconHeight = m_pixmap.height(); + const int iconHeight = styleOption().iconSize; int toggleSize = KIconLoader::SizeSmall; if (iconHeight >= KIconLoader::SizeEnormous) { @@ -196,13 +196,15 @@ QRectF KFileItemListWidget::selectionToggleRect() const // when trying to hit the toggle. const int widgetHeight = size().height(); const int widgetWidth = size().width(); - const int minPadding = 2; + const int minMargin = 2; - if (toggleSize + minPadding * 2 >= widgetHeight) { + if (toggleSize + minMargin * 2 >= widgetHeight) { + pos.rx() -= (widgetHeight - toggleSize) / 2; toggleSize = widgetHeight; pos.setY(0); } - if (toggleSize + minPadding * 2 >= widgetWidth) { + if (toggleSize + minMargin * 2 >= widgetWidth) { + pos.ry() -= (widgetWidth - toggleSize) / 2; toggleSize = widgetWidth; pos.setX(0); } @@ -541,7 +543,6 @@ void KFileItemListWidget::updatePixmapCache() } m_iconRect = QRectF(m_pixmapPos, QSizeF(m_scaledPixmapSize)); - m_iconRect.adjust(-padding, -padding, padding, padding); // Prepare the pixmap that is used when the item gets hovered if (isHovered()) { diff --git a/src/kitemviews/kitemlistviewlayouter.cpp b/src/kitemviews/kitemlistviewlayouter.cpp index 30dd10346..2d02b6725 100644 --- a/src/kitemviews/kitemlistviewlayouter.cpp +++ b/src/kitemviews/kitemlistviewlayouter.cpp @@ -320,7 +320,7 @@ void KItemListViewLayouter::doLayout() m_xPosInc = itemMargin.width(); const int itemCount = m_model->count(); - if (itemCount > m_columnCount) { + if (itemCount > m_columnCount && m_columnWidth >= 32) { // Apply the unused width equally to each column const qreal unusedWidth = size.width() - m_columnCount * m_columnWidth; if (unusedWidth > 0) { -- 2.47.3