Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
do not override QDateTimeEdit::dateTimeChanged
- Loading branch information
|
@@ -15,8 +15,8 @@ class QgsDateTimeEdit : QDateTimeEdit |
|
|
|
|
|
.. warning:: |
|
|
|
|
|
You should use the signal dateTimeChanged of this subclass QgsDateTimeEdit |
|
|
rather than parent's one (QDateTimeEdit). If you consequently connect parent's |
|
|
You should use the signal valueChanged of this subclass |
|
|
rather than QDateTimeEdit.dateTimeChanged. If you consequently connect parent's |
|
|
dateTimeChanged signal and call dateTime() afterwards there is no warranty to |
|
|
have a proper NULL value handling. |
|
|
%End |
|
@@ -74,10 +74,9 @@ Resets the widget to show no value (ie, an "unknown" state). |
|
|
|
|
|
signals: |
|
|
|
|
|
void dateTimeChanged( const QDateTime &date ); |
|
|
void valueChanged( const QDateTime &date ); |
|
|
%Docstring |
|
|
reimplements QDateTimeEdit.dateTimeChanged signal |
|
|
to properly handles NULL values. |
|
|
signal emitted whenever the value changes. |
|
|
@param date the new date/time value. |
|
|
%End |
|
|
|
|
|
|
@@ -61,6 +61,15 @@ void QgsDateTimeEdit::clear() |
|
|
displayNull(); |
|
|
|
|
|
changed( QDateTime() ); |
|
|
|
|
|
// emit signal of QDateTime::dateTimeChanged with an invalid date |
|
|
// anyway, using parent's signal should be avoided |
|
|
// If you consequently connect parent's dateTimeChanged signal |
|
|
// and call dateTime() afterwards there is no warranty to |
|
|
// have a proper NULL value handling |
|
|
disconnect( this, &QDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEdit::changed ); |
|
|
emit dateTimeChanged( QDateTime() ); |
|
|
connect( this, &QDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEdit::changed ); |
|
|
} |
|
|
} |
|
|
|
|
@@ -170,7 +179,7 @@ void QgsDateTimeEdit::changed( const QDateTime &dateTime ) |
|
|
|
|
|
mClearAction->setVisible( mAllowNull && !mIsNull ); |
|
|
|
|
|
emit QgsDateTimeEdit::dateTimeChanged( dateTime ); |
|
|
emit QgsDateTimeEdit::valueChanged( dateTime ); |
|
|
} |
|
|
|
|
|
void QgsDateTimeEdit::displayNull( bool updateCalendar ) |
|
|
|
@@ -24,8 +24,8 @@ |
|
|
* \ingroup gui |
|
|
* \brief The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times. |
|
|
* |
|
|
* \warning You should use the signal dateTimeChanged of this subclass QgsDateTimeEdit |
|
|
* rather than parent's one (QDateTimeEdit). If you consequently connect parent's |
|
|
* \warning You should use the signal valueChanged of this subclass |
|
|
* rather than QDateTimeEdit::dateTimeChanged. If you consequently connect parent's |
|
|
* dateTimeChanged signal and call dateTime() afterwards there is no warranty to |
|
|
* have a proper NULL value handling. |
|
|
*/ |
|
@@ -70,11 +70,10 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit |
|
|
signals: |
|
|
|
|
|
/** |
|
|
* reimplements QDateTimeEdit::dateTimeChanged signal |
|
|
* to properly handles NULL values. |
|
|
* signal emitted whenever the value changes. |
|
|
* @param date the new date/time value. |
|
|
*/ |
|
|
void dateTimeChanged( const QDateTime &date ); |
|
|
void valueChanged( const QDateTime &date ); |
|
|
|
|
|
protected: |
|
|
void mousePressEvent( QMouseEvent *event ) override; |
|
|
|
@@ -93,7 +93,7 @@ void QgsDateTimeEditWrapper::initWidget( QWidget *editor ) |
|
|
|
|
|
if ( mQgsDateTimeEdit ) |
|
|
{ |
|
|
connect( mQgsDateTimeEdit, &QgsDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEditWrapper::dateTimeChanged ); |
|
|
connect( mQgsDateTimeEdit, &QgsDateTimeEdit::valueChanged, this, &QgsDateTimeEditWrapper::dateTimeChanged ); |
|
|
} |
|
|
else |
|
|
{ |
|
|