+
+LocationButton::LocationButton( const QString &text, bool bold, bool arrow )
+ : b_arrow( arrow )
+{
+ QFont font;
+ font.setBold( bold );
+ setFont( font );
+ setText( text );
+}
+
+#define PADDING 4
+
+void LocationButton::paintEvent ( QPaintEvent * event )
+{
+ QStyleOptionButton option;
+ option.initFrom( this );
+ //option.rect = rect();
+ //option.features = QStyleOptionButton::Flat;
+ option.state |= QStyle::State_Enabled;
+ //option.state |= isChecked() ? QStyle::State_On : QStyle::State_Off;
+ //if( isDown() ) option.state |= QStyle::State_Sunken;
+ QPainter p( this );
+
+ if( underMouse() )
+ style()->drawControl( QStyle::CE_PushButtonBevel, &option, &p );
+
+ int margin = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0,this) + PADDING;
+
+ QRect rect = option.rect.adjusted( b_arrow ? 15 + margin : margin, 0, margin * -1, 0 );
+ p.drawText( rect, Qt::AlignVCenter,
+ fontMetrics().elidedText( text(), Qt::ElideRight, rect.width() ) );
+
+ if( b_arrow )
+ {
+ option.rect.setX( margin );
+ option.rect.setWidth( 8 );
+ style()->drawPrimitive( QStyle::PE_IndicatorArrowRight, &option, &p );
+ }
+}
+
+QSize LocationButton::sizeHint() const
+{
+ int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0,this);
+ QSize s( fontMetrics().boundingRect( text() ).size() );
+ s.setWidth( s.width() + ( 2 * frameWidth ) + ( 2 * PADDING ) + ( b_arrow ? 15 : 0 ) );
+ s.setHeight( QPushButton::sizeHint().height() );
+ return s;
+}
+
+#undef PADDING