QGIS API Documentation  3.0.2-Girona (307d082)
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 
40  explicit QgsDateTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
41 
43  void setAllowNull( bool allowNull );
44  bool allowNull() const {return mAllowNull;}
45 
50  void setDateTime( const QDateTime &dateTime );
51 
56  QDateTime dateTime() const;
57 
62  void clear() override;
63 
68  void setEmpty();
69 
70  signals:
71 
76  void valueChanged( const QDateTime &date );
77 
78  protected:
79  void mousePressEvent( QMouseEvent *event ) override;
80  void focusOutEvent( QFocusEvent *event ) override;
81  void wheelEvent( QWheelEvent *event ) override;
82  void showEvent( QShowEvent *event ) override;
83 
84  private slots:
85  void changed( const QDateTime &dateTime );
86 
87  private:
88  bool mAllowNull = true;
89  bool mIsNull = false;
90  bool mIsEmpty = false;
91  bool mCurrentPressEvent = false;
92 
93  QString mOriginalStyleSheet = QString();
94  QAction *mClearAction;
95 
96  void displayNull( bool updateCalendar = false );
97 
99  void resetBeforeChange( int delta );
100 
112  void setMinimumEditDateTime()
113  {
114  setMinimumDateTime( QDateTime::fromString( QStringLiteral( "0100-01-01" ), Qt::ISODate ) );
115  }
116 };
117 
118 #endif // QGSDATETIMEEDIT_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
bool allowNull() const
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times...