26 #define YUILogComponent "qt-ui" 27 #include <yui/YUILog.h> 29 #include <qdatetimeedit.h> 30 #include <QVBoxLayout> 34 #include "YQDateField.h" 36 #include "YQWidgetCaption.h" 40 : QFrame( (QWidget *) parent->widgetRep() )
41 , YDateField( parent, label )
43 QVBoxLayout* layout =
new QVBoxLayout(
this );
47 layout->setSpacing( YQWidgetSpacing );
48 layout->setMargin ( YQWidgetMargin );
51 YUI_CHECK_NEW( _caption );
52 layout->addWidget( _caption );
54 _qt_dateEdit =
new QDateEdit(
this );
55 YUI_CHECK_NEW( _qt_dateEdit );
56 layout->addWidget( _qt_dateEdit );
59 _qt_dateEdit->setDisplayFormat(
"yyyy-MM-dd" );
60 _qt_dateEdit->setCalendarPopup(
true);
61 _caption->setBuddy( _qt_dateEdit );
63 connect( _qt_dateEdit, &QDateEdit::dateChanged,
64 this, &YQDateField::changed);
76 return toUTF8( _qt_dateEdit->date().toString( Qt::ISODate ) );
82 _qt_dateEdit->blockSignals(
true);
83 _qt_dateEdit->setDate( QDate::fromString( fromUTF8( newValue ), Qt::ISODate ) );
84 _qt_dateEdit->blockSignals(
false);
90 _caption->
setText( fromUTF8( newLabel ) );
91 YDateField::setLabel( newLabel );
97 QFrame::setEnabled( enabled );
98 YWidget::setEnabled( enabled );
104 return sizeHint().width();
110 return sizeHint().height();
116 resize( newWidth, newHeight );
122 _qt_dateEdit->setFocus();
127 void YQDateField::changed (
const QDate& )
133 #include "YQDateField.moc"
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
YQDateField(YWidget *parent, const std::string &label)
Constructor.
virtual void setValue(const std::string &newValue)
Set the current value (the text entered by the user or set from the outside) of this input field...
virtual int preferredWidth()
Preferred width of the widget.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual bool setKeyboardFocus()
Accept the keyboard focus.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
virtual std::string value()
Get the current value (the text entered by the user or set from the outside) of this input field...
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
virtual int preferredHeight()
Preferred height of the widget.
virtual ~YQDateField()
Destructor.
static YQUI * ui()
Access the global Qt-UI.