16 #include <QCalendarWidget> 18 #include <QMouseEvent> 21 #include <QStyleOptionSpinBox> 22 #include <QToolButton> 37 mClearButton->
setCursor( Qt::ArrowCursor );
38 mClearButton->
setStyleSheet(
"position: absolute; border: none; padding: 0px;" );
40 connect( mClearButton, SIGNAL( clicked() ),
this, SLOT(
clear() ) );
42 setStyleSheet(
QString(
".QWidget, QLineEdit, QToolButton { padding-right: %1px; }" ).arg( mClearButton->
sizeHint().
width() + spinButtonWidth() + frameWidth() + 1 ) );
61 mClearButton->
setVisible( mAllowNull && ( !mIsNull || mIsEmpty ) );
92 bool updateCalendar =
false;
106 updateCalendar =
true;
111 resetBeforeChange( buttonUpRect.
contains( event->
pos() ) ? -1 : 1 );
119 if ( updateCalendar )
128 if ( mAllowNull && mIsNull )
146 if ( mAllowNull && mIsNull )
148 resetBeforeChange( -event->
delta() );
156 if ( mAllowNull && mIsNull &&
167 if ( isNull != mIsNull )
172 if ( mOriginalStyleSheet.
isNull() )
183 mClearButton->
setVisible( mAllowNull && !mIsNull );
186 void QgsDateTimeEdit::displayNull(
bool updateCalendar )
189 if ( updateCalendar )
199 void QgsDateTimeEdit::resetBeforeChange(
int delta )
204 case QDateTimeEdit::DaySection:
207 case QDateTimeEdit::MonthSection:
210 case QDateTimeEdit::YearSection:
227 int QgsDateTimeEdit::spinButtonWidth()
const 232 int QgsDateTimeEdit::frameWidth()
const 257 if ( mAllowNull && mIsNull )
274 mClearButton->
move(
rect().right() - frameWidth() - spinButtonWidth() - sz.
width(),
QDateTime addMonths(int nmonths) const
virtual void wheelEvent(QWheelEvent *event)
void dateTimeChanged(const QDateTime &datetime)
QDateTime addYears(int nyears) const
virtual QSize minimumSizeHint() const
void setText(const QString &)
void showEvent(QShowEvent *event) override
QDateTime minimumDateTime() const
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const=0
virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const=0
void focusOutEvent(QFocusEvent *event) override
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
void initStyleOption(QStyleOptionSpinBox *option) const
void wheelEvent(QWheelEvent *event) override
void setCurrentPage(int year, int month)
virtual bool event(QEvent *event)
QLineEdit * lineEdit() const
Section currentSection() const
bool contains(const QPoint &point, bool proper) const
virtual void showEvent(QShowEvent *event)
virtual void mousePressEvent(QMouseEvent *event)
bool blockSignals(bool block)
void setDateTime(const QDateTime &dateTime)
QDateTime currentDateTime()
virtual void resizeEvent(QResizeEvent *event)
void setEmpty()
Resets the widget to show no value (ie, an "unknown" state).
void setAllowNull(bool allowNull)
determines if the widget allows setting null date/time.
QDateTime maximumDateTime() const
QgsDateTimeEdit(QWidget *parent=nullptr)
const QPoint & pos() const
void setDateTime(const QDateTime &dateTime)
setDateTime set the date time in the widget and handles null date times.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual void resizeEvent(QResizeEvent *event) override
QDateTime addDays(int ndays) const
virtual void clear() override
Set the current date as NULL.
QDateTime dateTime() const
dateTime returns the date time which can eventually be a null date/time
bool isNull(const QVariant &v)
virtual void focusOutEvent(QFocusEvent *event)
void mousePressEvent(QMouseEvent *event) override