Use QFontMetrics::height() instead of averageCharWidth()

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!
This commit is contained in:
Peter Penz 2011-10-06 16:41:29 +02:00
parent b1f6a546aa
commit 16d4f059c3
2 changed files with 2 additions and 2 deletions

View 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"

View 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()) {