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 _qt_timeEdit->setDisplayFormat( "hh:mm:ss");
50 layout->addWidget( _qt_timeEdit );
52 _caption->setBuddy( _qt_timeEdit );
56 YQTimeField::~YQTimeField()
62 string YQTimeField::value()
64 return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
68 void YQTimeField::setValue( const string & newValue )
70 _qt_timeEdit->setTime( QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
74 void YQTimeField::setLabel( const string & newLabel )
76 _caption->setText( fromUTF8( newLabel ) );
77 YTimeField::setLabel( newLabel );
81 void YQTimeField::setEnabled( bool enabled )
83 QFrame::setEnabled( enabled );
84 YWidget::setEnabled( enabled );
88 int YQTimeField::preferredWidth()
90 return sizeHint().width();
94 int YQTimeField::preferredHeight()
96 return sizeHint().height();
100 void YQTimeField::setSize( int newWidth, int newHeight )
102 resize( newWidth, newHeight );
106 bool YQTimeField::setKeyboardFocus()
108 _qt_timeEdit->setFocus();
114 #include "YQTimeField.moc"