1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
23 #include <qdatetimeedit.h>
27 #include "YQTimeField.h"
28 #include "YQWidgetCaption.h"
32 YQTimeField::YQTimeField( YWidget * parent, const string & label )
33 : QVBox( (QWidget *) parent->widgetRep() )
34 , YTimeField( parent, label )
37 setSpacing( YQWidgetSpacing );
38 setMargin ( YQWidgetMargin );
40 _caption = new YQWidgetCaption( this, fromUTF8( label ) );
41 YUI_CHECK_NEW( _caption );
43 _qt_timeEdit = new QTimeEdit( this );
44 YUI_CHECK_NEW( _qt_timeEdit );
46 _qt_timeEdit->setAutoAdvance( true );
47 _caption->setBuddy( _qt_timeEdit );
51 YQTimeField::~YQTimeField()
57 string YQTimeField::value()
59 return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
63 void YQTimeField::setValue( const string & newValue )
65 _qt_timeEdit->setTime( QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
69 void YQTimeField::setLabel( const string & newLabel )
71 _caption->setText( fromUTF8( newLabel ) );
72 YTimeField::setLabel( newLabel );
76 void YQTimeField::setEnabled( bool enabled )
78 QVBox::setEnabled( enabled );
79 YWidget::setEnabled( enabled );
83 int YQTimeField::preferredWidth()
85 return sizeHint().width();
89 int YQTimeField::preferredHeight()
91 return sizeHint().height();
95 void YQTimeField::setSize( int newWidth, int newHeight )
97 resize( newWidth, newHeight );
101 bool YQTimeField::setKeyboardFocus()
103 _qt_timeEdit->setFocus();
109 #include "YQTimeField.moc"