kexidbdatetimeedit.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 KexiDBDateTimeEdit_H
22#define KexiDBDateTimeEdit_H
23
24#include "kexiformdataiteminterface.h"
25#include <tqdatetimeedit.h>
26
27class KDatePicker;
28class TQDateTimeEditor;
29class TDEPopupMenu;
30
32class KEXIFORMUTILS_EXPORT KexiDBDateTimeEdit : 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 TQDateTimeEdit
39 TQ_PROPERTY( TQDateTime dateTime READ dateTime WRITE setDateTime )
40 TQ_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE true )
41
42 public:
43 enum Order { DMY, MDY, YMD, YDM };
44
45 KexiDBDateTimeEdit(const TQDateTime &datetime, TQWidget *parent, const char *name=0);
46 virtual ~KexiDBDateTimeEdit();
47
48 inline TQString dataSource() const { return KexiFormDataItemInterface::dataSource(); }
49 inline TQCString dataSourceMimeType() const { return KexiFormDataItemInterface::dataSourceMimeType(); }
50 virtual TQVariant value();
51 virtual void setInvalidState( const TQString& displayText );
52
55 virtual bool valueIsNull();
56
61 virtual bool valueIsEmpty();
62
64 virtual bool isReadOnly() const;
65
67 virtual TQWidget* widget();
68
69 virtual bool cursorAtStart();
70 virtual bool cursorAtEnd();
71 virtual void clear();
72
73 virtual void setEnabled(bool enabled);
74
75 // property functions
76 TQDateTime dateTime() const;
77
78 signals:
79 void dateTimeChanged();
80
81 public slots:
82 inline void setDataSource(const TQString &ds) { KexiFormDataItemInterface::setDataSource(ds); }
83 inline void setDataSourceMimeType(const TQCString &ds) { KexiFormDataItemInterface::setDataSourceMimeType(ds); }
84 void setDateTime(const TQDateTime &dt);
85 virtual void setReadOnly(bool set);
86
87 protected:
88 virtual void setValueInternal(const TQVariant& add, bool removeOld);
89 virtual bool eventFilter(TQObject *o, TQEvent *e);
90
91 protected slots:
92 void slotValueChanged();
93 void slotShowDatePicker();
94 void acceptDate();
95
96 private:
97 KDatePicker *m_datePicker;
98 TQDateEdit* m_dateEdit;
99 TQTimeEdit* m_timeEdit;
100 TQDateTimeEditor *m_dte_date, *m_dte_time;
101 TDEPopupMenu *m_datePickerPopupMenu;
102 bool m_invalidState : 1;
103 bool m_cleared : 1;
104 bool m_readOnly : 1;
105};
106
107#endif
A db-aware datetime 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