QGIS API Documentation 3.99.0-Master (d270888f95f)
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 QgsDateTimeEdit( const QVariant &var, QMetaType::Type parserType, QWidget *parent );
144#endif
145
147 bool mIsEmpty = false;
148
151
156 void displayNull( bool updateCalendar = false );
157
161 virtual void emitValueChanged( const QVariant &value );
162
166 bool isNull() const;
167
168 protected slots:
169#ifndef SIP_RUN
171 void changed( const QVariant &dateTime );
173#endif
174
175
176 private:
177 bool mCurrentPressEvent = false;
178
179 QString mOriginalStyleSheet = QString();
180 QAction *mClearAction;
181 QString mNullRepresentation;
182
184 bool mAllowNull = true;
185
187 bool mIsNull = false;
188
192 void displayCurrentDate();
193
195 void resetBeforeChange( int delta );
196
207 void setMinimumEditDateTime();
208
210};
211
212
227class GUI_EXPORT QgsTimeEdit : public QgsDateTimeEdit
228{
229 Q_OBJECT
230
231 public:
238 explicit QgsTimeEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
239
244 void setTime( const QTime &time );
245
246 signals:
247
251 void timeValueChanged( const QTime &time );
252
253 protected:
254 void emitValueChanged( const QVariant &value ) override;
255};
256
271class GUI_EXPORT QgsDateEdit : public QgsDateTimeEdit
272{
273 Q_OBJECT
274
275 public:
282 explicit QgsDateEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
283
288 void setDate( const QDate &date );
289
290 signals:
291
295 void dateValueChanged( const QDate &date );
296
297 protected:
298 void emitValueChanged( const QVariant &value ) override;
299};
300
301#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