kexidbdateedit.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004-2005 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KexiDBDateEdit_H
22#define KexiDBDateEdit_H
23
24#include "kexiformdataiteminterface.h"
25#include <tqdatetimeedit.h>
26
27class TDEPopupMenu;
28class KDatePicker;
29class TQDateTimeEditor;
30
32class KEXIFORMUTILS_EXPORT KexiDBDateEdit : public TQWidget, public KexiFormDataItemInterface
33{
34 TQ_OBJECT
35
36 TQ_PROPERTY(TQString dataSource READ dataSource WRITE setDataSource DESIGNABLE true)
37 TQ_PROPERTY(TQCString dataSourceMimeType READ dataSourceMimeType WRITE setDataSourceMimeType DESIGNABLE true)
38 // properties copied from TQDateEdit
39 TQ_ENUMS( Order )
40 TQ_PROPERTY( Order order READ order WRITE setOrder DESIGNABLE true)
41 TQ_PROPERTY( TQDate date READ date WRITE setDate DESIGNABLE true)
42 TQ_PROPERTY( bool autoAdvance READ autoAdvance WRITE setAutoAdvance DESIGNABLE true)
43 TQ_PROPERTY( TQDate maxValue READ maxValue WRITE setMaxValue DESIGNABLE true)
44 TQ_PROPERTY( TQDate minValue READ minValue WRITE setMinValue DESIGNABLE true)
45 TQ_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true )
46
47 public:
48 enum Order { DMY = TQDateEdit::DMY, MDY = TQDateEdit::MDY, YMD = TQDateEdit::YMD, YDM = TQDateEdit::YDM };
49
50 KexiDBDateEdit(const TQDate &date, TQWidget *parent, const char *name=0);
51 virtual ~KexiDBDateEdit();
52
53 inline TQString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
54 inline TQCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
55 virtual TQVariant value();
56 virtual void setInvalidState( const TQString& displayText );
57
60 virtual bool valueIsNull();
61
66 virtual bool valueIsEmpty();
67
69 virtual bool isReadOnly() const;
70
72 virtual TQWidget* widget();
73
74 virtual bool cursorAtStart();
75 virtual bool cursorAtEnd();
76 virtual void clear();
77
78 virtual void setEnabled(bool enabled);
79
80 // property functions
81 inline TQDate date() const { return m_edit->date(); }
82 inline void setOrder(Order order) { m_edit->setOrder( (TQDateEdit::Order) order); }
83 inline Order order() const { return (Order)m_edit->order(); }
84 inline void setAutoAdvance( bool advance ) { m_edit->setAutoAdvance(advance); }
85 inline bool autoAdvance() const { return m_edit->autoAdvance(); }
86 inline void setMinValue(const TQDate& d) { m_edit->setMinValue(d); }
87 inline TQDate minValue() const { return m_edit->minValue(); }
88 inline void setMaxValue(const TQDate& d) { m_edit->setMaxValue(d); }
89 inline TQDate maxValue() const { return m_edit->maxValue(); }
90
91 signals:
92 void dateChanged(const TQDate &date);
93
94 public slots:
95 inline void setDataSource(const TQString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
96 inline void setDataSourceMimeType(const TQCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
97 inline void setDate(const TQDate& date) { m_edit->setDate(date); }
98 virtual void setReadOnly(bool set);
99
100 protected slots:
101 void slotValueChanged(const TQDate&);
102 void slotShowDatePicker();
103 void acceptDate();
104
105 protected:
106 virtual void setValueInternal(const TQVariant& add, bool removeOld);
107 virtual bool eventFilter(TQObject *o, TQEvent *e);
108
109 private:
110 KDatePicker *m_datePicker;
111 TQDateEdit *m_edit;
112 TDEPopupMenu *m_datePickerPopupMenu;
113 TQDateTimeEditor *m_dte_date;
114 bool m_invalidState : 1;
115 bool m_cleared : 1;
116 bool m_readOnly : 1;
117};
118
119#endif
A db-aware date editor.
virtual bool cursorAtEnd()=0
virtual bool cursorAtStart()=0
virtual bool isReadOnly() const
virtual TQVariant value()=0
virtual bool valueIsNull()=0
virtual bool valueIsEmpty()=0
virtual void setValueInternal(const TQVariant &add, bool removeOld)=0
virtual void clear()=0
clears item's data, so the data will contain NULL data
An interface for declaring form widgets to be data-aware.
void setDataSourceMimeType(const TQCString &ds)
void setDataSource(const TQString &ds)
Sets the name of the data source for this widget.
virtual void setInvalidState(const TQString &displayText)=0
virtual void setReadOnly(bool readOnly)=0