kexi

kexidatetimeformatter.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXIDATETIMEFORMATTER_H
00021 #define KEXIDATETIMEFORMATTER_H
00022 
00023 #include <qdatetimeedit.h>
00024 #include <qregexp.h>
00025 
00027 class KEXIGUIUTILS_EXPORT KexiDateFormatter
00028 {
00029     public:
00031         KexiDateFormatter();
00032 
00035 
00036         ~KexiDateFormatter();
00037 
00040         QDate stringToDate( const QString& str ) const;
00041 
00047         QVariant stringToVariant( const QString& str ) const;
00048 
00051         QString dateToString( const QDate& date ) const;
00052 
00055         QString inputMask() const { return m_inputMask; }
00056 
00058         QString separator() const { return m_separator; }
00059 
00062         bool isEmpty( const QString& str ) const;
00063 
00064     protected:
00066         QString m_inputMask;
00067 
00069         QDateEdit::Order m_order;
00070 
00072         bool m_longYear;
00073 
00074         bool m_monthWithLeadingZero, m_dayWithLeadingZero;
00075 
00077         QString m_qtFormat;
00078 
00080         int m_yearpos, m_monthpos, m_daypos;
00081 
00082         QString m_separator;
00083 };
00084 
00088 class KEXIGUIUTILS_EXPORT KexiTimeFormatter
00089 {
00090     public:
00092         KexiTimeFormatter();
00093 
00096 
00097         ~KexiTimeFormatter();
00098 
00101         QTime stringToTime( const QString& str ) const;
00102 
00108         QVariant stringToVariant( const QString& str );
00109 
00112         QString timeToString( const QTime& time ) const;
00113 
00116         QString inputMask() const { return m_inputMask; }
00117 
00120         bool isEmpty( const QString& str ) const;
00121 
00122     protected:
00124         QString m_inputMask;
00125 
00126 //      //! Order of date sections
00127 //      QDateEdit::Order m_order;
00128 
00130         bool m_24h;
00131 
00132         bool m_hoursWithLeadingZero;
00133 
00135         QString m_outputFormat;
00136 
00138         int m_hourpos, m_minpos, m_secpos, m_ampmpos;
00139 
00140         QRegExp *m_hmsRegExp, *m_hmRegExp;
00141 };
00142 
00145 KEXIGUIUTILS_EXPORT QString dateTimeInputMask(
00146     const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter);
00147 
00152 KEXIGUIUTILS_EXPORT QDateTime stringToDateTime(
00153     const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter, const QString& str);
00154 
00157 KEXIGUIUTILS_EXPORT bool dateTimeIsEmpty( const KexiDateFormatter& dateFormatter, 
00158     const KexiTimeFormatter& timeFormatter, const QString& str );
00159 
00162 KEXIGUIUTILS_EXPORT bool dateTimeIsValid( const KexiDateFormatter& dateFormatter, 
00163     const KexiTimeFormatter& timeFormatter, const QString& str );
00164 
00165 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys