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

List:       kde-commits
Subject:    KDE/kdegames/ksudoku/src/gui
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2007-11-01 0:59:47
Message-ID: 1193878787.534324.18166.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 731567 by apaku:

Improve the speed a lot by not calculating the exact font size. Width is set to the \
rectangle anyway and for the height the font-height is a good approximation.

 M  +4 -21     gamevariants.cpp  


--- trunk/KDE/kdegames/ksudoku/src/gui/gamevariants.cpp #731566:731567
@@ -126,30 +126,13 @@
 QSize GameVariantDelegate::sizeHint(const QStyleOptionViewItem& option, const \
QModelIndex& index) const {  Q_UNUSED(option);
 	Q_UNUSED(index);
-	QSize size(m_leftMargin+m_iconWidth+m_rightMargin+m_separatorPixels*2, \
m_iconHeight+m_separatorPixels*2); +	QSize \
size(m_leftMargin+m_iconWidth+m_rightMargin+m_separatorPixels*2, 0);  
-	QRect contentRect = option.rect.adjusted(m_leftMargin, m_separatorPixels, \
                -m_rightMargin, -m_separatorPixels);
-	contentRect.adjust(m_iconWidth + m_separatorPixels*2, 0, 0, 0);
-
-	QFont titleFont(option.font);
-	titleFont.setPointSize(titleFont.pointSize() + 2);
-	titleFont.setWeight(QFont::Bold);
-
-	QString titleStr = option.fontMetrics.elidedText(title(index), Qt::ElideRight, \
                contentRect.width());
-	QSize titleSize = option.fontMetrics.size( Qt::TextSingleLine, titleStr );
-	contentRect.adjust(0, m_separatorPixels + option.fontMetrics.height(), 0, 0);
-
-	// Show Description
-	QString descrStr = option.fontMetrics.elidedText(description(index), \
                Qt::ElideRight, contentRect.width());
-	QSize descrSize = option.fontMetrics.size( Qt::TextSingleLine, descrStr );
-
-	if( descrSize.width() > titleSize.width() )
-		size.setWidth(size.width() + descrSize.width());
+	if( m_iconHeight < option.fontMetrics.height()*3 )
+		size.setHeight( option.fontMetrics.height()*3 + m_separatorPixels*3);
 	else
-		size.setWidth(size.width() + titleSize.width());
+		size.setHeight( m_iconHeight+m_separatorPixels*2);
 
-	if( titleSize.height()+descrSize.height()+m_separatorPixels*2 > m_iconWidth )
-		size.setHeight( titleSize.height()+option.fontMetrics.height()+descrSize.height()+m_separatorPixels*4 \
);  return size;
 }
 


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

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