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 "YQDateField.h"
28 #include "YQWidgetCaption.h"
31 YQDateField::YQDateField( YWidget * parent, const string & label )
32 : QVBox( (QWidget *) parent->widgetRep() )
33 , YDateField( parent, label )
36 setSpacing( YQWidgetSpacing );
37 setMargin ( YQWidgetMargin );
39 _caption = new YQWidgetCaption( this, fromUTF8( label ) );
40 YUI_CHECK_NEW( _caption );
42 _qt_dateEdit = new QDateEdit( this );
43 YUI_CHECK_NEW( _qt_dateEdit );
45 _qt_dateEdit->setAutoAdvance( true );
46 _qt_dateEdit->setOrder( QDateEdit::DMY );
47 _caption->setBuddy( _qt_dateEdit );
51 YQDateField::~YQDateField()
57 string YQDateField::value()
59 return toUTF8( _qt_dateEdit->date().toString( Qt::ISODate ) );
63 void YQDateField::setValue( const string & newValue )
65 _qt_dateEdit->setDate( QDate::fromString( fromUTF8( newValue ), Qt::ISODate ) );
70 void YQDateField::setLabel( const string & newLabel )
72 _caption->setText( fromUTF8( newLabel ) );
73 YDateField::setLabel( newLabel );
77 void YQDateField::setEnabled( bool enabled )
79 QVBox::setEnabled( enabled );
80 YWidget::setEnabled( enabled );
84 int YQDateField::preferredWidth()
86 return sizeHint().width();
90 int YQDateField::preferredHeight()
92 return sizeHint().height();
96 void YQDateField::setSize( int newWidth, int newHeight )
98 resize( newWidth, newHeight );
102 bool YQDateField::setKeyboardFocus()
104 _qt_dateEdit->setFocus();
111 #include "YQDateField.moc"