]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Details-view: Fix column-width issue
authorPeter Penz <peter.penz19@gmail.com>
Sat, 8 Oct 2011 20:46:37 +0000 (22:46 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 8 Oct 2011 20:47:52 +0000 (22:47 +0200)
The column-width must respect the minimum width of the
header-roles.

src/kitemviews/kitemlistheader.cpp
src/kitemviews/kitemlistheader_p.h
src/kitemviews/kitemlistview.cpp

index 3187d2c362c13b7053d36f39572b6c6bc0186e8f..96f868aade8c284209f25f57ca15a385b7af1226 100644 (file)
@@ -112,6 +112,12 @@ QHash<QByteArray, qreal> KItemListHeader::visibleRolesWidths() const
     return m_visibleRolesWidths;
 }
 
+qreal KItemListHeader::minimumRoleWidth() const
+{
+    QFontMetricsF fontMetrics(font());
+    return fontMetrics.height() * 4;
+}
+
 void KItemListHeader::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
 {
     Q_UNUSED(option);
@@ -340,10 +346,4 @@ bool KItemListHeader::isAboveRoleGrip(const QPointF& pos, int roleIndex) const
     return pos.x() >= (x - grip) && pos.x() <= x;
 }
 
-qreal KItemListHeader::minimumRoleWidth() const
-{
-    QFontMetricsF fontMetrics(font());
-    return fontMetrics.height() * 4;
-}
-
 #include "kitemlistheader_p.moc"
index 43b7db59a909f5bccfdc186a161dab0a2bd52d00..a3f06f114ac30ad19c7871f7eb8c2463ef246941 100644 (file)
@@ -47,6 +47,8 @@ public:
     void setVisibleRolesWidths(const QHash<QByteArray, qreal> rolesWidths);
     QHash<QByteArray, qreal> visibleRolesWidths() const;
 
+    qreal minimumRoleWidth() const;
+
     virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
 
 signals:
@@ -77,7 +79,6 @@ private:
     void updateHoveredRoleIndex(const QPointF& pos);
     int roleIndexAt(const QPointF& pos) const;
     bool isAboveRoleGrip(const QPointF& pos, int roleIndex) const;
-    qreal minimumRoleWidth() const;
 
 private:
     enum RoleOperation
index 08c92e5516972977056c04b16481f1cb0ad392cb..93baa1334c42ddef9b967440e1f14bf0b91778e3 100644 (file)
@@ -1459,8 +1459,20 @@ void KItemListView::updateVisibleRolesSizes(const KItemRangeList& itemRanges)
     }
 
     if (itemCount == rangesItemCount) {
-        // The sizes of all roles need to be determined
         m_visibleRolesSizes = visibleRolesSizes(itemRanges);
+
+        // Assure the the sizes are not smaller than the minimum defined by the header
+        // TODO: Currently only implemented for a top-aligned header
+        const qreal minHeaderRoleWidth = m_header->minimumRoleWidth();
+        QMutableHashIterator<QByteArray, QSizeF> it (m_visibleRolesSizes);
+        while (it.hasNext()) {
+            it.next();
+            const QSizeF& size = it.value();
+            if (size.width() < minHeaderRoleWidth) {
+                const QSizeF newSize(minHeaderRoleWidth, size.height());
+                m_visibleRolesSizes.insert(it.key(), newSize);
+            }
+        }
     } else {
         // Only a sub range of the roles need to be determined.
         // The chances are good that the sizes of the sub ranges
@@ -1483,7 +1495,7 @@ void KItemListView::updateVisibleRolesSizes(const KItemRangeList& itemRanges)
 
         if (!updateRequired) {
             // All the updated sizes are smaller than the current sizes and no change
-            // of the roles-widths is required
+            // of the stretched roles-widths is required
             return;
         }
     }