kexi
kexidbdateedit.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KexiDBDateEdit_H
00022 #define KexiDBDateEdit_H
00023
00024 #include "kexiformdataiteminterface.h"
00025 #include <qdatetimeedit.h>
00026
00027 class KPopupMenu;
00028 class KDatePicker;
00029 class QDateTimeEditor;
00030
00032 class KEXIFORMUTILS_EXPORT KexiDBDateEdit : public QWidget, public KexiFormDataItemInterface
00033 {
00034 Q_OBJECT
00035 Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
00036 Q_PROPERTY(QCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
00037
00038 Q_ENUMS( Order )
00039 Q_PROPERTY( Order order READ order WRITE setOrder DESIGNABLE true)
00040 Q_PROPERTY( QDate date READ date WRITE setDate DESIGNABLE true)
00041 Q_PROPERTY( bool autoAdvance READ autoAdvance WRITE setAutoAdvance DESIGNABLE true)
00042 Q_PROPERTY( QDate maxValue READ maxValue WRITE setMaxValue DESIGNABLE true)
00043 Q_PROPERTY( QDate minValue READ minValue WRITE setMinValue DESIGNABLE true)
00044 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true )
00045
00046 public:
00047 enum Order { DMY = QDateEdit::DMY, MDY = QDateEdit::MDY, YMD = QDateEdit::YMD, YDM = QDateEdit::YDM };
00048
00049 KexiDBDateEdit(const QDate &date, QWidget *parent, const char *name=0);
00050 virtual ~KexiDBDateEdit();
00051
00052 inline QString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
00053 inline QCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
00054 virtual QVariant value();
00055 virtual void setInvalidState( const QString& displayText );
00056
00059 virtual bool valueIsNull();
00060
00065 virtual bool valueIsEmpty();
00066
00068 virtual bool isReadOnly() const;
00069
00071 virtual QWidget* widget();
00072
00073 virtual bool cursorAtStart();
00074 virtual bool cursorAtEnd();
00075 virtual void clear();
00076
00077 virtual void setEnabled(bool enabled);
00078
00079
00080 inline QDate date() const { return m_edit->date(); }
00081 inline void setOrder(Order order) { m_edit->setOrder( (QDateEdit::Order) order); }
00082 inline Order order() const { return (Order)m_edit->order(); }
00083 inline void setAutoAdvance( bool advance ) { m_edit->setAutoAdvance(advance); }
00084 inline bool autoAdvance() const { return m_edit->autoAdvance(); }
00085 inline void setMinValue(const QDate& d) { m_edit->setMinValue(d); }
00086 inline QDate minValue() const { return m_edit->minValue(); }
00087 inline void setMaxValue(const QDate& d) { m_edit->setMaxValue(d); }
00088 inline QDate maxValue() const { return m_edit->maxValue(); }
00089
00090 signals:
00091 void dateChanged(const QDate &date);
00092
00093 public slots:
00094 inline void setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
00095 inline void setDataSourceMimeType(const QCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
00096 inline void setDate(const QDate& date) { m_edit->setDate(date); }
00097 virtual void setReadOnly(bool set);
00098
00099 protected slots:
00100 void slotValueChanged(const QDate&);
00101 void slotShowDatePicker();
00102 void acceptDate();
00103
00104 protected:
00105 virtual void setValueInternal(const QVariant& add, bool removeOld);
00106 virtual bool eventFilter(QObject *o, QEvent *e);
00107
00108 private:
00109 KDatePicker *m_datePicker;
00110 QDateEdit *m_edit;
00111 KPopupMenu *m_datePickerPopupMenu;
00112 QDateTimeEditor *m_dte_date;
00113 bool m_invalidState : 1;
00114 bool m_cleared : 1;
00115 bool m_readOnly : 1;
00116 };
00117
00118 #endif
|