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 <q3datetimeedit.h>
25 #include <QVBoxLayout>
29 #include "YQDateField.h"
30 #include "YQWidgetCaption.h"
33 YQDateField::YQDateField( YWidget * parent, const string & label )
34 : QFrame( (QWidget *) parent->widgetRep() )
35 , YDateField( parent, label )
37 QVBoxLayout* layout = new QVBoxLayout( this );
41 layout->setSpacing( YQWidgetSpacing );
42 layout->setMargin ( YQWidgetMargin );
44 _caption = new YQWidgetCaption( this, fromUTF8( label ) );
45 YUI_CHECK_NEW( _caption );
46 layout->addWidget( _caption );
48 _qt_dateEdit = new Q3DateEdit( this );
49 YUI_CHECK_NEW( _qt_dateEdit );
50 layout->addWidget( _qt_dateEdit );
52 //_qt_dateEdit->setAutoAdvance( true );
53 _qt_dateEdit->setOrder( Q3DateEdit::DMY );
54 _caption->setBuddy( _qt_dateEdit );
58 YQDateField::~YQDateField()
64 string YQDateField::value()
66 return toUTF8( _qt_dateEdit->date().toString( Qt::ISODate ) );
70 void YQDateField::setValue( const string & newValue )
72 _qt_dateEdit->setDate( QDate::fromString( fromUTF8( newValue ), Qt::ISODate ) );
77 void YQDateField::setLabel( const string & newLabel )
79 _caption->setText( fromUTF8( newLabel ) );
80 YDateField::setLabel( newLabel );
84 void YQDateField::setEnabled( bool enabled )
86 QFrame::setEnabled( enabled );
87 YWidget::setEnabled( enabled );
91 int YQDateField::preferredWidth()
93 return sizeHint().width();
97 int YQDateField::preferredHeight()
99 return sizeHint().height();
103 void YQDateField::setSize( int newWidth, int newHeight )
105 resize( newWidth, newHeight );
109 bool YQDateField::setKeyboardFocus()
111 _qt_dateEdit->setFocus();
118 #include "YQDateField.moc"