Skip to content
Permalink
Browse files

Merge pull request #4842 from mj10777/master3.qgsdatetimeedit

changes to QgsDateTimeEdit to support the minimal Date supported by Q…
  • Loading branch information
nyalldawson committed Jul 13, 2017
2 parents 64575b3 + 6434d8d commit 93a8025bb28b9d456b88ec3570d41090e0105375
Showing with 16 additions and 0 deletions.
  1. +1 −0 src/gui/editorwidgets/qgsdatetimeedit.cpp
  2. +15 −0 src/gui/editorwidgets/qgsdatetimeedit.h
@@ -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 )
@@ -82,6 +82,21 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
QLineEdit *mNullLabel = nullptr;
QToolButton *mClearButton = nullptr;

/** 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
* \note not available in Python bindings
*/
void setMinimumEditDateTime()
{
setMinimumDateTime( QDateTime::fromString( "0100-01-01", Qt::ISODate ) );
}

};

#endif // QGSDATETIMEEDIT_H

0 comments on commit 93a8025

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