summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabprefs.cpp
authorzautrix <zautrix>2004-10-23 11:40:59 (UTC)
committer zautrix <zautrix>2004-10-23 11:40:59 (UTC)
commit25b0233d54a6d4bea457fd843073e57183d8bea0 (patch) (side-by-side diff)
tree4d85c3cec59e8b085738be7111c7e2bb0ee7219e /kaddressbook/kabprefs.cpp
parentba2583db0431059cd7368be23c9653e81af16d29 (diff)
downloadkdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.zip
kdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.tar.gz
kdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.tar.bz2
global settings bugfixes
Diffstat (limited to 'kaddressbook/kabprefs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabprefs.cpp73
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 @@
#endif
KABPrefs *KABPrefs::sInstance = 0;
-static KStaticDeleter<KABPrefs> staticDeleter;
+static KStaticDeleter<KABPrefs> staticDeleterAB;
KABPrefs::KABPrefs()
: KPimPrefs("kaddressbookrc")
{
-
- mLocaleDict = 0;
mDetailsFont = QFont("helvetica",12);
KPrefs::setCurrentGroup( "Views" );
addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
@@ -96,19 +94,18 @@ KABPrefs::KABPrefs()
KABPrefs::~KABPrefs()
{
//qDebug("KABPrefs::~KABPrefs() ");
- setLocaleDict( 0 );
- if ( mLocaleDict )
- delete mLocaleDict;
+ if (sInstance == this)
+ sInstance = staticDeleterAB.setObject(0);
}
KABPrefs *KABPrefs::instance()
{
if ( !sInstance ) {
#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
sInstance->readConfig();
}
@@ -131,66 +128,6 @@ KConfig* KABPrefs::getConfig()
}
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();
}