]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Details mode: Fix wrong required column-width calculation
authorPeter Penz <peter.penz19@gmail.com>
Sun, 22 Apr 2012 22:23:45 +0000 (00:23 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 22 Apr 2012 22:24:40 +0000 (00:24 +0200)
BUG: 298577
FIXED-IN: 4.9.0

src/kitemviews/kitemlistview.cpp
src/kitemviews/kstandarditemlistwidget.cpp

index ae86b28422a74b6b61e01a50649f4b50871980c3..6d2d98e93297fd157203d44d51455642ee45b072 100644 (file)
@@ -693,6 +693,10 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
     m_layouter->markAsDirty();
     doLayout(animate ? Animation : NoAnimation);
 
+    if (m_itemSize.isEmpty()) {
+        updatePreferredColumnWidths();
+    }
+
     onStyleOptionChanged(option, previousOption);
 }
 
@@ -1461,6 +1465,11 @@ void KItemListView::setModel(KItemModelBase* model)
                 this,    SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
         connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
                 this,    SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
+
+        const int itemCount = m_model->count();
+        if (itemCount > 0) {
+            slotItemsInserted(KItemRangeList() << KItemRange(0, itemCount));
+        }
     }
 
     onModelChanged(model, previous);
@@ -2130,7 +2139,7 @@ void KItemListView::applyAutomaticColumnWidths()
         // Stretch the first column to use the whole remaining width
         firstColumnWidth += availableWidth - requiredWidth;
         m_headerWidget->setColumnWidth(firstRole, firstColumnWidth);
-    } else if (requiredWidth > availableWidth) {
+    } else if (requiredWidth > availableWidth && m_visibleRoles.count() > 1) {
         // Shrink the first column to be able to show as much other
         // columns as possible
         qreal shrinkedFirstColumnWidth = firstColumnWidth - requiredWidth + availableWidth;
index 996d0cb58142f698f404bf3190c02b798a4c78a9..43df72f9532cbec99dccfca280890d1fc492b5bb 100644 (file)
@@ -43,7 +43,7 @@
 #include <QTextLayout>
 #include <QTextLine>
 
-// #define KFILEITEMLISTWIDGET_DEBUG
+// #define KSTANDARDITEMLISTWIDGET_DEBUG
 
 KStandardItemListWidgetInformant::KStandardItemListWidgetInformant() :
     KItemListWidgetInformant()
@@ -143,9 +143,12 @@ qreal KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArra
         width += option.fontMetrics.width(text);
 
         if (role == "text") {
-            // Increase the width by the expansion-toggle and the current expansion level
-            const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
-            width += option.padding + (expandedParentsCount + 1) * view->itemSize().height() + KIconLoader::SizeSmall;
+            if (view->supportsItemExpanding()) {
+                // Increase the width by the expansion-toggle and the current expansion level
+                const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
+                const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
+                width += (expandedParentsCount + 1) * height;
+            }
 
             // Increase the width by the required space for the icon
             width += option.padding * 2 + option.iconSize;
@@ -295,7 +298,7 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic
         painter->restore();
     }
 
-#ifdef KFILEITEMLISTWIDGET_DEBUG
+#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
     painter->setBrush(Qt::NoBrush);
     painter->setPen(Qt::green);
     painter->drawRect(m_iconRect);
@@ -1130,7 +1133,7 @@ void KStandardItemListWidget::drawPixmap(QPainter* painter, const QPixmap& pixma
         KPixmapModifier::scale(scaledPixmap, m_scaledPixmapSize);
         painter->drawPixmap(m_pixmapPos, scaledPixmap);
 
-#ifdef KFILEITEMLISTWIDGET_DEBUG
+#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
         painter->setPen(Qt::blue);
         painter->drawRect(QRectF(m_pixmapPos, QSizeF(m_scaledPixmapSize)));
 #endif