]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Icon-rectangle and selection-toggle optimizations
authorPeter Penz <peter.penz19@gmail.com>
Thu, 9 Feb 2012 08:57:47 +0000 (09:57 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 9 Feb 2012 15:05:03 +0000 (16:05 +0100)
- 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
src/kitemviews/kitemlistviewlayouter.cpp

index 9fdcbec65fa1e91218cabd5fd496352a0f2acb4c..64cc8b4497800871e8bbd0e948fb68252cf48d12 100644 (file)
@@ -179,7 +179,7 @@ QRectF KFileItemListWidget::selectionToggleRect() const
 {
     const_cast<KFileItemListWidget*>(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()) {
index 30dd10346f86312c71b313bfaec6a59ff3f97fa5..2d02b6725102d04b5dc2ddf5dc9c58480eadf0a3 100644 (file)
@@ -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) {