Kexi API Documentation (2.0 alpha)

KexiDateFormatter Class Reference

#include <kexidatetimeformatter.h>

List of all members.


Detailed Description

Date formatter used by KexiDateTableEdit and KexiDateTimeTableEdit.

Definition at line 27 of file kexidatetimeformatter.h.

Public Member Functions

 KexiDateFormatter ()
 Creates new formatter with KDE setting for "short date".
 ~KexiDateFormatter ()
QDate stringToDate (const QString &str) const
 Converts string str to date using predefined settings.
QVariant stringToVariant (const QString &str) const
QString dateToString (const QDate &date) const
 Converts date to string using predefined settings.
QString inputMask () const
QString separator () const
bool isEmpty (const QString &str) const

Protected Attributes

QString m_inputMask
 Input mask generated using the formatter settings. Can be used in QLineEdit::setInputMask().
QDateEdit::Order m_order
 Order of date sections.
bool m_longYear
 4 or 2 digits
bool m_monthWithLeadingZero
bool m_dayWithLeadingZero
QString m_qtFormat
 Date format used in dateToString().
int m_yearpos
 Used in stringToDate() to convert string back to QDate.
int m_monthpos
 Used in stringToDate() to convert string back to QDate.
int m_daypos
 Used in stringToDate() to convert string back to QDate.
QString m_separator


Constructor & Destructor Documentation

KexiDateFormatter::KexiDateFormatter  ) 
 

Creates new formatter with KDE setting for "short date".

Todo:
allow to override the format using column property and/or global app settings
Todo:
more variables are possible here, see void KLocale::setDateFormatShort() docs http://developer.kde.org/documentation/library/3.5-api/kdelibs-apidocs/kdecore/html/classKLocale.html#a59
Todo:
use QRegExp (to replace Y by 1, etc.) instead of hardcoded "%1%299%399" because df may contain also other characters

Definition at line 31 of file kexidatetimeformatter.cpp.

References m_daypos, m_dayWithLeadingZero, m_inputMask, m_longYear, m_monthpos, m_monthWithLeadingZero, m_order, m_qtFormat, m_separator, and m_yearpos.

KexiDateFormatter::~KexiDateFormatter  ) 
 

Todo:
KexiDateFormatter(... settings ...);

Definition at line 116 of file kexidatetimeformatter.cpp.


Member Function Documentation

QString KexiDateFormatter::dateToString const QDate &  date  )  const
 

Converts date to string using predefined settings.

Returns:
null string if date is invalid

Definition at line 163 of file kexidatetimeformatter.cpp.

References m_qtFormat.

Referenced by KexiDateTimeTableEdit::handleCopyAction(), KexiDateTableEdit::handleCopyAction(), KexiDateTimeTableEdit::setupContents(), KexiDateTableEdit::setupContents(), KexiDateTimeTableEdit::setValueInInternalEditor(), and KexiDateTableEdit::setValueInInternalEditor().

QString KexiDateFormatter::inputMask  )  const [inline]
 

Returns:
Input mask generated using the formatter settings. Can be used in QLineEdit::setInputMask().

Definition at line 55 of file kexidatetimeformatter.h.

Referenced by dateTimeInputMask(), KexiQueryParameters::getParameters(), and KexiDateTableEdit::KexiDateTableEdit().

bool KexiDateFormatter::isEmpty const QString str  )  const
 

Returns:
true if str contains only spaces and separators according to the date format.

Definition at line 157 of file kexidatetimeformatter.cpp.

References m_separator.

Referenced by dateTimeIsEmpty(), stringToVariant(), KexiDateTableEdit::valueIsNull(), and KexiDateTableEdit::valueIsValid().

QString KexiDateFormatter::separator  )  const [inline]
 

Returns:
separator for this date format, a single character like "-" or "/"

Definition at line 58 of file kexidatetimeformatter.h.

QDate KexiDateFormatter::stringToDate const QString str  )  const
 

Converts string str to date using predefined settings.

Returns:
invalid date if the conversion is impossible

Definition at line 120 of file kexidatetimeformatter.cpp.

References m_daypos, m_longYear, m_monthpos, and m_yearpos.

Referenced by KexiDateTableEdit::dateValue(), KexiQueryParameters::getParameters(), KexiDateTableEdit::handleAction(), stringToDateTime(), stringToVariant(), and KexiDateTableEdit::valueIsValid().

QVariant KexiDateFormatter::stringToVariant const QString str  )  const
 

Converts string str to date using predefined settings and returns QVariant containing the date value. This method does the same as stringToDate() but if string contains invalid date representation, e.g. contains only spaces and separators, null QVariant() is returned.

Definition at line 147 of file kexidatetimeformatter.cpp.

References isEmpty(), and stringToDate().

Referenced by KexiDateTableEdit::value().


Member Data Documentation

int KexiDateFormatter::m_daypos [protected]
 

Used in stringToDate() to convert string back to QDate.

Definition at line 80 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter(), and stringToDate().

bool KexiDateFormatter::m_dayWithLeadingZero [protected]
 

Definition at line 74 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter().

QString KexiDateFormatter::m_inputMask [protected]
 

Input mask generated using the formatter settings. Can be used in QLineEdit::setInputMask().

Definition at line 66 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter().

bool KexiDateFormatter::m_longYear [protected]
 

4 or 2 digits

Definition at line 72 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter(), and stringToDate().

int KexiDateFormatter::m_monthpos [protected]
 

Used in stringToDate() to convert string back to QDate.

Definition at line 80 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter(), and stringToDate().

bool KexiDateFormatter::m_monthWithLeadingZero [protected]
 

Definition at line 74 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter().

QDateEdit::Order KexiDateFormatter::m_order [protected]
 

Order of date sections.

Definition at line 69 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter().

QString KexiDateFormatter::m_qtFormat [protected]
 

Date format used in dateToString().

Definition at line 77 of file kexidatetimeformatter.h.

Referenced by dateToString(), and KexiDateFormatter().

QString KexiDateFormatter::m_separator [protected]
 

Definition at line 82 of file kexidatetimeformatter.h.

Referenced by isEmpty(), and KexiDateFormatter().

int KexiDateFormatter::m_yearpos [protected]
 

Used in stringToDate() to convert string back to QDate.

Definition at line 80 of file kexidatetimeformatter.h.

Referenced by KexiDateFormatter(), and stringToDate().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:49:56 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003