-rw-r--r-- | kaddressbook/kabprefs.cpp | 73 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 1 |
2 files changed, 5 insertions, 69 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 01c935f..3cbcc9a 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -45,3 +45,3 @@ KABPrefs *KABPrefs::sInstance = 0; -static KStaticDeleter<KABPrefs> staticDeleter; +static KStaticDeleter<KABPrefs> staticDeleterAB; @@ -50,4 +50,2 @@ KABPrefs::KABPrefs() { - - mLocaleDict = 0; mDetailsFont = QFont("helvetica",12); @@ -98,5 +96,4 @@ KABPrefs::~KABPrefs() //qDebug("KABPrefs::~KABPrefs() "); - setLocaleDict( 0 ); - if ( mLocaleDict ) - delete mLocaleDict; + if (sInstance == this) + sInstance = staticDeleterAB.setObject(0); } @@ -107,6 +104,6 @@ KABPrefs *KABPrefs::instance() #ifdef KAB_EMBEDDED - sInstance = staticDeleter.setObject( new KABPrefs() ); + sInstance = staticDeleterAB.setObject( new KABPrefs() ); #else //KAB_EMBEDDED //US the following line has changed ???. Why - staticDeleter.setObject( sInstance, new KABPrefs() ); + staticDeleterAB.setObject( sInstance, new KABPrefs() ); #endif //KAB_EMBEDDED @@ -133,62 +130,2 @@ void KABPrefs::usrReadConfig() { - QString fileName ; -#ifndef DESKTOP_VERSION - fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; -#else - fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; -#endif - int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; - mLocaleDict = 0; - if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { - - if ( mPreferredLanguage == 1 ) - fileName = fileName+"germantranslation.txt"; - else if ( mPreferredLanguage == 4 ) - fileName = fileName+"usertranslation.txt"; - else if ( mPreferredLanguage == 2 ) - fileName = fileName+"frenchtranslation.txt"; - else if ( mPreferredLanguage == 3 ) - fileName = fileName+"italiantranslation.txt"; - QFile file( fileName ); - if (file.open( IO_ReadOnly ) ) { - QTextStream ts( &file ); - ts.setEncoding( QTextStream::Latin1 ); - //ts.setCodec( QTextCodec::latin1 ); - QString text = ts.read(); - file.close(); - text.replace( QRegExp("\\\\n"), "\n" ); - QString line; - QString we; - QString wt; - int br = 0; - int nbr; - nbr = text.find ( "},", br ); - line = text.mid( br, nbr - br ); - br = nbr+1; - int se, ee, st, et; - mLocaleDict = new QDict<QString>; - QString end = "{ \"\",\"\" }"; - while ( (line != end) && (br > 1) ) { - //qDebug("%d *%s* ", br, line.latin1()); - se = line.find("\"")+1; - et = line.findRev("\"",-1); - ee = line.find("\",\""); - st = ee+3; - we = line.mid( se, ee-se ); - wt = line.mid( st, et-st ); - //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); - mLocaleDict->insert( we, new QString (wt) ); - nbr = text.find ( "}", br ); - line = text.mid( br, nbr - br ); - br = nbr+1; - } - //qDebug("end *%s* ", end.latin1()); - - setLocaleDict( mLocaleDict ); - } else { - qDebug("KO: Cannot find translation file %s",fileName.latin1() ); - } - - - } KPimPrefs::usrReadConfig(); diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 1098f4c..cc8413e 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h @@ -91,3 +91,2 @@ class KABPrefs : public KPimPrefs - QDict<QString> *mLocaleDict; static KABPrefs *sInstance; |