kexi

kexidatetableedit.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002   Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2003   Daniel Molkentin <molkentin@kde.org>
00004    Copyright (C) 2003-2004,2006 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This program is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this program; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef KEXIDATETABLEEDIT_H
00023 #define KEXIDATETABLEEDIT_H
00024 
00025 #include <qdatetimeedit.h>
00026 
00027 #include "kexiinputtableedit.h"
00028 
00030 class KEXIDATATABLE_EXPORT KexiDateFormatter
00031 {
00032     public:
00034         KexiDateFormatter();
00035 
00038 
00039         ~KexiDateFormatter();
00040 
00043         QDate stringToDate( const QString& str ) const;
00044 
00047         QString dateToString( const QDate& date ) const;
00048 
00051         QString inputMask() const { return m_inputMask; }
00052 
00053         QString separator() const { return m_separator; }
00054 
00055     protected:
00057         QString m_inputMask;
00058 
00060         QDateEdit::Order m_order;
00061 
00063         bool m_longYear;
00064 
00065         bool m_monthWithLeadingZero, m_dayWithLeadingZero;
00066 
00068         QString m_qtFormat;
00069 
00071         int m_yearpos, m_monthpos, m_daypos;
00072 
00073         QString m_separator;
00074 };
00075 
00082 class KEXIDATATABLE_EXPORT KexiDateTableEdit : public KexiInputTableEdit
00083 {
00084     Q_OBJECT
00085 
00086     public:
00087         KexiDateTableEdit(KexiTableViewColumn &column, QScrollView *parent=0);
00088         virtual ~KexiDateTableEdit();
00089         virtual void setupContents( QPainter *p, bool focused, QVariant val, 
00090             QString &txt, int &align, int &x, int &y_offset, int &w, int &h );
00091         virtual QVariant value();
00092         virtual bool valueIsNull();
00093         virtual bool valueIsEmpty();
00094         virtual bool valueIsValid();
00095 
00096     protected:
00097         virtual void setValueInternal(const QVariant& add, bool removeOld);
00098         QDate dateValue() const;
00099 
00101         KexiDateFormatter m_formatter;
00102 };
00103 
00104 KEXI_DECLARE_CELLEDITOR_FACTORY_ITEM(KexiDateEditorFactoryItem)
00105 
00106 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys