QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsdatetimeedit.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatetimeedit.h
3 --------------------------------------
4 Date : 08.2014
5 Copyright : (C) 2014 Denis Rouzaud
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_sip.h"
21#include "qgis_gui.h"
22
36class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
37{
38 Q_OBJECT
39 Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull )
40
41 public:
42
49 explicit QgsDateTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
50
55 void setAllowNull( bool allowNull );
56
61 bool allowNull() const {return mAllowNull;}
62
67 void setDateTime( const QDateTime &dateTime );
68
74 QDateTime dateTime() const;
75
80 QTime time() const;
81
86 QDate date() const;
87
92 void clear() override;
93
98 void setEmpty();
99
107 QString nullRepresentation() const;
108
116 void setNullRepresentation( const QString &null );
117
118 signals:
119
124 void valueChanged( const QDateTime &date );
125
126 protected:
127 void mousePressEvent( QMouseEvent *event ) override;
128 void focusOutEvent( QFocusEvent *event ) override;
129 void focusInEvent( QFocusEvent *event ) override;
130 void wheelEvent( QWheelEvent *event ) override;
131 void showEvent( QShowEvent *event ) override;
132
133#ifndef SIP_RUN
135#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
136 QgsDateTimeEdit( const QVariant &var, QVariant::Type parserType, QWidget *parent );
137#else
138 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
139#endif
141#endif
142
144 bool mIsEmpty = false;
145
147 int mBlockChangedSignal = 0;
148
153 void displayNull( bool updateCalendar = false );
154
158 virtual void emitValueChanged( const QVariant &value );
159
163 bool isNull() const;
164
165 protected slots:
166#ifndef SIP_RUN
168 void changed( const QVariant &dateTime );
170#endif
171
172
173 private:
174 bool mCurrentPressEvent = false;
175
176 QString mOriginalStyleSheet = QString();
177 QAction *mClearAction;
178 QString mNullRepresentation;
179
181 bool mAllowNull = true;
182
184 bool mIsNull = false;
185
189 void displayCurrentDate();
190
192 void resetBeforeChange( int delta );
193
207 void setMinimumEditDateTime();
208
209 friend class TestQgsDateTimeEdit;
210};
211
212
227class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
228{
229 Q_OBJECT
230
231 public:
232
239 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
240
245 void setTime( const QTime &time );
246
247 signals:
248
252 void timeValueChanged( const QTime &time );
253
254 protected:
255 void emitValueChanged( const QVariant &value ) override;
256
257};
258
273class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
274{
275 Q_OBJECT
276
277 public:
278
285 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
286
291 void setDate( const QDate &date );
292
293 signals:
294
298 void dateValueChanged( const QDate &date );
299
300 protected:
301 void emitValueChanged( const QVariant &value ) override;
302
303};
304
305#endif // QGSDATETIMEEDIT_H
The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
bool allowNull() const
If the widget allows setting null date/time.
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
The QgsTimeEdit class is a QTimeEdit widget with the capability of setting/reading null date/times.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53