-rw-r--r-- | kaddressbook/kabprefs.cpp | 73 |
1 files changed, 5 insertions, 68 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 01c935f..3cbcc9a 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -43,13 +43,11 @@ | |||
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | KABPrefs *KABPrefs::sInstance = 0; | 45 | KABPrefs *KABPrefs::sInstance = 0; |
46 | static KStaticDeleter<KABPrefs> staticDeleter; | 46 | static KStaticDeleter<KABPrefs> staticDeleterAB; |
47 | 47 | ||
48 | KABPrefs::KABPrefs() | 48 | KABPrefs::KABPrefs() |
49 | : KPimPrefs("kaddressbookrc") | 49 | : KPimPrefs("kaddressbookrc") |
50 | { | 50 | { |
51 | |||
52 | mLocaleDict = 0; | ||
53 | mDetailsFont = QFont("helvetica",12); | 51 | mDetailsFont = QFont("helvetica",12); |
54 | KPrefs::setCurrentGroup( "Views" ); | 52 | KPrefs::setCurrentGroup( "Views" ); |
55 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 53 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
@@ -96,19 +94,18 @@ KABPrefs::KABPrefs() | |||
96 | KABPrefs::~KABPrefs() | 94 | KABPrefs::~KABPrefs() |
97 | { | 95 | { |
98 | //qDebug("KABPrefs::~KABPrefs() "); | 96 | //qDebug("KABPrefs::~KABPrefs() "); |
99 | setLocaleDict( 0 ); | 97 | if (sInstance == this) |
100 | if ( mLocaleDict ) | 98 | sInstance = staticDeleterAB.setObject(0); |
101 | delete mLocaleDict; | ||
102 | } | 99 | } |
103 | 100 | ||
104 | KABPrefs *KABPrefs::instance() | 101 | KABPrefs *KABPrefs::instance() |
105 | { | 102 | { |
106 | if ( !sInstance ) { | 103 | if ( !sInstance ) { |
107 | #ifdef KAB_EMBEDDED | 104 | #ifdef KAB_EMBEDDED |
108 | sInstance = staticDeleter.setObject( new KABPrefs() ); | 105 | sInstance = staticDeleterAB.setObject( new KABPrefs() ); |
109 | #else //KAB_EMBEDDED | 106 | #else //KAB_EMBEDDED |
110 | //US the following line has changed ???. Why | 107 | //US the following line has changed ???. Why |
111 | staticDeleter.setObject( sInstance, new KABPrefs() ); | 108 | staticDeleterAB.setObject( sInstance, new KABPrefs() ); |
112 | #endif //KAB_EMBEDDED | 109 | #endif //KAB_EMBEDDED |
113 | sInstance->readConfig(); | 110 | sInstance->readConfig(); |
114 | } | 111 | } |
@@ -131,66 +128,6 @@ KConfig* KABPrefs::getConfig() | |||
131 | } | 128 | } |
132 | void KABPrefs::usrReadConfig() | 129 | void KABPrefs::usrReadConfig() |
133 | { | 130 | { |
134 | QString fileName ; | ||
135 | #ifndef DESKTOP_VERSION | ||
136 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; | ||
137 | #else | ||
138 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; | ||
139 | #endif | ||
140 | int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | ||
141 | mLocaleDict = 0; | ||
142 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | ||
143 | |||
144 | if ( mPreferredLanguage == 1 ) | ||
145 | fileName = fileName+"germantranslation.txt"; | ||
146 | else if ( mPreferredLanguage == 4 ) | ||
147 | fileName = fileName+"usertranslation.txt"; | ||
148 | else if ( mPreferredLanguage == 2 ) | ||
149 | fileName = fileName+"frenchtranslation.txt"; | ||
150 | else if ( mPreferredLanguage == 3 ) | ||
151 | fileName = fileName+"italiantranslation.txt"; | ||
152 | QFile file( fileName ); | ||
153 | if (file.open( IO_ReadOnly ) ) { | ||
154 | QTextStream ts( &file ); | ||
155 | ts.setEncoding( QTextStream::Latin1 ); | ||
156 | //ts.setCodec( QTextCodec::latin1 ); | ||
157 | QString text = ts.read(); | ||
158 | file.close(); | ||
159 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
160 | QString line; | ||
161 | QString we; | ||
162 | QString wt; | ||
163 | int br = 0; | ||
164 | int nbr; | ||
165 | nbr = text.find ( "},", br ); | ||
166 | line = text.mid( br, nbr - br ); | ||
167 | br = nbr+1; | ||
168 | int se, ee, st, et; | ||
169 | mLocaleDict = new QDict<QString>; | ||
170 | QString end = "{ \"\",\"\" }"; | ||
171 | while ( (line != end) && (br > 1) ) { | ||
172 | //qDebug("%d *%s* ", br, line.latin1()); | ||
173 | se = line.find("\"")+1; | ||
174 | et = line.findRev("\"",-1); | ||
175 | ee = line.find("\",\""); | ||
176 | st = ee+3; | ||
177 | we = line.mid( se, ee-se ); | ||
178 | wt = line.mid( st, et-st ); | ||
179 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
180 | mLocaleDict->insert( we, new QString (wt) ); | ||
181 | nbr = text.find ( "}", br ); | ||
182 | line = text.mid( br, nbr - br ); | ||
183 | br = nbr+1; | ||
184 | } | ||
185 | //qDebug("end *%s* ", end.latin1()); | ||
186 | |||
187 | setLocaleDict( mLocaleDict ); | ||
188 | } else { | ||
189 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | ||
190 | } | ||
191 | |||
192 | |||
193 | } | ||
194 | KPimPrefs::usrReadConfig(); | 131 | KPimPrefs::usrReadConfig(); |
195 | } | 132 | } |
196 | 133 | ||