]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use QFontMetrics::height() instead of averageCharWidth()
authorPeter Penz <peter.penz19@gmail.com>
Thu, 6 Oct 2011 14:41:29 +0000 (16:41 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 6 Oct 2011 14:45:15 +0000 (16:45 +0200)
QFontMetrics::averageCharWidth() is quite slow and does not work
well on fonts with broken characters. In the
usecases required by Dolphin QFontMetrics::height() is a better
and faster alternative to get a font-dependent minimum width.

Thanks go to Christoph Feck for this hint!

src/kitemviews/kitemlistheader.cpp
src/search/dolphinsearchbox.cpp

index f9b976369f8b648a9f17372a25488797a92af81a..0b94f327b19029b673f2d5ee893a314671f78098 100644 (file)
@@ -337,7 +337,7 @@ bool KItemListHeader::isAboveRoleGrip(const QPointF& pos, int roleIndex) const
 qreal KItemListHeader::minimumRoleWidth() const
 {
     QFontMetricsF fontMetrics(font());
-    return fontMetrics.averageCharWidth() * 8;
+    return fontMetrics.height() * 4;
 }
 
 #include "kitemlistheader_p.moc"
index d65eb5b7ca6fc256a2e6b954f748c91e40267045..06644e1f36fde0fda8ff0f87aad80007acbee526 100644 (file)
@@ -91,7 +91,7 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
     m_searchPath = url;
 
     QFontMetrics metrics(m_fromHereButton->font());
-    const int maxWidth = metrics.averageCharWidth() * 15;
+    const int maxWidth = metrics.height() * 8;
 
     QString location = url.fileName();
     if (location.isEmpty()) {