(trunk qt) fix icon spacing issue in Oxygen theme

This commit is contained in:
Charles Kerr 2010-07-31 06:55:26 +00:00
parent 91594e583f
commit 52922f89f1
1 changed files with 11 additions and 6 deletions

View File

@ -10,8 +10,6 @@
* $Id$
*/
#include <iostream>
#include <QString>
#include <QtGui>
@ -38,6 +36,14 @@ enum
TrackerRole
};
namespace
{
int getHSpacing( QWidget * w )
{
return qMax( 4, w->style()->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, w ) );
}
}
FilterBarComboBoxDelegate :: FilterBarComboBoxDelegate( QObject * parent, QComboBox * combo ):
QItemDelegate( parent ),
myCombo( combo )
@ -80,7 +86,7 @@ FilterBarComboBoxDelegate :: paint( QPainter * painter,
disabledOption.state &= ~( QStyle::State_Enabled | QStyle::State_Selected );
QRect boundingBox = option.rect;
const int hmargin = myCombo->style()->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, myCombo );
const int hmargin = getHSpacing( myCombo );
boundingBox.setLeft( boundingBox.left() + hmargin );
boundingBox.setRight( boundingBox.right() - hmargin );
@ -121,8 +127,7 @@ FilterBarComboBoxDelegate :: sizeHint( const QStyleOptionViewItem & option,
else
{
QStyle * s = myCombo->style( );
const int hmargin = s->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, myCombo );
const int hmargin = getHSpacing( myCombo );
QSize size = QItemDelegate::sizeHint( option, index );
size.setHeight( qMax( size.height(), myCombo->iconSize().height() + 6 ) );
@ -161,7 +166,7 @@ FilterBarComboBox :: paintEvent( QPaintEvent * e )
{
QStyle * s = style();
QRect rect = s->subControlRect( QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this );
const int hmargin = s->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, this );
const int hmargin = getHSpacing( this );
rect.setRight( rect.right() - hmargin );
// draw the icon