-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 @@ -20,30 +20,36 @@ with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ //US#ifdef KAB_EMBEDDED //#include <qstring.h> //#endif //KAB_EMBEDDED +#include <qtextstream.h> +#include <qfile.h> +#include <stdlib.h> +#include <libkdepim/kpimglobalprefs.h> #include <kconfig.h> #include <klocale.h> #include <kstaticdeleter.h> //US#include <kdebug.h> // defines kdDebug() #include "kabprefs.h" KABPrefs *KABPrefs::sInstance = 0; static KStaticDeleter<KABPrefs> staticDeleter; KABPrefs::KABPrefs() : KPimPrefs("kaddressbookrc") { + + mLocaleDict = 0; mDetailsFont = QFont("helvetica",12); KPrefs::setCurrentGroup( "Views" ); addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); KPrefs::setCurrentGroup( "General" ); addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); @@ -80,16 +86,19 @@ KABPrefs::KABPrefs() KPrefs::setCurrentGroup( "Filters" ); addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); } KABPrefs::~KABPrefs() { //qDebug("KABPrefs::~KABPrefs() "); + setLocaleDict( 0 ); + if ( mLocaleDict ) + delete mLocaleDict; } KABPrefs *KABPrefs::instance() { if ( !sInstance ) { #ifdef KAB_EMBEDDED sInstance = staticDeleter.setObject( new KABPrefs() ); #else //KAB_EMBEDDED @@ -110,16 +119,81 @@ void KABPrefs::setCategoryDefaults() << i18n( "Customer" ) << i18n( "Friend" ); } // US introduce a nonconst way to return the config object. KConfig* KABPrefs::getConfig() { return config(); } +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() ); + } + + + } + qDebug("KABPrefs::usrReadConfig********************** "); + KPimPrefs::usrReadConfig(); +} /*US void KABPrefs::usrSetDefaults() { KPimPrefs::usrSetDefaults(); } diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 4a3b6e2..1098f4c 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h @@ -20,16 +20,17 @@ with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KABPREFS_H #define KABPREFS_H #include <qstringlist.h> +#include <qdict.h> #include <libkdepim/kpimprefs.h> class KConfig; class KABPrefs : public KPimPrefs { public: @@ -55,16 +56,17 @@ class KABPrefs : public KPimPrefs // void usrSetDefaults(); /** Read preferences from config file */ // void usrReadConfig(); /** Write preferences to config file */ // void usrWriteConfig(); #endif //KAB_EMBEDDED + void usrReadConfig(); // GUI bool mJumpButtonBarVisible; bool mDetailsPageVisible; bool mMultipleViewsAtOnce; bool mSearchWithReturn; QValueList<int> mExtensionsSplitter; @@ -82,12 +84,13 @@ class KABPrefs : public KPimPrefs int mCurrentFilter; void setCategoryDefaults(); QFont mDetailsFont; private: KABPrefs(); + QDict<QString> *mLocaleDict; static KABPrefs *sInstance; }; #endif diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index f48f214..2832257 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -41,18 +41,17 @@ #ifdef KAB_EMBEDDED KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) #else //KAB_EMBEDDED //MOC_SKIP_BEGIN KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) //MOC_SKIP_END #endif //KAB_EMBEDDED -{ - +{ setIcon(SmallIcon( "ka24" ) ); #if 0 //US for embedded systems, create the toolbar before we initiate KABCore. // KABCore will fill the toolbar with menues and icons QMainWindow::ToolBarDock tbd; tbd = Top; iconToolBar = new QToolBar( this ); addToolBar (iconToolBar , tbd ); diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index da28870..8062354 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp @@ -38,16 +38,17 @@ #include <kdebug.h> #include "kaddressbookview.h" KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : QWidget( parent, name ), mAddressBook( ab ), mFieldList() { + initGUI(); } KAddressBookView::~KAddressBookView() { kdDebug(5720) << "KAddressBookView::~KAddressBookView: destroying - " << name() << endl; } diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 40089a1..a8816f9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -10,20 +10,21 @@ #endif #include <qtextcodec.h> #include <kstandarddirs.h> #include <qregexp.h> #include <kglobal.h> #include <stdio.h> #include <qdir.h> +#include "kabprefs.h" #include "kaddressbookmain.h" #include "externalapphandler.h" #include <libkdepim/kpimglobalprefs.h> - +void dumpMissing(); int main( int argc, char **argv ) { #ifndef DESKTOP_VERSION QPEApplication a( argc, argv ); a.setKeepRunning (); #else QApplication a( argc, argv ); QApplication::setStyle( new QPlatinumStyle ()); @@ -66,16 +67,18 @@ int main( int argc, char **argv ) #else QString fileName ; fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); QApplication::addLibraryPath ( qApp->applicationDirPath () ); #endif KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); + // init language + KABPrefs::instance(); KAddressBookMain m ; //US MainWindow m; QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); { KPimGlobalPrefs::instance()->setGlobalConfig(); } #ifndef DESKTOP_VERSION @@ -83,13 +86,14 @@ int main( int argc, char **argv ) #else a.setMainWidget( &m ); m.resize (640, 480 ); m.show(); #endif a.exec(); + dumpMissing(); } qDebug("KA: Bye! "); } |