summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp4
-rw-r--r--microkde/kdecore/klocale.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 27acfec..673d845 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -726,195 +726,197 @@ QString KLocale::monthName(int i,bool shortName) const
726 726
727 return QString::null; 727 return QString::null;
728} 728}
729 729
730QString KLocale::country() const 730QString KLocale::country() const
731{ 731{
732 return QString::null; 732 return QString::null;
733} 733}
734 734
735QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 735QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
736{ 736{
737 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 737 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
738 738
739 if ( dformat == ISODate ) 739 if ( dformat == ISODate )
740 return "%Y-%m-%d"; 740 return "%Y-%m-%d";
741 741
742 if ( QApplication::desktop()->width() < 480 ) { 742 if ( QApplication::desktop()->width() < 480 ) {
743 if ( dformat == Default ) 743 if ( dformat == Default )
744 return "%a %d %b %Y"; 744 return "%a %d %b %Y";
745 else if ( dformat == Format1 ) 745 else if ( dformat == Format1 )
746 return "%a %b %d %Y"; 746 return "%a %b %d %Y";
747 } else { 747 } else {
748 if ( dformat == Default ) 748 if ( dformat == Default )
749 return "%A %d %B %Y"; 749 return "%A %d %B %Y";
750 else if ( dformat == Format1 ) 750 else if ( dformat == Format1 )
751 return "%A %B %d %Y"; 751 return "%A %B %d %Y";
752 752
753 } 753 }
754 return mDateFormat ; 754 return mDateFormat ;
755} 755}
756 756
757QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const 757QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
758{ 758{
759 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 759 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
760 760
761 if ( dformat == Default ) 761 if ( dformat == Default )
762 return "%d.%m.%Y"; 762 return "%d.%m.%Y";
763 else if ( dformat == Format1 ) 763 else if ( dformat == Format1 )
764 return "%m.%d.%Y"; 764 return "%m.%d.%Y";
765 else if ( dformat == ISODate ) // = Qt::ISODate 765 else if ( dformat == ISODate ) // = Qt::ISODate
766 return "%Y-%m-%d"; 766 return "%Y-%m-%d";
767 return mDateFormatShort ; 767 return mDateFormatShort ;
768 768
769} 769}
770 770
771 771
772QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const 772QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
773{ 773{
774 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; 774 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
775 775
776 if ( tformat == Default ) 776 if ( tformat == Default )
777 if ( mHourF24Format) 777 if ( mHourF24Format)
778 return "%H:%M:%S"; 778 return "%H:%M:%S";
779 else 779 else
780 return "%I:%M:%S%p"; 780 return "%I:%M:%S%p";
781 781
782 else if ( tformat == Format1 ) 782 else if ( tformat == Format1 )
783 if ( mHourF24Format) 783 if ( mHourF24Format)
784 return "%H:%M:%S"; 784 return "%H:%M:%S";
785 else 785 else
786 return "%I:%M:%S%p"; 786 return "%I:%M:%S%p";
787 787
788 else if ( tformat == ISODate ) // = Qt::ISODate 788 else if ( tformat == ISODate ) // = Qt::ISODate
789 if ( mHourF24Format) 789 if ( mHourF24Format)
790 return "%H:%M:%S"; 790 return "%H:%M:%S";
791 else 791 else
792 return "%I:%M:%S%p"; 792 return "%I:%M:%S%p";
793 793
794} 794}
795 795
796void KLocale::insertCatalogue ( const QString & ) 796void KLocale::insertCatalogue ( const QString & )
797{ 797{
798} 798}
799 799
800KCalendarSystem *KLocale::calendar() 800KCalendarSystem *KLocale::calendar()
801{ 801{
802 if ( !mCalendarSystem ) { 802 if ( !mCalendarSystem ) {
803 mCalendarSystem = new KCalendarSystemGregorian; 803 mCalendarSystem = new KCalendarSystemGregorian;
804 } 804 }
805 805
806 return mCalendarSystem; 806 return mCalendarSystem;
807} 807}
808 808
809int KLocale::timezoneOffset( QString timeZone ) 809int KLocale::timezoneOffset( QString timeZone )
810{ 810{
811 int ret = 1001; 811 int ret = 1001;
812 int index = mTimeZoneList.findIndex( timeZone ); 812 int index = mTimeZoneList.findIndex( timeZone );
813 if ( index < 24 ) 813 if ( index < 24 )
814 ret = ( index-11 ) * 60 ; 814 ret = ( index-11 ) * 60 ;
815 return ret; 815 return ret;
816} 816}
817 817
818QStringList KLocale::timeZoneList() const 818QStringList KLocale::timeZoneList() const
819{ 819{
820 return mTimeZoneList; 820 return mTimeZoneList;
821} 821}
822void KLocale::setTimezone( const QString &timeZone ) 822void KLocale::setTimezone( const QString &timeZone, bool oddTZ )
823{ 823{
824 mTimeZoneOffset = timezoneOffset( timeZone ); 824 mTimeZoneOffset = timezoneOffset( timeZone );
825 if ( oddTZ )
826 mTimeZoneOffset += 30;
825} 827}
826 828
827void KLocale::setDaylightSaving( bool b, int start , int end ) 829void KLocale::setDaylightSaving( bool b, int start , int end )
828{ 830{
829 daylightEnabled = b; 831 daylightEnabled = b;
830 daylightStart = start; 832 daylightStart = start;
831 daylightEnd = end; 833 daylightEnd = end;
832 mSouthDaylight = (end < start); 834 mSouthDaylight = (end < start);
833 // qDebug("klocale daylight %d %d %d ", b, start , end ); 835 // qDebug("klocale daylight %d %d %d ", b, start , end );
834} 836}
835 837
836int KLocale::localTimeOffset( const QDateTime &dt ) 838int KLocale::localTimeOffset( const QDateTime &dt )
837{ 839{
838 bool addDaylight = false; 840 bool addDaylight = false;
839 if ( daylightEnabled ) { 841 if ( daylightEnabled ) {
840 int d_end, d_start; 842 int d_end, d_start;
841 int dayofyear = dt.date().dayOfYear(); 843 int dayofyear = dt.date().dayOfYear();
842 int year = dt.date().year(); 844 int year = dt.date().year();
843 int add = 0; 845 int add = 0;
844 if ( QDate::leapYear(year) ) 846 if ( QDate::leapYear(year) )
845 add = 1; 847 add = 1;
846 QDate date ( year,1,1 ); 848 QDate date ( year,1,1 );
847 if ( daylightEnd > 59 ) 849 if ( daylightEnd > 59 )
848 d_end = daylightEnd +add; 850 d_end = daylightEnd +add;
849 else 851 else
850 d_end = daylightEnd; 852 d_end = daylightEnd;
851 if ( daylightStart > 59 ) 853 if ( daylightStart > 59 )
852 d_start = daylightStart +add; 854 d_start = daylightStart +add;
853 else 855 else
854 d_start = daylightStart; 856 d_start = daylightStart;
855 QDate s_date = date.addDays( d_start -1 ); 857 QDate s_date = date.addDays( d_start -1 );
856 QDate e_date = date.addDays( d_end -1 ); 858 QDate e_date = date.addDays( d_end -1 );
857 int dof = s_date.dayOfWeek(); 859 int dof = s_date.dayOfWeek();
858 if ( dof < 7 ) 860 if ( dof < 7 )
859 s_date = s_date.addDays( -dof ); 861 s_date = s_date.addDays( -dof );
860 dof = e_date.dayOfWeek(); 862 dof = e_date.dayOfWeek();
861 if ( dof < 7 ) 863 if ( dof < 7 )
862 e_date = e_date.addDays( -dof ); 864 e_date = e_date.addDays( -dof );
863 QTime startTime ( 3,0,0 ); 865 QTime startTime ( 3,0,0 );
864 QDateTime startDt( s_date, startTime ); 866 QDateTime startDt( s_date, startTime );
865 QDateTime endDt( e_date, startTime ); 867 QDateTime endDt( e_date, startTime );
866 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 868 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
867 if ( mSouthDaylight ) { 869 if ( mSouthDaylight ) {
868 if ( ! ( endDt < dt && dt < startDt) ) 870 if ( ! ( endDt < dt && dt < startDt) )
869 addDaylight = true; 871 addDaylight = true;
870 } else { 872 } else {
871 if ( startDt < dt && dt < endDt ) 873 if ( startDt < dt && dt < endDt )
872 addDaylight = true; 874 addDaylight = true;
873 875
874 876
875 } 877 }
876 } 878 }
877 int addMin = 0; 879 int addMin = 0;
878 if ( addDaylight ) 880 if ( addDaylight )
879 addMin = 60; 881 addMin = 60;
880 return mTimeZoneOffset + addMin; 882 return mTimeZoneOffset + addMin;
881} 883}
882// ****************************************************************** 884// ******************************************************************
883// added LR 885// added LR
884QString KLocale::formatNumber(double num, int precision) const 886QString KLocale::formatNumber(double num, int precision) const
885{ 887{
886 bool neg = num < 0; 888 bool neg = num < 0;
887 if (precision == -1) precision = 2; 889 if (precision == -1) precision = 2;
888 QString res = QString::number(neg?-num:num, 'f', precision); 890 QString res = QString::number(neg?-num:num, 'f', precision);
889 int pos = res.find('.'); 891 int pos = res.find('.');
890 if (pos == -1) pos = res.length(); 892 if (pos == -1) pos = res.length();
891 else res.replace(pos, 1, decimalSymbol()); 893 else res.replace(pos, 1, decimalSymbol());
892 894
893 while (0 < (pos -= 3)) 895 while (0 < (pos -= 3))
894 res.insert(pos, thousandsSeparator()); // thousand sep 896 res.insert(pos, thousandsSeparator()); // thousand sep
895 897
896 // How can we know where we should put the sign? 898 // How can we know where we should put the sign?
897 res.prepend(neg?negativeSign():positiveSign()); 899 res.prepend(neg?negativeSign():positiveSign());
898 900
899 return res; 901 return res;
900} 902}
901QString KLocale::formatNumber(const QString &numStr) const 903QString KLocale::formatNumber(const QString &numStr) const
902{ 904{
903 return formatNumber(numStr.toDouble()); 905 return formatNumber(numStr.toDouble());
904} 906}
905double KLocale::readNumber(const QString &_str, bool * ok) const 907double KLocale::readNumber(const QString &_str, bool * ok) const
906{ 908{
907 QString str = _str.stripWhiteSpace(); 909 QString str = _str.stripWhiteSpace();
908 bool neg = str.find(negativeSign()) == 0; 910 bool neg = str.find(negativeSign()) == 0;
909 if (neg) 911 if (neg)
910 str.remove( 0, negativeSign().length() ); 912 str.remove( 0, negativeSign().length() );
911 913
912 /* will hold the scientific notation portion of the number. 914 /* will hold the scientific notation portion of the number.
913 Example, with 2.34E+23, exponentialPart == "E+23" 915 Example, with 2.34E+23, exponentialPart == "E+23"
914 */ 916 */
915 QString exponentialPart; 917 QString exponentialPart;
916 int EPos; 918 int EPos;
917 919
918 EPos = str.find('E', 0, false); 920 EPos = str.find('E', 0, false);
919 921
920 if (EPos != -1) 922 if (EPos != -1)
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 5783530..be9442c 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -2,117 +2,117 @@
2#define MINIKDE_KLOCALE_H 2#define MINIKDE_KLOCALE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdict.h> 7#include <qdict.h>
8 8
9#ifndef I18N_NOOP 9#ifndef I18N_NOOP
10#define I18N_NOOP(x) (x) 10#define I18N_NOOP(x) (x)
11#endif 11#endif
12 12
13class KCalendarSystem; 13class KCalendarSystem;
14void setLocaleDict( QDict<QString> * dict ); 14void setLocaleDict( QDict<QString> * dict );
15QString i18n(const char *text); 15QString i18n(const char *text);
16QString i18n(const char *hint, const char *text); 16QString i18n(const char *hint, const char *text);
17QString i18n(const char *text1, const char *textn, int num); 17QString i18n(const char *text1, const char *textn, int num);
18 18
19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict 19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict
20// with our i18n method. we use uic -tr tr2i18n to redirect 20// with our i18n method. we use uic -tr tr2i18n to redirect
21// to the right i18n() function 21// to the right i18n() function
22inline QString tr2i18n(const char* message, const char* =0) { 22inline QString tr2i18n(const char* message, const char* =0) {
23 return i18n( message); 23 return i18n( message);
24} 24}
25 25
26class KLocale 26class KLocale
27{ 27{
28 public: 28 public:
29 KLocale(); 29 KLocale();
30 30
31 QString formatNumber(double num, int precision = -1) const; 31 QString formatNumber(double num, int precision = -1) const;
32 QString formatNumber(const QString &numStr) const; 32 QString formatNumber(const QString &numStr) const;
33 double readNumber(const QString &numStr, bool * ok = 0) const; 33 double readNumber(const QString &numStr, bool * ok = 0) const;
34 34
35 QString decimalSymbol() const; 35 QString decimalSymbol() const;
36 QString thousandsSeparator() const; 36 QString thousandsSeparator() const;
37 QString positiveSign() const; 37 QString positiveSign() const;
38 QString negativeSign() const; 38 QString negativeSign() const;
39 39
40 40
41 QString translate( const char *index ) const; 41 QString translate( const char *index ) const;
42 QString translate( const char *index, const char *fallback) const; 42 QString translate( const char *index, const char *fallback) const;
43 43
44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45 45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; 46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; 48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
49 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
50 bool shortFormat, 50 bool shortFormat,
51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
52 52
53 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
57 57
58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
59 59
60 bool use12Clock() const; 60 bool use12Clock() const;
61 bool weekStartsMonday() const; 61 bool weekStartsMonday() const;
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 68
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74
75 KCalendarSystem *calendar(); 75 KCalendarSystem *calendar();
76 void setHore24Format ( bool ); 76 void setHore24Format ( bool );
77 void setWeekStartMonday( bool ); 77 void setWeekStartMonday( bool );
78 void setIntDateFormat( IntDateFormat ); 78 void setIntDateFormat( IntDateFormat );
79 void setIntTimeFormat( IntDateFormat ); 79 void setIntTimeFormat( IntDateFormat );
80 IntDateFormat getIntDateFormat( ); 80 IntDateFormat getIntDateFormat( );
81 IntDateFormat getIntTimeFormat( ); 81 IntDateFormat getIntTimeFormat( );
82 void setLanguage( int ); 82 void setLanguage( int );
83 void setDateFormat( QString ); 83 void setDateFormat( QString );
84 void setDateFormatShort( QString ); 84 void setDateFormatShort( QString );
85 85
86 QString m_decimalSymbol; 86 QString m_decimalSymbol;
87 QString m_thousandsSeparator; 87 QString m_thousandsSeparator;
88 QString m_currencySymbol; 88 QString m_currencySymbol;
89 QString m_monetaryDecimalSymbol; 89 QString m_monetaryDecimalSymbol;
90 QString m_monetaryThousandsSeparator; 90 QString m_monetaryThousandsSeparator;
91 QString m_positiveSign; 91 QString m_positiveSign;
92 QString m_negativeSign; 92 QString m_negativeSign;
93 93
94 int timezoneOffset( QString ); 94 int timezoneOffset( QString );
95 QStringList timeZoneList() const; 95 QStringList timeZoneList() const;
96 void setDaylightSaving( bool, int , int ); 96 void setDaylightSaving( bool, int , int );
97 int localTimeOffset(const QDateTime &); 97 int localTimeOffset(const QDateTime &);
98 void setTimezone( const QString &timeZone ); 98 void setTimezone( const QString &timeZone , bool oddTZ);
99 private: 99 private:
100 QTime readTime(const QString &str, bool seconds, bool *ok) const; 100 QTime readTime(const QString &str, bool seconds, bool *ok) const;
101 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 101 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
102 KCalendarSystem *mCalendarSystem; 102 KCalendarSystem *mCalendarSystem;
103 bool mWeekStartsMonday; 103 bool mWeekStartsMonday;
104 bool mHourF24Format; 104 bool mHourF24Format;
105 IntDateFormat mIntDateFormat; 105 IntDateFormat mIntDateFormat;
106 IntDateFormat mIntTimeFormat; 106 IntDateFormat mIntTimeFormat;
107 int mLanguage; 107 int mLanguage;
108 QString mDateFormat; 108 QString mDateFormat;
109 QString mDateFormatShort; 109 QString mDateFormatShort;
110 QStringList mTimeZoneList; 110 QStringList mTimeZoneList;
111 bool daylightEnabled; 111 bool daylightEnabled;
112 int mDaylightTZoffset; 112 int mDaylightTZoffset;
113 int mNondaylightTZoffset; 113 int mNondaylightTZoffset;
114 bool mSouthDaylight; 114 bool mSouthDaylight;
115 int daylightStart, daylightEnd, mTimeZoneOffset; 115 int daylightStart, daylightEnd, mTimeZoneOffset;
116}; 116};
117 117
118#endif 118#endif