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>
24 #include <QVBoxLayout>
28 #include "YQDateField.h"
29 #include "YQWidgetCaption.h"
32 YQDateField::YQDateField( YWidget * parent, const string & label )
33 : QFrame( (QWidget *) parent->widgetRep() )
34 , YDateField( parent, label )
36 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_dateEdit = new QDateEdit( this );
48 YUI_CHECK_NEW( _qt_dateEdit );
49 layout->addWidget( _qt_dateEdit );
51 //_qt_dateEdit->setAutoAdvance( true );
52 _qt_dateEdit->setDisplayFormat( "dd.MM.yyyy" );
53 _caption->setBuddy( _qt_dateEdit );
57 YQDateField::~YQDateField()
63 string YQDateField::value()
65 return toUTF8( _qt_dateEdit->date().toString( Qt::ISODate ) );
69 void YQDateField::setValue( const string & newValue )
71 _qt_dateEdit->setDate( QDate::fromString( fromUTF8( newValue ), Qt::ISODate ) );
76 void YQDateField::setLabel( const string & newLabel )
78 _caption->setText( fromUTF8( newLabel ) );
79 YDateField::setLabel( newLabel );
83 void YQDateField::setEnabled( bool enabled )
85 QFrame::setEnabled( enabled );
86 YWidget::setEnabled( enabled );
90 int YQDateField::preferredWidth()
92 return sizeHint().width();
96 int YQDateField::preferredHeight()
98 return sizeHint().height();
102 void YQDateField::setSize( int newWidth, int newHeight )
104 resize( newWidth, newHeight );
108 bool YQDateField::setKeyboardFocus()
110 _qt_dateEdit->setFocus();
117 #include "YQDateField.moc"