QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
21 class QToolButton;
22 class QLineEdit;
23 
27 class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
28 {
29  Q_OBJECT
30  Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull )
31 
32  public:
33  explicit QgsDateTimeEdit( QWidget *parent = nullptr );
34 
36  void setAllowNull( bool allowNull );
37  bool allowNull() const {return mAllowNull;}
38 
43  void setDateTime( const QDateTime &dateTime );
44 
49  QDateTime dateTime() const;
50 
53  virtual void clear() override;
54 
58  void setEmpty();
59 
60  protected:
61  virtual void resizeEvent( QResizeEvent* event ) override;
62  void mousePressEvent( QMouseEvent*event ) override;
63  void focusOutEvent( QFocusEvent *event ) override;
64  void wheelEvent( QWheelEvent *event ) override;
65  void showEvent( QShowEvent *event ) override;
66 
67 
68  private slots:
69  void changed( const QDateTime &dateTime );
70 
71  private:
72  int spinButtonWidth() const;
73  int frameWidth() const;
74 
75  void displayNull( bool updateCalendar = false );
76 
78  void resetBeforeChange( int delta );
79 
80  bool mAllowNull;
81  bool mIsNull;
82  bool mIsEmpty;
83 
84  QLineEdit* mNullLabel;
85  QToolButton* mClearButton;
86  QString mOriginalStyleSheet;
87 };
88 
89 #endif // QGSDATETIMEEDIT_H
virtual void wheelEvent(QWheelEvent *event)
bool allowNull() const
virtual void clear()
virtual void showEvent(QShowEvent *event)
virtual void mousePressEvent(QMouseEvent *event)
void setDateTime(const QDateTime &dateTime)
virtual void resizeEvent(QResizeEvent *event)
virtual void focusOutEvent(QFocusEvent *event)
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times...