17 #include <QDateTimeEdit>
30 , mQDateTimeEdit( NULL )
31 , mQgsDateTimeEdit( NULL )
47 mQgsDateTimeEdit = qgsEditor;
55 mQDateTimeEdit = qtEditor;
58 if ( !mQDateTimeEdit )
60 QgsDebugMsg(
"Date/time edit widget could not be initialized because provided widget is not a QDateTimeEdit." );
68 const bool calendar =
config(
"calendar_popup",
false ).toBool();
71 const bool allowNull =
config(
"allow_null",
true ).toBool();
72 if ( mQgsDateTimeEdit )
79 "For that the QGIS custom widget QgsDateTimeEdit needs to be used." ),
83 if ( mQgsDateTimeEdit )
95 return mQgsDateTimeEdit || mQDateTimeEdit;
98 void QgsDateTimeEditWrapper::dateTimeChanged(
const QDateTime& dateTime )
106 if ( !mQDateTimeEdit )
111 if ( mQgsDateTimeEdit )
117 return mQDateTimeEdit->
dateTime().toString( fieldFormat );
123 if ( !mQDateTimeEdit )
129 if ( mQgsDateTimeEdit )
141 if ( !mQDateTimeEdit )
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.
QString toString(Qt::DateFormat format) const
QDateTime dateTime() const
dateTime returns the date time which can eventually be a null date/time
#define QGSDATETIMEEDIT_DATEFORMAT
QgsDateTimeEditWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent=0)
QString tr(const char *sourceText, const char *disambiguation, int n)
void setValue(const QVariant &value) override
void setEnabled(bool enabled) override
QVariant value() override
Will be used to access the widget's value.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
bool valid() override
Return true if the widget has been properly initialized.
QDateTime fromString(const QString &string, Qt::DateFormat format)
void initWidget(QWidget *editor) override
This method should initialize the editor widget with runtime data.
QDateTime currentDateTime()
static QgsMessageLog * instance()
void setAllowNull(bool allowNull)
determines if the widget allows setting null date/time.
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)
Represents a vector layer which manages a vector based data sets.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times...