kexi

kexidatetimeformatter.h
1/* This file is part of the KDE project
2 Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIDATETIMEFORMATTER_H
21#define KEXIDATETIMEFORMATTER_H
22
23#include <tqdatetimeedit.h>
24#include <tqregexp.h>
25
27class KEXIGUIUTILS_EXPORT KexiDateFormatter
28{
29 public:
32
35
37
40 TQDate stringToDate( const TQString& str ) const;
41
47 TQVariant stringToVariant( const TQString& str ) const;
48
51 TQString dateToString( const TQDate& date ) const;
52
55 TQString inputMask() const { return m_inputMask; }
56
58 TQString separator() const { return m_separator; }
59
62 bool isEmpty( const TQString& str ) const;
63
64 protected:
66 TQString m_inputMask;
67
69 TQDateEdit::Order m_order;
70
73
74 bool m_monthWithLeadingZero, m_dayWithLeadingZero;
75
77 TQString m_qtFormat;
78
80 int m_yearpos, m_monthpos, m_daypos;
81
82 TQString m_separator;
83};
84
88class KEXIGUIUTILS_EXPORT KexiTimeFormatter
89{
90 public:
93
96
98
101 TQTime stringToTime( const TQString& str ) const;
102
108 TQVariant stringToVariant( const TQString& str );
109
112 TQString timeToString( const TQTime& time ) const;
113
116 TQString inputMask() const { return m_inputMask; }
117
120 bool isEmpty( const TQString& str ) const;
121
122 protected:
124 TQString m_inputMask;
125
126// //! Order of date sections
127// TQDateEdit::Order m_order;
128
130 bool m_24h;
131
132 bool m_hoursWithLeadingZero;
133
136
138 int m_hourpos, m_minpos, m_secpos, m_ampmpos;
139
140 TQRegExp *m_hmsRegExp, *m_hmRegExp;
141};
142
145KEXIGUIUTILS_EXPORT TQString dateTimeInputMask(
146 const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter);
147
152KEXIGUIUTILS_EXPORT TQDateTime stringToDateTime(
153 const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter, const TQString& str);
154
157KEXIGUIUTILS_EXPORT bool dateTimeIsEmpty( const KexiDateFormatter& dateFormatter,
158 const KexiTimeFormatter& timeFormatter, const TQString& str );
159
162KEXIGUIUTILS_EXPORT bool dateTimeIsValid( const KexiDateFormatter& dateFormatter,
163 const KexiTimeFormatter& timeFormatter, const TQString& str );
164
165#endif
Date formatter used by KexiDateTableEdit and KexiDateTimeTableEdit.
bool m_longYear
4 or 2 digits
TQDateEdit::Order m_order
Order of date sections.
int m_yearpos
Used in stringToDate() to convert string back to TQDate.
TQString m_qtFormat
Date format used in dateToString().
TQString dateToString(const TQDate &date) const
TQVariant stringToVariant(const TQString &str) const
TQDate stringToDate(const TQString &str) const
TQString m_inputMask
Input mask generated using the formatter settings. Can be used in TQLineEdit::setInputMask().
TQString separator() const
KexiDateFormatter()
Creates new formatter with KDE setting for "short date".
TQString inputMask() const
Time formatter used by KexiTimeTableEdit and KexiDateTimeTableEdit Following time formats are allowed...
TQTime stringToTime(const TQString &str) const
TQString timeToString(const TQTime &time) const
TQString m_inputMask
Input mask generated using the formatter settings. Can be used in TQLineEdit::setInputMask().
int m_hourpos
Used in stringToTime() to convert string back to TQTime.
TQVariant stringToVariant(const TQString &str)
TQString m_outputFormat
Time format used in timeToString(). Notation from TDELocale::setTimeFormat() is used.
KexiTimeFormatter()
Creates new formatter with KDE setting for time.
TQString inputMask() const