1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
22 #include <qmultilineedit.h>
23 #define y2log_component "qt-ui"
24 #include <ycp/y2log.h>
30 #include "YQLogView.h"
31 #include "YQWidgetCaption.h"
34 YQLogView::YQLogView( YWidget * parent,
38 : QVBox( (QWidget *) parent->widgetRep() )
39 , YLogView( parent, label, visibleLines, maxLines )
43 setSpacing( YQWidgetSpacing );
44 setMargin( YQWidgetMargin );
46 _caption = new YQWidgetCaption( this, label );
47 YUI_CHECK_NEW( _caption );
49 _qt_text = new QMultiLineEdit( this );
50 YUI_CHECK_NEW( _qt_text );
52 _qt_text->setReadOnly( true );
53 _qt_text->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
55 _caption->setBuddy( _qt_text );
59 YQLogView::~YQLogView()
66 YQLogView::displayLogText( const string & text )
68 _qt_text->setText( fromUTF8( text ) );
69 _qt_text->scrollToBottom();
74 YQLogView::setLabel( const string & label )
76 _caption->setText( label );
77 YLogView::setLabel( label );
83 YQLogView::setEnabled( bool enabled )
85 _caption->setEnabled( enabled );
86 _qt_text->setEnabled( enabled );
87 YWidget::setEnabled( enabled );
92 YQLogView::preferredWidth()
94 return max( 50, sizeHint().width() );
99 YQLogView::preferredHeight()
101 int hintHeight = visibleLines() * _qt_text->fontMetrics().lineSpacing();
102 hintHeight += _qt_text->style().scrollBarExtent().height();
103 hintHeight += _qt_text->frameWidth() * 2;
105 if ( _caption->isShown() )
106 hintHeight += _caption->sizeHint().height();
108 return max( 80, hintHeight );
113 YQLogView::setSize( int newWidth, int newHeight )
115 resize( newWidth, newHeight );
120 YQLogView::setKeyboardFocus()
122 _qt_text->setFocus();
129 #include "YQLogView.moc"