QGIS API Documentation 3.37.0-Master (df6056bf1be)
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
97 void setEmpty();
98
106 QString nullRepresentation() const;
107
115 void setNullRepresentation( const QString &null );
116
123 bool event( QEvent *event ) override;
124
125 signals:
126
131 void valueChanged( const QDateTime &date );
132
133 protected:
134 void mousePressEvent( QMouseEvent *event ) override;
135 void focusOutEvent( QFocusEvent *event ) override;
136 void focusInEvent( QFocusEvent *event ) override;
137 void wheelEvent( QWheelEvent *event ) override;
138 void showEvent( QShowEvent *event ) override;
139
140#ifndef SIP_RUN
142#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
143 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
144#else
145 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
146#endif
148#endif
149
151 bool mIsEmpty = false;
152
154 int mBlockChangedSignal = 0;
155
160 void displayNull( bool updateCalendar = false );
161
165 virtual void emitValueChanged( const QVariant &value );
166
170 bool isNull() const;
171
172 protected slots:
173#ifndef SIP_RUN
175 void changed( const QVariant &dateTime );
177#endif
178
179
180 private:
181 bool mCurrentPressEvent = false;
182
183 QString mOriginalStyleSheet = QString();
184 QAction *mClearAction;
185 QString mNullRepresentation;
186
188 bool mAllowNull = true;
189
191 bool mIsNull = false;
192
196 void displayCurrentDate();
197
199 void resetBeforeChange( int delta );
200
213 void setMinimumEditDateTime();
214
215 friend class TestQgsDateTimeEdit;
216};
217
218
233class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
234{
235 Q_OBJECT
236
237 public:
238
245 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
246
251 void setTime( const QTime &time );
252
253 signals:
254
258 void timeValueChanged( const QTime &time );
259
260 protected:
261 void emitValueChanged( const QVariant &value ) override;
262
263};
264
279class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
280{
281 Q_OBJECT
282
283 public:
284
291 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
292
297 void setDate( const QDate &date );
298
299 signals:
300
304 void dateValueChanged( const QDate &date );
305
306 protected:
307 void emitValueChanged( const QVariant &value ) override;
308
309};
310
311#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