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"
29 #include <QVBoxLayout>
32 YQTimeField::YQTimeField( YWidget * parent, const string & label )
33 : QFrame( (QWidget *) parent->widgetRep() )
34 , YTimeField( parent, label )
37 QVBoxLayout* layout = new QVBoxLayout( this );
40 layout->setSpacing( YQWidgetSpacing );
41 layout->setMargin ( YQWidgetMargin );
43 _caption = new YQWidgetCaption( this, fromUTF8( label ) );
44 YUI_CHECK_NEW( _caption );
45 layout->addWidget( _caption );
47 _qt_timeEdit = new QTimeEdit( this );
48 YUI_CHECK_NEW( _qt_timeEdit );
49 layout->addWidget( _qt_timeEdit );
51 #warning FIXME setAutoAdvance does?
52 //_qt_timeEdit->setAutoAdvance( true );
53 _caption->setBuddy( _qt_timeEdit );
57 YQTimeField::~YQTimeField()
63 string YQTimeField::value()
65 return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
69 void YQTimeField::setValue( const string & newValue )
71 _qt_timeEdit->setTime( QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
75 void YQTimeField::setLabel( const string & newLabel )
77 _caption->setText( fromUTF8( newLabel ) );
78 YTimeField::setLabel( newLabel );
82 void YQTimeField::setEnabled( bool enabled )
84 QFrame::setEnabled( enabled );
85 YWidget::setEnabled( enabled );
89 int YQTimeField::preferredWidth()
91 return sizeHint().width();
95 int YQTimeField::preferredHeight()
97 return sizeHint().height();
101 void YQTimeField::setSize( int newWidth, int newHeight )
103 resize( newWidth, newHeight );
107 bool YQTimeField::setKeyboardFocus()
109 _qt_timeEdit->setFocus();
115 #include "YQTimeField.moc"