Skip to content
Permalink
Browse files

changes to QgsDateTimeEdit to support the minimal Date supported by Q…

…DateTimeEdit (0100-01-01)
  • Loading branch information
mj10777 committed Jul 12, 2017
1 parent ad31087 commit b7ff59c064991a3bb349e9c6526702d5afadfe83
@@ -30,6 +30,18 @@ Determines if the widget allows setting null date/time.
:rtype: bool
%End

void setMinimumEditDateTime();
%Docstring
Set the lowest Date that can be displayed with the Qt.ISODate format
- uses QDateTimeEdit.setMinimumDateTime (since Qt 4.4)
\note
- QDate and QDateTime does not support minus years for the Qt.ISODate format
-> returns empty (toString) or invalid (fromString) values
- QDateTimeEdit.setMinimumDateTime does not support dates < '0100-01-01'
-> it is not for us to wonder why [defined in qdatetimeparser_p.h]
.. versionadded:: 3.0
%End

void setDateTime( const QDateTime &dateTime );
%Docstring
setDateTime set the date time in the widget and handles null date times.
@@ -52,6 +52,7 @@ QgsDateTimeEdit::QgsDateTimeEdit( QWidget *parent )

// init with current time so mIsNull is properly initialized
QDateTimeEdit::setDateTime( QDateTime::currentDateTime() );
setMinimumEditDateTime();
}

void QgsDateTimeEdit::setAllowNull( bool allowNull )
@@ -38,6 +38,20 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
void setAllowNull( bool allowNull );
bool allowNull() const {return mAllowNull;}

/** Set the lowest Date that can be displayed with the Qt::ISODate format
* - uses QDateTimeEdit::setMinimumDateTime (since Qt 4.4)
* \note
* - QDate and QDateTime does not support minus years for the Qt::ISODate format
* -> returns empty (toString) or invalid (fromString) values
* - QDateTimeEdit::setMinimumDateTime does not support dates < '0100-01-01'
* -> it is not for us to wonder why [defined in qdatetimeparser_p.h]
* \since QGIS 3.0
*/
void setMinimumEditDateTime()
{
setMinimumDateTime( QDateTime::fromString( "0100-01-01", Qt::ISODate ) );
}

/**
* \brief setDateTime set the date time in the widget and handles null date times.
* \note since QDateTimeEdit::setDateTime() is not virtual, setDateTime must be called for QgsDateTimeEdit.

0 comments on commit b7ff59c

Please sign in to comment.
You can’t perform that action at this time.