Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 93a8025
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsdatetimeedit.cpp
Expand Up @@ -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 )
Expand Down
15 changes: 15 additions & 0 deletions src/gui/editorwidgets/qgsdatetimeedit.h
Expand Up @@ -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.