-rw-r--r-- | kaddressbook/kabprefs.cpp | 74 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 6 |
5 files changed, 84 insertions, 3 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 9270a7d..4b3ee47 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -25,6 +25,10 @@ | |||
25 | //#include <qstring.h> | 25 | //#include <qstring.h> |
26 | //#endif //KAB_EMBEDDED | 26 | //#endif //KAB_EMBEDDED |
27 | 27 | ||
28 | #include <qtextstream.h> | ||
29 | #include <qfile.h> | ||
30 | #include <stdlib.h> | ||
31 | #include <libkdepim/kpimglobalprefs.h> | ||
28 | 32 | ||
29 | #include <kconfig.h> | 33 | #include <kconfig.h> |
30 | #include <klocale.h> | 34 | #include <klocale.h> |
@@ -39,6 +43,8 @@ static KStaticDeleter<KABPrefs> staticDeleter; | |||
39 | KABPrefs::KABPrefs() | 43 | KABPrefs::KABPrefs() |
40 | : KPimPrefs("kaddressbookrc") | 44 | : KPimPrefs("kaddressbookrc") |
41 | { | 45 | { |
46 | |||
47 | mLocaleDict = 0; | ||
42 | mDetailsFont = QFont("helvetica",12); | 48 | mDetailsFont = QFont("helvetica",12); |
43 | KPrefs::setCurrentGroup( "Views" ); | 49 | KPrefs::setCurrentGroup( "Views" ); |
44 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 50 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
@@ -85,6 +91,9 @@ KABPrefs::KABPrefs() | |||
85 | KABPrefs::~KABPrefs() | 91 | KABPrefs::~KABPrefs() |
86 | { | 92 | { |
87 | //qDebug("KABPrefs::~KABPrefs() "); | 93 | //qDebug("KABPrefs::~KABPrefs() "); |
94 | setLocaleDict( 0 ); | ||
95 | if ( mLocaleDict ) | ||
96 | delete mLocaleDict; | ||
88 | } | 97 | } |
89 | 98 | ||
90 | KABPrefs *KABPrefs::instance() | 99 | KABPrefs *KABPrefs::instance() |
@@ -115,6 +124,71 @@ KConfig* KABPrefs::getConfig() | |||
115 | { | 124 | { |
116 | return config(); | 125 | return config(); |
117 | } | 126 | } |
127 | void KABPrefs::usrReadConfig() | ||
128 | { | ||
129 | QString fileName ; | ||
130 | #ifndef DESKTOP_VERSION | ||
131 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; | ||
132 | #else | ||
133 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; | ||
134 | #endif | ||
135 | int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | ||
136 | mLocaleDict = 0; | ||
137 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | ||
138 | |||
139 | if ( mPreferredLanguage == 1 ) | ||
140 | fileName = fileName+"germantranslation.txt"; | ||
141 | else if ( mPreferredLanguage == 4 ) | ||
142 | fileName = fileName+"usertranslation.txt"; | ||
143 | else if ( mPreferredLanguage == 2 ) | ||
144 | fileName = fileName+"frenchtranslation.txt"; | ||
145 | else if ( mPreferredLanguage == 3 ) | ||
146 | fileName = fileName+"italiantranslation.txt"; | ||
147 | QFile file( fileName ); | ||
148 | if (file.open( IO_ReadOnly ) ) { | ||
149 | QTextStream ts( &file ); | ||
150 | ts.setEncoding( QTextStream::Latin1 ); | ||
151 | //ts.setCodec( QTextCodec::latin1 ); | ||
152 | QString text = ts.read(); | ||
153 | file.close(); | ||
154 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
155 | QString line; | ||
156 | QString we; | ||
157 | QString wt; | ||
158 | int br = 0; | ||
159 | int nbr; | ||
160 | nbr = text.find ( "},", br ); | ||
161 | line = text.mid( br, nbr - br ); | ||
162 | br = nbr+1; | ||
163 | int se, ee, st, et; | ||
164 | mLocaleDict = new QDict<QString>; | ||
165 | QString end = "{ \"\",\"\" }"; | ||
166 | while ( (line != end) && (br > 1) ) { | ||
167 | //qDebug("%d *%s* ", br, line.latin1()); | ||
168 | se = line.find("\"")+1; | ||
169 | et = line.findRev("\"",-1); | ||
170 | ee = line.find("\",\""); | ||
171 | st = ee+3; | ||
172 | we = line.mid( se, ee-se ); | ||
173 | wt = line.mid( st, et-st ); | ||
174 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
175 | mLocaleDict->insert( we, new QString (wt) ); | ||
176 | nbr = text.find ( "}", br ); | ||
177 | line = text.mid( br, nbr - br ); | ||
178 | br = nbr+1; | ||
179 | } | ||
180 | //qDebug("end *%s* ", end.latin1()); | ||
181 | |||
182 | setLocaleDict( mLocaleDict ); | ||
183 | } else { | ||
184 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | ||
185 | } | ||
186 | |||
187 | |||
188 | } | ||
189 | qDebug("KABPrefs::usrReadConfig********************** "); | ||
190 | KPimPrefs::usrReadConfig(); | ||
191 | } | ||
118 | 192 | ||
119 | 193 | ||
120 | /*US | 194 | /*US |
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 4a3b6e2..1098f4c 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #define KABPREFS_H | 25 | #define KABPREFS_H |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qdict.h> | ||
28 | 29 | ||
29 | #include <libkdepim/kpimprefs.h> | 30 | #include <libkdepim/kpimprefs.h> |
30 | 31 | ||
@@ -60,6 +61,7 @@ class KABPrefs : public KPimPrefs | |||
60 | /** Write preferences to config file */ | 61 | /** Write preferences to config file */ |
61 | // void usrWriteConfig(); | 62 | // void usrWriteConfig(); |
62 | #endif //KAB_EMBEDDED | 63 | #endif //KAB_EMBEDDED |
64 | void usrReadConfig(); | ||
63 | 65 | ||
64 | 66 | ||
65 | // GUI | 67 | // GUI |
@@ -87,6 +89,7 @@ class KABPrefs : public KPimPrefs | |||
87 | private: | 89 | private: |
88 | KABPrefs(); | 90 | KABPrefs(); |
89 | 91 | ||
92 | QDict<QString> *mLocaleDict; | ||
90 | static KABPrefs *sInstance; | 93 | static KABPrefs *sInstance; |
91 | }; | 94 | }; |
92 | 95 | ||
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index f48f214..2832257 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -46,8 +46,7 @@ KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) | |||
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) |
47 | //MOC_SKIP_END | 47 | //MOC_SKIP_END |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | { | 49 | { |
50 | |||
51 | setIcon(SmallIcon( "ka24" ) ); | 50 | setIcon(SmallIcon( "ka24" ) ); |
52 | #if 0 | 51 | #if 0 |
53 | //US for embedded systems, create the toolbar before we initiate KABCore. | 52 | //US for embedded systems, create the toolbar before we initiate KABCore. |
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index da28870..8062354 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp | |||
@@ -43,6 +43,7 @@ KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, | |||
43 | const char *name ) | 43 | const char *name ) |
44 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() | 44 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() |
45 | { | 45 | { |
46 | |||
46 | initGUI(); | 47 | initGUI(); |
47 | } | 48 | } |
48 | 49 | ||
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 40089a1..a8816f9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -15,10 +15,11 @@ | |||
15 | #include <kglobal.h> | 15 | #include <kglobal.h> |
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <qdir.h> | 17 | #include <qdir.h> |
18 | #include "kabprefs.h" | ||
18 | #include "kaddressbookmain.h" | 19 | #include "kaddressbookmain.h" |
19 | #include "externalapphandler.h" | 20 | #include "externalapphandler.h" |
20 | #include <libkdepim/kpimglobalprefs.h> | 21 | #include <libkdepim/kpimglobalprefs.h> |
21 | 22 | void dumpMissing(); | |
22 | int main( int argc, char **argv ) | 23 | int main( int argc, char **argv ) |
23 | { | 24 | { |
24 | #ifndef DESKTOP_VERSION | 25 | #ifndef DESKTOP_VERSION |
@@ -71,6 +72,8 @@ int main( int argc, char **argv ) | |||
71 | 72 | ||
72 | #endif | 73 | #endif |
73 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
75 | // init language | ||
76 | KABPrefs::instance(); | ||
74 | KAddressBookMain m ; | 77 | KAddressBookMain m ; |
75 | //US MainWindow m; | 78 | //US MainWindow m; |
76 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
@@ -88,6 +91,7 @@ int main( int argc, char **argv ) | |||
88 | #endif | 91 | #endif |
89 | a.exec(); | 92 | a.exec(); |
90 | 93 | ||
94 | dumpMissing(); | ||
91 | 95 | ||
92 | } | 96 | } |
93 | qDebug("KA: Bye! "); | 97 | qDebug("KA: Bye! "); |