QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
48 explicit QgsDateTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
54 void setAllowNull( bool allowNull );
55
60 bool allowNull() const { return mAllowNull; }
61
66 void setDateTime( const QDateTime &dateTime );
67
73 QDateTime dateTime() const;
74
79 QTime time() const;
80
85 QDate date() const;
86
91 void clear() override;
92
96 void setEmpty();
97
105 QString nullRepresentation() const;
106
114 void setNullRepresentation( const QString &null );
115
122 bool event( QEvent *event ) override;
123
124 signals:
125
130 void valueChanged( const QDateTime &date );
131
132 protected:
133 void mousePressEvent( QMouseEvent *event ) override;
134 void focusOutEvent( QFocusEvent *event ) override;
135 void focusInEvent( QFocusEvent *event ) override;
136 void wheelEvent( QWheelEvent *event ) override;
137 void showEvent( QShowEvent *event ) override;
138
139#ifndef SIP_RUN
141#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
142 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
143#else
144 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
145#endif
147#endif
148
150 bool mIsEmpty = false;
151
153 int mBlockChangedSignal = 0;
154
159 void displayNull( bool updateCalendar = false );
160
164 virtual void emitValueChanged( const QVariant &value );
165
169 bool isNull() const;
170
171 protected slots:
172#ifndef SIP_RUN
174 void changed( const QVariant &dateTime );
176#endif
177
178
179 private:
180 bool mCurrentPressEvent = false;
181
182 QString mOriginalStyleSheet = QString();
183 QAction *mClearAction;
184 QString mNullRepresentation;
185
187 bool mAllowNull = true;
188
190 bool mIsNull = false;
191
195 void displayCurrentDate();
196
198 void resetBeforeChange( int delta );
199
210 void setMinimumEditDateTime();
211
212 friend class TestQgsDateTimeEdit;
213};
214
215
230class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
231{
232 Q_OBJECT
233
234 public:
241 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
242
247 void setTime( const QTime &time );
248
249 signals:
250
254 void timeValueChanged( const QTime &time );
255
256 protected:
257 void emitValueChanged( const QVariant &value ) override;
258};
259
274class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
275{
276 Q_OBJECT
277
278 public:
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#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