[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kfile
From:       Rafael Fernández López <ereslibre () kde ! org>
Date:       2008-10-03 0:16:35
Message-ID: 1222992995.198241.24693.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 867173 by ereslibre:

when the icon size changes, also update the grid


 M  +13 -1     kdiroperator.cpp  


--- trunk/KDE/kdelibs/kfile/kdiroperator.cpp #867172:867173
@@ -221,6 +221,8 @@
     void _k_synchronizeSortingState(int, Qt::SortOrder);
     void _k_slotChangeDecorationPosition(bool);
 
+    void updateListViewGrid();
+
     // private members
     KDirOperator *parent;
     QStack<KUrl*> backStack;    ///< Contains all URLs you can reach with the back button.
@@ -912,6 +914,7 @@
     // do not let the icon to be smaller than the smallest size on KIconLoader
     val = qMax(val, (int) KIconLoader::SizeSmall);
     d->itemView->setIconSize(QSize(val, val));
+    d->updateListViewGrid();
     d->previewGenerator->updatePreviews();
 }
 
@@ -2356,12 +2359,21 @@
     } else {
         decorationPosition = QStyleOptionViewItem::Top;
         view->setFlow(QListView::LeftToRight);
-        view->setGridSize(QSize(150,150));
+        updateListViewGrid();
     }
 
     itemView->update();
 }
 
+void KDirOperator::Private::updateListViewGrid()
+{
+    QListView *view = static_cast<QListView*>(itemView);
+    const QFontMetrics metrics(itemView->viewport()->font());
+    int size = itemView->iconSize().height() + metrics.height() * 2;
+    // some heuristics for good looking. let's guess width = height * (3 / 2) is nice
+    view->setGridSize(QSize(size * (3.0 / 2.0), size));
+}
+
 void KDirOperator::setViewConfig(KConfigGroup& configGroup)
 {
     delete d->configGroup;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic