summaryrefslogtreecommitdiffstats
path: root/kexi/widget/utils/kexidatetimeformatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kexi/widget/utils/kexidatetimeformatter.cpp')
-rw-r--r--kexi/widget/utils/kexidatetimeformatter.cpp186
1 files changed, 93 insertions, 93 deletions
diff --git a/kexi/widget/utils/kexidatetimeformatter.cpp b/kexi/widget/utils/kexidatetimeformatter.cpp
index d8f642ca0..430d2f8fc 100644
--- a/kexi/widget/utils/kexidatetimeformatter.cpp
+++ b/kexi/widget/utils/kexidatetimeformatter.cpp
@@ -32,69 +32,69 @@ KexiDateFormatter::KexiDateFormatter()
{
// use "short date" format system settings
//! @todo allow to override the format using column property and/or global app settings
- QString df( KGlobal::locale()->dateFormatShort() );
+ TQString df( KGlobal::locale()->dateFormatShort() );
if (df.length()>2)
m_separator = df.mid(2,1);
else
m_separator = "-";
const int separatorLen = m_separator.length();
- QString yearMask("9999");
- QString yearDateFormat("yyyy"),
+ TQString yearMask("9999");
+ TQString yearDateFormat("yyyy"),
monthDateFormat("MM"),
dayDateFormat("dd"); //for setting up m_dateFormat
bool ok = df.length()>=8;
- int yearpos, monthpos, daypos; //result of df.find()
+ int yearpos, monthpos, daypos; //result of df.tqfind()
if (ok) {//look at % variables
//! @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
- yearpos = df.find("%y", 0, false); //&y or %y
+ yearpos = df.tqfind("%y", 0, false); //&y or %y
m_longYear = !(yearpos>=0 && df.mid(yearpos+1, 1)=="y");
if (!m_longYear) {
yearMask = "99";
yearDateFormat = "yy";
}
- monthpos = df.find("%m", 0, true); //%m or %n
+ monthpos = df.tqfind("%m", 0, true); //%m or %n
m_monthWithLeadingZero = true;
if (monthpos<0) {
- monthpos = df.find("%n", 0, false);
+ monthpos = df.tqfind("%n", 0, false);
m_monthWithLeadingZero = false;
monthDateFormat = "M";
}
- daypos = df.find("%d", 0, true);//%d or %e
+ daypos = df.tqfind("%d", 0, true);//%d or %e
m_dayWithLeadingZero = true;
if (daypos<0) {
- daypos = df.find("%e", 0, false);
+ daypos = df.tqfind("%e", 0, false);
m_dayWithLeadingZero = false;
dayDateFormat = "d";
}
ok = (yearpos>=0 && monthpos>=0 && daypos>=0);
}
- m_order = QDateEdit::YMD; //default
+ m_order = TQDateEdit::YMD; //default
if (ok) {
if (yearpos<monthpos && monthpos<daypos) {
//will be set in "default: YMD"
}
else if (yearpos<daypos && daypos<monthpos) {
- m_order = QDateEdit::YDM;
-//! @todo use QRegExp (to replace %Y by %1, etc.) instead of hardcoded "%1%299%399"
+ m_order = TQDateEdit::YDM;
+//! @todo use TQRegExp (to tqreplace %Y by %1, etc.) instead of hardcoded "%1%299%399"
//! because df may contain also other characters
- m_inputMask = QString("%1%299%399").arg(yearMask).arg(m_separator).arg(m_separator);
+ m_inputMask = TQString("%1%299%399").tqarg(yearMask).tqarg(m_separator).tqarg(m_separator);
m_qtFormat = yearDateFormat+m_separator+dayDateFormat+m_separator+monthDateFormat;
m_yearpos = 0;
m_daypos = yearMask.length()+separatorLen;
m_monthpos = m_daypos+2+separatorLen;
}
else if (daypos<monthpos && monthpos<yearpos) {
- m_order = QDateEdit::DMY;
- m_inputMask = QString("99%199%2%3").arg(m_separator).arg(m_separator).arg(yearMask);
+ m_order = TQDateEdit::DMY;
+ m_inputMask = TQString("99%199%2%3").tqarg(m_separator).tqarg(m_separator).tqarg(yearMask);
m_qtFormat = dayDateFormat+m_separator+monthDateFormat+m_separator+yearDateFormat;
m_daypos = 0;
m_monthpos = 2+separatorLen;
m_yearpos = m_monthpos+2+separatorLen;
}
else if (monthpos<daypos && daypos<yearpos) {
- m_order = QDateEdit::MDY;
- m_inputMask = QString("99%199%2%3").arg(m_separator).arg(m_separator).arg(yearMask);
+ m_order = TQDateEdit::MDY;
+ m_inputMask = TQString("99%199%2%3").tqarg(m_separator).tqarg(m_separator).tqarg(yearMask);
m_qtFormat = monthDateFormat+m_separator+dayDateFormat+m_separator+yearDateFormat;
m_monthpos = 0;
m_daypos = 2+separatorLen;
@@ -103,8 +103,8 @@ KexiDateFormatter::KexiDateFormatter()
else
ok = false;
}
- if (!ok || m_order == QDateEdit::YMD) {//default: YMD
- m_inputMask = QString("%1%299%399").arg(yearMask).arg(m_separator).arg(m_separator);
+ if (!ok || m_order == TQDateEdit::YMD) {//default: YMD
+ m_inputMask = TQString("%1%299%399").tqarg(yearMask).tqarg(m_separator).tqarg(m_separator);
m_qtFormat = yearDateFormat+m_separator+monthDateFormat+m_separator+dayDateFormat;
m_yearpos = 0;
m_monthpos = yearMask.length()+separatorLen;
@@ -117,12 +117,12 @@ KexiDateFormatter::~KexiDateFormatter()
{
}
-QDate KexiDateFormatter::stringToDate( const QString& str ) const
+TQDate KexiDateFormatter::stringToDate( const TQString& str ) const
{
bool ok = true;
int year = str.mid(m_yearpos, m_longYear ? 4 : 2).toInt(&ok);
if (!ok)
- return QDate();
+ return TQDate();
if (year < 30) {//2000..2029
year = 2000 + year;
}
@@ -132,35 +132,35 @@ QDate KexiDateFormatter::stringToDate( const QString& str ) const
int month = str.mid(m_monthpos, 2).toInt(&ok);
if (!ok)
- return QDate();
+ return TQDate();
int day = str.mid(m_daypos, 2).toInt(&ok);
if (!ok)
- return QDate();
+ return TQDate();
- QDate date(year, month, day);
+ TQDate date(year, month, day);
if (!date.isValid())
- return QDate();
+ return TQDate();
return date;
}
-QVariant KexiDateFormatter::stringToVariant( const QString& str ) const
+TQVariant KexiDateFormatter::stringToVariant( const TQString& str ) const
{
if (isEmpty(str))
- return QVariant();
- const QDate date( stringToDate( str ) );
+ return TQVariant();
+ const TQDate date( stringToDate( str ) );
if (date.isValid())
return date;
- return QVariant();
+ return TQVariant();
}
-bool KexiDateFormatter::isEmpty( const QString& str ) const
+bool KexiDateFormatter::isEmpty( const TQString& str ) const
{
- QString s(str);
- return s.replace(m_separator,"").stripWhiteSpace().isEmpty();
+ TQString s(str);
+ return s.tqreplace(m_separator,"").stripWhiteSpace().isEmpty();
}
-QString KexiDateFormatter::dateToString( const QDate& date ) const
+TQString KexiDateFormatter::dateToString( const TQDate& date ) const
{
return date.toString(m_qtFormat);
}
@@ -168,35 +168,35 @@ QString KexiDateFormatter::dateToString( const QDate& date ) const
//------------------------------------------------
KexiTimeFormatter::KexiTimeFormatter()
-: m_hmsRegExp( new QRegExp("(\\d*):(\\d*):(\\d*).*( am| pm){,1}", false/*!CS*/) )
- , m_hmRegExp( new QRegExp("(\\d*):(\\d*).*( am| pm){,1}", false/*!CS*/) )
+: m_hmsRegExp( new TQRegExp("(\\d*):(\\d*):(\\d*).*( am| pm){,1}", false/*!CS*/) )
+ , m_hmRegExp( new TQRegExp("(\\d*):(\\d*).*( am| pm){,1}", false/*!CS*/) )
{
- QString tf( KGlobal::locale()->timeFormat() );
- //m_hourpos, m_minpos, m_secpos; are result of tf.find()
- QString hourVariable, minVariable, secVariable;
+ TQString tf( KGlobal::locale()->timeFormat() );
+ //m_hourpos, m_minpos, m_secpos; are result of tf.tqfind()
+ TQString hourVariable, minVariable, secVariable;
- //detect position of HOUR section: find %H or %k or %I or %l
+ //detect position of HOUR section: tqfind %H or %k or %I or %l
m_24h = true;
m_hoursWithLeadingZero = true;
- m_hourpos = tf.find("%H", 0, true);
+ m_hourpos = tf.tqfind("%H", 0, true);
if (m_hourpos>=0) {
m_24h = true;
m_hoursWithLeadingZero = true;
}
else {
- m_hourpos = tf.find("%k", 0, true);
+ m_hourpos = tf.tqfind("%k", 0, true);
if (m_hourpos>=0) {
m_24h = true;
m_hoursWithLeadingZero = false;
}
else {
- m_hourpos = tf.find("%I", 0, true);
+ m_hourpos = tf.tqfind("%I", 0, true);
if (m_hourpos>=0) {
m_24h = false;
m_hoursWithLeadingZero = true;
}
else {
- m_hourpos = tf.find("%l", 0, true);
+ m_hourpos = tf.tqfind("%l", 0, true);
if (m_hourpos>=0) {
m_24h = false;
m_hoursWithLeadingZero = false;
@@ -204,9 +204,9 @@ KexiTimeFormatter::KexiTimeFormatter()
}
}
}
- m_minpos = tf.find("%M", 0, true);
- m_secpos = tf.find("%S", 0, true); //can be -1
- m_ampmpos = tf.find("%p", 0, true); //can be -1
+ m_minpos = tf.tqfind("%M", 0, true);
+ m_secpos = tf.tqfind("%S", 0, true); //can be -1
+ m_ampmpos = tf.tqfind("%p", 0, true); //can be -1
if (m_hourpos<0 || m_minpos<0) {
//set default: hr and min are needed, sec are optional
@@ -221,13 +221,13 @@ KexiTimeFormatter::KexiTimeFormatter()
hourVariable = tf.mid(m_hourpos, 2);
m_inputMask = tf;
-// m_inputMask.replace( hourVariable, "00" );
-// m_inputMask.replace( "%M", "00" );
-// m_inputMask.replace( "%S", "00" ); //optional
- m_inputMask.replace( hourVariable, "99" );
- m_inputMask.replace( "%M", "99" );
- m_inputMask.replace( "%S", "00" ); //optional
- m_inputMask.replace( "%p", "AA" ); //am or pm
+// m_inputMask.tqreplace( hourVariable, "00" );
+// m_inputMask.tqreplace( "%M", "00" );
+// m_inputMask.tqreplace( "%S", "00" ); //optional
+ m_inputMask.tqreplace( hourVariable, "99" );
+ m_inputMask.tqreplace( "%M", "99" );
+ m_inputMask.tqreplace( "%S", "00" ); //optional
+ m_inputMask.tqreplace( "%p", "AA" ); //am or pm
m_inputMask += ";_";
m_outputFormat = tf;
@@ -239,7 +239,7 @@ KexiTimeFormatter::~KexiTimeFormatter()
delete m_hmRegExp;
}
-QTime KexiTimeFormatter::stringToTime( const QString& str ) const
+TQTime KexiTimeFormatter::stringToTime( const TQString& str ) const
{
int hour, min, sec;
bool pm = false;
@@ -257,7 +257,7 @@ QTime KexiTimeFormatter::stringToTime( const QString& str ) const
}
if (tryWithoutSeconds) {
if (-1 == m_hmRegExp->search(str))
- return QTime(99,0,0);
+ return TQTime(99,0,0);
hour = m_hmRegExp->cap(1).toInt();
min = m_hmRegExp->cap(2).toInt();
sec = 0;
@@ -267,98 +267,98 @@ QTime KexiTimeFormatter::stringToTime( const QString& str ) const
if (pm && hour < 12)
hour += 12; //PM
- return QTime(hour, min, sec);
+ return TQTime(hour, min, sec);
}
-QVariant KexiTimeFormatter::stringToVariant( const QString& str )
+TQVariant KexiTimeFormatter::stringToVariant( const TQString& str )
{
if (isEmpty( str ))
- return QVariant();
- const QTime time( stringToTime( str ) );
+ return TQVariant();
+ const TQTime time( stringToTime( str ) );
if (time.isValid())
return time;
- return QVariant();
+ return TQVariant();
}
-bool KexiTimeFormatter::isEmpty( const QString& str ) const
+bool KexiTimeFormatter::isEmpty( const TQString& str ) const
{
- QString s(str);
- return s.replace(':',"").stripWhiteSpace().isEmpty();
+ TQString s(str);
+ return s.tqreplace(':',"").stripWhiteSpace().isEmpty();
}
-QString KexiTimeFormatter::timeToString( const QTime& time ) const
+TQString KexiTimeFormatter::timeToString( const TQTime& time ) const
{
if (!time.isValid())
- return QString::null;
+ return TQString();
- QString s(m_outputFormat);
+ TQString s(m_outputFormat);
if (m_24h) {
if (m_hoursWithLeadingZero)
- s.replace( "%H", QString::fromLatin1(time.hour()<10 ? "0" : "") + QString::number(time.hour()) );
+ s.tqreplace( "%H", TQString::tqfromLatin1(time.hour()<10 ? "0" : "") + TQString::number(time.hour()) );
else
- s.replace( "%k", QString::number(time.hour()) );
+ s.tqreplace( "%k", TQString::number(time.hour()) );
}
else {
int time12 = (time.hour()>12) ? (time.hour()-12) : time.hour();
if (m_hoursWithLeadingZero)
- s.replace( "%I", QString::fromLatin1(time12<10 ? "0" : "") + QString::number(time12) );
+ s.tqreplace( "%I", TQString::tqfromLatin1(time12<10 ? "0" : "") + TQString::number(time12) );
else
- s.replace( "%l", QString::number(time12) );
+ s.tqreplace( "%l", TQString::number(time12) );
}
- s.replace( "%M", QString::fromLatin1(time.minute()<10 ? "0" : "") + QString::number(time.minute()) );
+ s.tqreplace( "%M", TQString::tqfromLatin1(time.minute()<10 ? "0" : "") + TQString::number(time.minute()) );
if (m_secpos>=0)
- s.replace( "%S", QString::fromLatin1(time.second()<10 ? "0" : "") + QString::number(time.second()) );
+ s.tqreplace( "%S", TQString::tqfromLatin1(time.second()<10 ? "0" : "") + TQString::number(time.second()) );
if (m_ampmpos>=0)
- s.replace( "%p", KGlobal::locale()->translate( time.hour()>=12 ? "pm" : "am") );
+ s.tqreplace( "%p", KGlobal::locale()->translate( time.hour()>=12 ? "pm" : "am") );
return s;
}
//------------------------------------------------
-QString dateTimeInputMask(const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter)
+TQString dateTimeInputMask(const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter)
{
- QString mask(dateFormatter.inputMask());
- mask.truncate(dateFormatter.inputMask().length()-2);
- return mask + " " + timeFormatter.inputMask();
+ TQString tqmask(dateFormatter.inputMask());
+ tqmask.truncate(dateFormatter.inputMask().length()-2);
+ return tqmask + " " + timeFormatter.inputMask();
}
-QDateTime stringToDateTime(
- const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter, const QString& str)
+TQDateTime stringToDateTime(
+ const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter, const TQString& str)
{
- QString s( str.stripWhiteSpace() );
- const int timepos = s.find(" ");
- const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(s.mid(timepos+1)); //.replace(':',"").stripWhiteSpace().isEmpty();
+ TQString s( str.stripWhiteSpace() );
+ const int timepos = s.tqfind(" ");
+ const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(s.mid(timepos+1)); //.tqreplace(':',"").stripWhiteSpace().isEmpty();
if (emptyTime)
s = s.left(timepos);
if (timepos>0 && !emptyTime) {
- return QDateTime(
+ return TQDateTime(
dateFormatter.stringToDate( s.left(timepos) ),
timeFormatter.stringToTime( s.mid(timepos+1) )
);
}
else {
- return QDateTime(
+ return TQDateTime(
dateFormatter.stringToDate( s ),
- QTime(0,0,0)
+ TQTime(0,0,0)
);
}
}
bool dateTimeIsEmpty( const KexiDateFormatter& dateFormatter, const KexiTimeFormatter& timeFormatter,
- const QString& str )
+ const TQString& str )
{
- int timepos = str.find(" ");
- const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(str.mid(timepos+1)); //s.mid(timepos+1).replace(':',"").stripWhiteSpace().isEmpty();
- return (timepos >= 0 && dateFormatter.isEmpty(str.left(timepos)) //s.left(timepos).replace(m_dateFormatter.separator(), "").stripWhiteSpace().isEmpty()
+ int timepos = str.tqfind(" ");
+ const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(str.mid(timepos+1)); //s.mid(timepos+1).tqreplace(':',"").stripWhiteSpace().isEmpty();
+ return (timepos >= 0 && dateFormatter.isEmpty(str.left(timepos)) //s.left(timepos).tqreplace(m_dateFormatter.separator(), "").stripWhiteSpace().isEmpty()
&& emptyTime);
}
bool dateTimeIsValid( const KexiDateFormatter& dateFormatter,
- const KexiTimeFormatter& timeFormatter, const QString& str )
+ const KexiTimeFormatter& timeFormatter, const TQString& str )
{
- int timepos = str.find(" ");
- const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(str.mid(timepos+1)); //s.mid(timepos+1).replace(':',"").stripWhiteSpace().isEmpty();
- if (timepos >= 0 && dateFormatter.isEmpty(str.left(timepos)) // s.left(timepos).replace(m_dateFormatter.separator(), "").stripWhiteSpace().isEmpty()
+ int timepos = str.tqfind(" ");
+ const bool emptyTime = timepos >= 0 && timeFormatter.isEmpty(str.mid(timepos+1)); //s.mid(timepos+1).tqreplace(':',"").stripWhiteSpace().isEmpty();
+ if (timepos >= 0 && dateFormatter.isEmpty(str.left(timepos)) // s.left(timepos).tqreplace(m_dateFormatter.separator(), "").stripWhiteSpace().isEmpty()
&& emptyTime)
//empty date/time is valid
return true;