QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QDateTimeEdit>
23
37class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
38{
39 Q_OBJECT
40 Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull )
41
42 public:
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
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
214};
215
216
231class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
232{
233 Q_OBJECT
234
235 public:
242 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
243
248 void setTime( const QTime &time );
249
250 signals:
251
255 void timeValueChanged( const QTime &time );
256
257 protected:
258 void emitValueChanged( const QVariant &value ) override;
259};
260
275class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
276{
277 Q_OBJECT
278
279 public:
286 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
287
292 void setDate( const QDate &date );
293
294 signals:
295
299 void dateValueChanged( const QDate &date );
300
301 protected:
302 void emitValueChanged( const QVariant &value ) override;
303};
304
305#endif // QGSDATETIMEEDIT_H
void setDate(const QDate &date)
Sets the date for the widget and handles null dates.
void dateValueChanged(const QDate &date)
Signal emitted whenever the date changes.
QgsDateEdit(QWidget *parent=nullptr)
Constructor for QgsDateEdit.
void emitValueChanged(const QVariant &value) override
Emits the widget's correct value changed signal.
bool allowNull() const
If the widget allows setting null date/time.
void wheelEvent(QWheelEvent *event) override
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
friend class TestQgsDateTimeEdit
int mBlockChangedSignal
Block change signals if true.
void showEvent(QShowEvent *event) override
QDateTime dateTime() const
Returns the date time which can be a null date/time.
void focusInEvent(QFocusEvent *event) override
bool isNull() const
Returns true if the widget is currently set to a null value.
virtual void emitValueChanged(const QVariant &value)
Emits the widget's correct value changed signal.
void mousePressEvent(QMouseEvent *event) override
QTime time() const
Returns the time which can be a null time.
void focusOutEvent(QFocusEvent *event) override
bool mIsEmpty
true if the widget is empty
void displayNull(bool updateCalendar=false)
write the null value representation to the line edit without changing the value
bool event(QEvent *event) override
Reimplemented to enable/disable the clear action depending on read-only status.
QgsDateTimeEdit(QWidget *parent=nullptr)
Constructor for QgsDateTimeEdit.
QDate date() const
Returns the date which can be a null date.
void valueChanged(const QDateTime &date)
Signal emitted whenever the value changes.
QgsTimeEdit(QWidget *parent=nullptr)
Constructor for QgsTimeEdit.
void emitValueChanged(const QVariant &value) override
Emits the widget's correct value changed signal.
void timeValueChanged(const QTime &time)
Signal emitted whenever the time changes.
void setTime(const QTime &time)
Sets the time for the widget and handles null times.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53