author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdecore/klocale.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdecore/klocale.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 1d8ae9f..dd310fa 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,23 +1,24 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | #include <QDesktopWidget> | ||
3 | 4 | ||
4 | #include "kdebug.h" | 5 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 6 | #include "kcalendarsystemgregorian.h" |
6 | 7 | ||
7 | #include "klocale.h" | 8 | #include "klocale.h" |
8 | 9 | ||
9 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
10 | 11 | ||
11 | //#define COLLECT_TRANSLATION | 12 | //#define COLLECT_TRANSLATION |
12 | 13 | ||
13 | 14 | ||
14 | QDict<QString> *mLocaleDict = 0; | 15 | Q3Dict<QString> *mLocaleDict = 0; |
15 | void setLocaleDict( QDict<QString> * dict ) | 16 | void setLocaleDict( Q3Dict<QString> * dict ) |
16 | { | 17 | { |
17 | mLocaleDict = dict; | 18 | mLocaleDict = dict; |
18 | 19 | ||
19 | } | 20 | } |
20 | 21 | ||
21 | #ifdef COLLECT_TRANSLATION | 22 | #ifdef COLLECT_TRANSLATION |
22 | 23 | ||
23 | QStringList missingTrans; | 24 | QStringList missingTrans; |
@@ -40,45 +41,45 @@ void addExist(const char *text,QString trans ) | |||
40 | existingTrans1.append(mis); | 41 | existingTrans1.append(mis); |
41 | existingTrans2.append(trans); | 42 | existingTrans2.append(trans); |
42 | 43 | ||
43 | } | 44 | } |
44 | 45 | ||
45 | } | 46 | } |
46 | 47 | ||
47 | #include <qfile.h> | 48 | #include <qfile.h> |
48 | #include <qtextstream.h> | 49 | #include <q3textstream.h> |
49 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
50 | #endif | 51 | #endif |
51 | void dumpMissing() | 52 | void dumpMissing() |
52 | { | 53 | { |
53 | #ifdef COLLECT_TRANSLATION | 54 | #ifdef COLLECT_TRANSLATION |
54 | QString fileName = "/tmp/usernewtrans.txt"; | 55 | QString fileName = "/tmp/usernewtrans.txt"; |
55 | QFile file( fileName ); | 56 | QFile file( fileName ); |
56 | if (!file.open( IO_WriteOnly ) ) { | 57 | if (!file.open( QIODevice::WriteOnly ) ) { |
57 | return ; | 58 | return ; |
58 | } | 59 | } |
59 | QTextStream ts( &file ); | 60 | Q3TextStream ts( &file ); |
60 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 61 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
61 | 62 | ||
62 | int i; | 63 | int i; |
63 | for ( i = 0; i< missingTrans.count(); ++i ) { | 64 | for ( i = 0; i< missingTrans.count(); ++i ) { |
64 | 65 | ||
65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 66 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 67 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
67 | 68 | ||
68 | } | 69 | } |
69 | file.close(); | 70 | file.close(); |
70 | { | 71 | { |
71 | QString fileName = "/tmp/usertrans.txt"; | 72 | QString fileName = "/tmp/usertrans.txt"; |
72 | QFile file( fileName ); | 73 | QFile file( fileName ); |
73 | if (!file.open( IO_WriteOnly ) ) { | 74 | if (!file.open( QIODevice::WriteOnly ) ) { |
74 | return ; | 75 | return ; |
75 | } | 76 | } |
76 | QTextStream ts( &file ); | 77 | Q3TextStream ts( &file ); |
77 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 78 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
78 | 79 | ||
79 | int i; | 80 | int i; |
80 | for ( i = 0; i< existingTrans1.count(); ++i ) { | 81 | for ( i = 0; i< existingTrans1.count(); ++i ) { |
81 | 82 | ||
82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); | 83 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); |
83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); | 84 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); |
84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; | 85 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; |
@@ -462,17 +463,17 @@ QString KLocale::formatDateTime(const QDateTime &pDateTime, | |||
462 | IntDateFormat intIntDateFormat) const | 463 | IntDateFormat intIntDateFormat) const |
463 | { | 464 | { |
464 | QString format("%1 %2"); | 465 | QString format("%1 %2"); |
465 | 466 | ||
466 | if ( intIntDateFormat == Default ) | 467 | if ( intIntDateFormat == Default ) |
467 | format = "%1 %2"; | 468 | format = "%1 %2"; |
468 | else if ( intIntDateFormat == Format1 ) | 469 | else if ( intIntDateFormat == Format1 ) |
469 | format = "%1 %2"; | 470 | format = "%1 %2"; |
470 | else if ( intIntDateFormat == ISODate ) | 471 | else if ( intIntDateFormat == Qt::ISODate ) |
471 | format = "%1T%2"; | 472 | format = "%1T%2"; |
472 | 473 | ||
473 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) | 474 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) |
474 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); | 475 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); |
475 | 476 | ||
476 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); | 477 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); |
477 | 478 | ||
478 | return res; | 479 | return res; |
@@ -522,17 +523,17 @@ QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) con | |||
522 | continue; | 523 | continue; |
523 | } | 524 | } |
524 | 525 | ||
525 | // remove space at the begining | 526 | // remove space at the begining |
526 | if (str.length() > strpos && str.at(strpos).isSpace()) | 527 | if (str.length() > strpos && str.at(strpos).isSpace()) |
527 | strpos++; | 528 | strpos++; |
528 | 529 | ||
529 | c = fmt.at(fmtpos++); | 530 | c = fmt.at(fmtpos++); |
530 | switch (c) | 531 | switch (c.unicode()) |
531 | { | 532 | { |
532 | case 'a': | 533 | case 'a': |
533 | case 'A': | 534 | case 'A': |
534 | // this will just be ignored | 535 | // this will just be ignored |
535 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 536 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
536 | for (int j = 1; j < 8; j++) { | 537 | for (int j = 1; j < 8; j++) { |
537 | QString s = weekDayName(j, c == 'a').lower(); | 538 | QString s = weekDayName(j, c == 'a').lower(); |
538 | int len = s.length(); | 539 | int len = s.length(); |
@@ -633,17 +634,17 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | |||
633 | continue; | 634 | continue; |
634 | } | 635 | } |
635 | 636 | ||
636 | // remove space at the begining | 637 | // remove space at the begining |
637 | if (str.length() > strpos && str.at(strpos).isSpace()) | 638 | if (str.length() > strpos && str.at(strpos).isSpace()) |
638 | strpos++; | 639 | strpos++; |
639 | 640 | ||
640 | c = Format.at(Formatpos++); | 641 | c = Format.at(Formatpos++); |
641 | switch (c) | 642 | switch (c.unicode()) |
642 | { | 643 | { |
643 | case 'p': | 644 | case 'p': |
644 | { | 645 | { |
645 | QString s; | 646 | QString s; |
646 | s = i18n("pm").lower(); | 647 | s = i18n("pm").lower(); |
647 | int len = s.length(); | 648 | int len = s.length(); |
648 | if (str.mid(strpos, len) == s) | 649 | if (str.mid(strpos, len) == s) |
649 | { | 650 | { |
@@ -729,17 +730,17 @@ QDateTime KLocale::readDateTime(const QString &intstr, | |||
729 | int pos = intstr.find("T"); | 730 | int pos = intstr.find("T"); |
730 | QString date = intstr.left(pos); | 731 | QString date = intstr.left(pos); |
731 | QString time = intstr.mid(pos+1); | 732 | QString time = intstr.mid(pos+1); |
732 | 733 | ||
733 | QString dformat = dateFormat(intIntDateFormat); | 734 | QString dformat = dateFormat(intIntDateFormat); |
734 | QString tformat = timeFormat(intIntDateFormat); | 735 | QString tformat = timeFormat(intIntDateFormat); |
735 | 736 | ||
736 | QDate m_date = readDate(date, dformat, &ok1); | 737 | QDate m_date = readDate(date, dformat, &ok1); |
737 | QTime m_time = readTime(time, tformat, &ok2); | 738 | QTime m_time = readTime(time, !tformat.isEmpty(), &ok2); |
738 | 739 | ||
739 | QDateTime m_dt; | 740 | QDateTime m_dt; |
740 | 741 | ||
741 | if (ok) | 742 | if (ok) |
742 | { | 743 | { |
743 | if ((ok1 == false) || (ok2 == false)) | 744 | if ((ok1 == false) || (ok2 == false)) |
744 | *ok = false; | 745 | *ok = false; |
745 | else | 746 | else |