17 #include <QMouseEvent>
20 #include <QToolButton>
34 mClearButton->
setCursor( Qt::ArrowCursor );
35 mClearButton->
setStyleSheet(
"position: absolute; border: none; padding: 0px;" );
37 connect( mClearButton, SIGNAL( clicked() ),
this, SLOT(
clear() ) );
39 mNullLabel =
new QLineEdit(
QSettings().value(
"qgis/nullValue",
"NULL" ).toString(),
this );
41 mNullLabel->
setStyleSheet(
"position: absolute; border: none; font-style: italic; color: grey;" );
60 mNullLabel->
setVisible( mAllowNull && mIsNull );
61 mClearButton->
setVisible( mAllowNull && !mIsNull );
75 if ( mAllowNull && mIsNull && lerect.
contains( event->
pos() ) )
81 void QgsDateTimeEdit::changed(
const QDateTime & dateTime )
83 mIsNull = dateTime.
isNull();
84 mNullLabel->
setVisible( mAllowNull && mIsNull );
85 mClearButton->
setVisible( mAllowNull && !mIsNull );
89 int QgsDateTimeEdit::spinButtonWidth()
const
94 int QgsDateTimeEdit::frameWidth()
const
115 if ( mAllowNull && mIsNull )
132 mClearButton->
move(
rect().right() - frameWidth() - spinButtonWidth() - sz.
width(),
135 mNullLabel->
move( 0, 0 );
QDateTime dateTime() const
dateTime returns the date time which can eventually be a null date/time
void dateTimeChanged(const QDateTime &datetime)
virtual QSize minimumSizeHint() 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
QgsDateTimeEdit(QWidget *parent=0)
QLineEdit * lineEdit() const
bool contains(const QPoint &point, bool proper) const
virtual void mousePressEvent(QMouseEvent *event)
QRect adjusted(int dx1, int dy1, int dx2, int dy2) const
void setDateTime(const QDateTime &dateTime)
QDateTime currentDateTime()
virtual void resizeEvent(QResizeEvent *event)
void setAllowNull(bool allowNull)
determines if the widget allows setting null date/time.
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
virtual void clear() override
Set the current date as NULL.
void mousePressEvent(QMouseEvent *event) override