17 #include <QDateTimeEdit>
30 , mQDateTimeEdit( NULL )
31 , mQgsDateTimeEdit( NULL )
38 widget->
setDateTime( QDateTime::currentDateTime() );
47 mQgsDateTimeEdit = qgsEditor;
52 QDateTimeEdit* qtEditor =
dynamic_cast<QDateTimeEdit*
>( editor );
55 mQDateTimeEdit = qtEditor;
58 if ( !mQDateTimeEdit )
60 QgsDebugMsg(
"Date/time edit widget could not be initialized because provided widget is not a QDateTimeEdit." );
66 mQDateTimeEdit->setDisplayFormat( displayFormat );
68 const bool calendar =
config(
"calendar_popup",
false ).toBool();
69 mQDateTimeEdit->setCalendarPopup( calendar );
71 const bool allowNull =
config(
"allow_null",
true ).toBool();
72 if ( mQgsDateTimeEdit )
79 "For that the QGIS custom widget QgsDateTimeEdit needs to be used." ),
83 if ( mQgsDateTimeEdit )
85 connect( mQgsDateTimeEdit, SIGNAL( dateTimeChanged( QDateTime ) ),
this, SLOT( dateTimeChanged( QDateTime ) ) );
89 connect( mQDateTimeEdit, SIGNAL( dateTimeChanged( QDateTime ) ),
this, SLOT( dateTimeChanged( QDateTime ) ) );
93 void QgsDateTimeEditWrapper::dateTimeChanged(
const QDateTime& dateTime )
101 if ( !mQDateTimeEdit )
102 return QVariant(
field().type() );
106 if ( mQgsDateTimeEdit )
108 return mQgsDateTimeEdit->
dateTime().toString( fieldFormat );
112 return mQDateTimeEdit->dateTime().toString( fieldFormat );
118 if ( !mQDateTimeEdit )
122 const QDateTime date = QDateTime::fromString( value.toString(), fieldFormat );
124 if ( mQgsDateTimeEdit )
130 mQDateTimeEdit->setDateTime( date );
136 if ( !mQDateTimeEdit )
139 mQDateTimeEdit->setEnabled( enabled );