QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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
211 void setMinimumEditDateTime();
212
213 friend class TestQgsDateTimeEdit;
214};
215
216
231class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
232{
233 Q_OBJECT
234
235 public:
236
243 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
244
249 void setTime( const QTime &time );
250
251 signals:
252
256 void timeValueChanged( const QTime &time );
257
258 protected:
259 void emitValueChanged( const QVariant &value ) override;
260
261};
262
277class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
278{
279 Q_OBJECT
280
281 public:
282
289 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
290
295 void setDate( const QDate &date );
296
297 signals:
298
302 void dateValueChanged( const QDate &date );
303
304 protected:
305 void emitValueChanged( const QVariant &value ) override;
306
307};
308
309#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