QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsdatetimeedit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdatetimeedit.h
3  --------------------------------------
4  Date : 08.2014
5  Copyright : (C) 2014 Denis Rouzaud
6  Email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSDATETIMEEDIT_H
17 #define QGSDATETIMEEDIT_H
18 
19 #include <QDateTimeEdit>
20 #include "qgis.h"
21 #include "qgis_gui.h"
22 
32 class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
33 {
34  Q_OBJECT
35  Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull )
36 
37  public:
38 
44  explicit QgsDateTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
45 
50  void setAllowNull( bool allowNull );
51 
56  bool allowNull() const {return mAllowNull;}
57 
62  void setDateTime( const QDateTime &dateTime );
63 
69  QDateTime dateTime() const;
70 
75  void clear() override;
76 
81  void setEmpty();
82 
83  signals:
84 
89  void valueChanged( const QDateTime &date );
90 
91  protected:
92  void mousePressEvent( QMouseEvent *event ) override;
93  void focusOutEvent( QFocusEvent *event ) override;
94  void wheelEvent( QWheelEvent *event ) override;
95  void showEvent( QShowEvent *event ) override;
96 
97  private slots:
98  void changed( const QDateTime &dateTime );
99 
100  private:
101  bool mAllowNull = true;
102  bool mIsNull = false;
103  bool mIsEmpty = false;
104  bool mCurrentPressEvent = false;
105 
106  QString mOriginalStyleSheet = QString();
107  QAction *mClearAction;
108 
109  void displayNull( bool updateCalendar = false );
110 
112  void resetBeforeChange( int delta );
113 
125  void setMinimumEditDateTime()
126  {
127  setMinimumDateTime( QDateTime::fromString( QStringLiteral( "0100-01-01" ), Qt::ISODate ) );
128  }
129 };
130 
131 #endif // QGSDATETIMEEDIT_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
bool allowNull() const
If the widget allows setting null date/time.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times...