QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
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
124 bool event( QEvent *event ) override;
125
126 signals:
127
132 void valueChanged( const QDateTime &date );
133
134 protected:
135 void mousePressEvent( QMouseEvent *event ) override;
136 void focusOutEvent( QFocusEvent *event ) override;
137 void focusInEvent( QFocusEvent *event ) override;
138 void wheelEvent( QWheelEvent *event ) override;
139 void showEvent( QShowEvent *event ) override;
140
141#ifndef SIP_RUN
143#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
144 QgsDateTimeEdit( const QVariant &var, QVariant::Type parserType, QWidget *parent );
145#else
146 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
147#endif
149#endif
150
152 bool mIsEmpty = false;
153
155 int mBlockChangedSignal = 0;
156
161 void displayNull( bool updateCalendar = false );
162
166 virtual void emitValueChanged( const QVariant &value );
167
171 bool isNull() const;
172
173 protected slots:
174#ifndef SIP_RUN
176 void changed( const QVariant &dateTime );
178#endif
179
180
181 private:
182 bool mCurrentPressEvent = false;
183
184 QString mOriginalStyleSheet = QString();
185 QAction *mClearAction;
186 QString mNullRepresentation;
187
189 bool mAllowNull = true;
190
192 bool mIsNull = false;
193
197 void displayCurrentDate();
198
200 void resetBeforeChange( int delta );
201
215 void setMinimumEditDateTime();
216
217 friend class TestQgsDateTimeEdit;
218};
219
220
235class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
236{
237 Q_OBJECT
238
239 public:
240
247 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
248
253 void setTime( const QTime &time );
254
255 signals:
256
260 void timeValueChanged( const QTime &time );
261
262 protected:
263 void emitValueChanged( const QVariant &value ) override;
264
265};
266
281class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
282{
283 Q_OBJECT
284
285 public:
286
293 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
294
299 void setDate( const QDate &date );
300
301 signals:
302
306 void dateValueChanged( const QDate &date );
307
308 protected:
309 void emitValueChanged( const QVariant &value ) override;
310
311};
312
313#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